summaryrefslogtreecommitdiff
path: root/test/units/modules/network
diff options
context:
space:
mode:
Diffstat (limited to 'test/units/modules/network')
-rw-r--r--test/units/modules/network/fortios/test_fortios_alertemail_setting.py431
-rw-r--r--test/units/modules/network/fortios/test_fortios_antivirus_heuristic.py151
-rw-r--r--test/units/modules/network/fortios/test_fortios_antivirus_profile.py339
-rw-r--r--test/units/modules/network/fortios/test_fortios_antivirus_quarantine.py231
-rw-r--r--test/units/modules/network/fortios/test_fortios_antivirus_settings.py167
-rw-r--r--test/units/modules/network/fortios/test_fortios_application_custom.py289
-rw-r--r--test/units/modules/network/fortios/test_fortios_application_group.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_application_list.py309
-rw-r--r--test/units/modules/network/fortios/test_fortios_application_name.py309
-rw-r--r--test/units/modules/network/fortios/test_fortios_application_rule_settings.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_authentication_rule.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_authentication_scheme.py289
-rw-r--r--test/units/modules/network/fortios/test_fortios_authentication_setting.py207
-rw-r--r--test/units/modules/network/fortios/test_fortios_dlp_filepattern.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_dlp_fp_doc_source.py369
-rw-r--r--test/units/modules/network/fortios/test_fortios_dlp_fp_sensitivity.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_dlp_sensor.py289
-rw-r--r--test/units/modules/network/fortios/test_fortios_dlp_settings.py183
-rw-r--r--test/units/modules/network/fortios/test_fortios_dnsfilter_domain_filter.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_dnsfilter_profile.py289
-rw-r--r--test/units/modules/network/fortios/test_fortios_endpoint_control_client.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_endpoint_control_forticlient_ems.py289
-rw-r--r--test/units/modules/network/fortios/test_fortios_endpoint_control_forticlient_registration_sync.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_endpoint_control_profile.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_endpoint_control_settings.py255
-rw-r--r--test/units/modules/network/fortios/test_fortios_extender_controller_extender.py559
-rw-r--r--test/units/modules/network/fortios/test_fortios_facts.py103
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_DoS_policy.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_DoS_policy6.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_address.py439
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_address6.py349
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_address6_template.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_addrgrp.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_addrgrp6.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_auth_portal.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_central_snat_map.py259
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_dnstranslation.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_identity_based_route.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_interface_policy.py399
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_interface_policy6.py399
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_internet_service.py269
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_internet_service_custom.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_internet_service_group.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ip_translation.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ipmacbinding_setting.py167
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ipmacbinding_table.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ippool.py329
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ippool6.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ipv6_eh_filter.py207
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ldb_monitor.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_local_in_policy.py259
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_local_in_policy6.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_multicast_address.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_multicast_address6.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_multicast_policy.py309
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_multicast_policy6.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_policy.py1169
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_policy46.py359
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_policy6.py789
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_policy64.py359
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_profile_group.py329
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_profile_protocol_options.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_proxy_address.py349
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_proxy_addrgrp.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_proxy_policy.py599
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_schedule_group.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_schedule_onetime.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_schedule_recurring.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_service_category.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_service_custom.py409
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_service_group.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_shaper_per_ip_shaper.py269
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_shaper_traffic_shaper.py269
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_shaping_policy.py299
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_shaping_profile.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_sniffer.py439
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ssh_host_key.py269
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ssh_local_ca.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ssh_local_key.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ssh_setting.py215
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ssl_server.py329
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ssl_setting.py231
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ssl_ssh_profile.py309
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_ttl_policy.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_vip.py839
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_vip46.py339
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_vip6.py789
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_vip64.py339
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_vipgrp.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_vipgrp46.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_vipgrp6.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_vipgrp64.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_wildcard_fqdn_custom.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_firewall_wildcard_fqdn_group.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_ftp_proxy_explicit.py183
-rw-r--r--test/units/modules/network/fortios/test_fortios_icap_profile.py309
-rw-r--r--test/units/modules/network/fortios/test_fortios_icap_server.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_ips_custom.py329
-rw-r--r--test/units/modules/network/fortios/test_fortios_ips_decoder.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_ips_global.py247
-rw-r--r--test/units/modules/network/fortios/test_fortios_ips_rule.py329
-rw-r--r--test/units/modules/network/fortios/test_fortios_ips_rule_settings.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_ips_sensor.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_ips_settings.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_custom_field.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_disk_filter.py407
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_disk_setting.py367
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_eventfilter.py231
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortianalyzer2_filter.py263
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortianalyzer2_setting.py295
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortianalyzer3_filter.py263
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortianalyzer3_setting.py295
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortianalyzer_filter.py263
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortianalyzer_override_filter.py263
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortianalyzer_override_setting.py311
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortianalyzer_setting.py295
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortiguard_filter.py263
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortiguard_override_filter.py263
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortiguard_override_setting.py191
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_fortiguard_setting.py207
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_gui_display.py167
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_memory_filter.py399
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_memory_global_setting.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_memory_setting.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_null_device_filter.py255
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_null_device_setting.py151
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_setting.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_syslogd2_filter.py255
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_syslogd2_setting.py223
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_syslogd3_filter.py255
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_syslogd3_setting.py223
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_syslogd4_filter.py255
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_syslogd4_setting.py223
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_syslogd_filter.py255
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_syslogd_override_filter.py255
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_syslogd_override_setting.py231
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_syslogd_setting.py223
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_threat_weight.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_webtrends_filter.py255
-rw-r--r--test/units/modules/network/fortios/test_fortios_log_webtrends_setting.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_report_chart.py369
-rw-r--r--test/units/modules/network/fortios/test_fortios_report_dataset.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_report_layout.py329
-rw-r--r--test/units/modules/network/fortios/test_fortios_report_setting.py183
-rw-r--r--test/units/modules/network/fortios/test_fortios_report_style.py449
-rw-r--r--test/units/modules/network/fortios/test_fortios_report_theme.py489
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_access_list.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_access_list6.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_aspath_list.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_auth_path.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_bfd.py143
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_bfd6.py143
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_bgp.py447
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_community_list.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_isis.py431
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_key_chain.py189
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_multicast.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_multicast6.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_multicast_flow.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_ospf.py335
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_ospf6.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_policy.py339
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_policy6.py319
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_prefix_list.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_prefix_list6.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_rip.py207
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_ripng.py183
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_route_map.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_setting.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_static.py379
-rw-r--r--test/units/modules/network/fortios/test_fortios_router_static6.py309
-rw-r--r--test/units/modules/network/fortios/test_fortios_spamfilter_bwl.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_spamfilter_bword.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_spamfilter_dnsbl.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_spamfilter_fortishield.py167
-rw-r--r--test/units/modules/network/fortios/test_fortios_spamfilter_iptrust.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_spamfilter_mheader.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_spamfilter_options.py151
-rw-r--r--test/units/modules/network/fortios/test_fortios_spamfilter_profile.py339
-rw-r--r--test/units/modules/network/fortios/test_fortios_ssh_filter_profile.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_802_1X_settings.py167
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_custom_command.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_global.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_igmp_snooping.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_lldp_profile.py269
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_lldp_settings.py183
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_mac_sync_settings.py151
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_managed_switch.py389
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_network_monitor_settings.py151
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_qos_dot1p_map.py289
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_qos_ip_dscp_map.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_qos_qos_policy.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_qos_queue_policy.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_quarantine.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_security_policy_802_1X.py339
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_security_policy_captive_portal.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_sflow.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_storm_control.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_stp_settings.py207
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_switch_group.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_switch_interface_tag.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_switch_log.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_switch_profile.py217
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_system.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_virtual_port_pool.py207
-rw-r--r--test/units/modules/network/fortios/test_fortios_switch_controller_vlan.py287
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_accprofile.py349
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_admin.py689
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_affinity_interrupt.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_affinity_packet_redistribution.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_alarm.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_alias.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_api_user.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_arp_table.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_auto_install.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_auto_script.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_automation_action.py359
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_automation_destination.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_automation_stitch.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_automation_trigger.py299
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_autoupdate_push_update.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_autoupdate_schedule.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_autoupdate_tunneling.py183
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_central_management.py263
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_cluster_sync.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_console.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_csf.py215
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_custom_language.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_ddns.py359
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_dedicated_mgmt.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_dhcp6_server.py359
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_dhcp_server.py589
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_dns.py223
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_dns_database.py319
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_dns_server.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_dscp_based_priority.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_email_server.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_external_resource.py259
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_fips_cc.py167
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_firmware_upgrade.py68
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_fm.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_fortiguard.py391
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_fortimanager.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_fortisandbox.py191
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_fsso_polling.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_ftm_push.py167
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_geoip_override.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_global.py1567
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_gre_tunnel.py349
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_ha.py647
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_ha_monitor.py167
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_interface.py1769
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_ipip_tunnel.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_ips_urlfilter_dns.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_ips_urlfilter_dns6.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_ipv6_neighbor_cache.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_ipv6_tunnel.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_link_monitor.py409
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_mac_address_table.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_management_tunnel.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_mobile_tunnel.py329
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_nat64.py191
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_nd_proxy.py143
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_netflow.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_network_visibility.py191
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_ntp.py183
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_object_tagging.py259
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_password_policy.py231
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_password_policy_guest_admin.py231
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_pppoe_interface.py349
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_probe_response.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_proxy_arp.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_admin.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_alertmail.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_auth.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_device_detection_portal.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_ec.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_fortiguard_wf.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_ftp.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_group.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_http.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_icap.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_image.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_mail.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_nac_quar.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_nntp.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_spam.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_sslvpn.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_traffic_quota.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_utm.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_replacemsg_webproxy.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_resource_limits.py287
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_sdn_connector.py489
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_session_helper.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_session_ttl.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_settings.py1031
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_sflow.py167
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_sit_tunnel.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_sms_server.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_snmp_community.py329
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_snmp_sysinfo.py207
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_snmp_user.py339
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_storage.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_switch_interface.py259
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_tos_based_priority.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_vdom.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_vdom_dns.py191
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_vdom_exception.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_vdom_link.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_vdom_netflow.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_vdom_property.py399
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_vdom_radius_server.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_vdom_sflow.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_virtual_wan_link.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_virtual_wire_pair.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_vxlan.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_wccp.py419
-rw-r--r--test/units/modules/network/fortios/test_fortios_system_zone.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_adgrp.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_device.py269
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_device_access_list.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_device_category.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_device_group.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_domain_controller.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_fortitoken.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_fsso.py379
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_fsso_polling.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_group.py399
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_krb_keytab.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_ldap.py429
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_local.py399
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_password_policy.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_peer.py319
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_peergrp.py189
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_pop3.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_quarantine.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_radius.py539
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_security_exempt_list.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_setting.py263
-rw-r--r--test/units/modules/network/fortios/test_fortios_user_tacacsplus.py299
-rw-r--r--test/units/modules/network/fortios/test_fortios_voip_profile.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_certificate_ca.py289
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_certificate_crl.py329
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_certificate_local.py429
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_certificate_ocsp_server.py259
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_certificate_remote.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_certificate_setting.py287
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ipsec_concentrator.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ipsec_forticlient.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ipsec_manualkey.py289
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ipsec_manualkey_interface.py329
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase1.py1149
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase1_interface.py1419
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase2.py599
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase2_interface.py589
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_l2tp.py183
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_pptp.py191
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ssl_settings.py495
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ssl_web_host_check_software.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ssl_web_portal.py689
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ssl_web_realm.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ssl_web_user_bookmark.py199
-rw-r--r--test/units/modules/network/fortios/test_fortios_vpn_ssl_web_user_group_bookmark.py189
-rw-r--r--test/units/modules/network/fortios/test_fortios_waf_main_class.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_waf_profile.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_waf_signature.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_waf_sub_class.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_wanopt_auth_group.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_wanopt_cache_service.py183
-rw-r--r--test/units/modules/network/fortios/test_fortios_wanopt_content_delivery_network_rule.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_wanopt_peer.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_wanopt_profile.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_wanopt_remote_storage.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_wanopt_settings.py167
-rw-r--r--test/units/modules/network/fortios/test_fortios_wanopt_webcache.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_web_proxy_debug_url.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_web_proxy_explicit.py351
-rw-r--r--test/units/modules/network/fortios/test_fortios_web_proxy_forward_server.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_web_proxy_forward_server_group.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_web_proxy_global.py247
-rw-r--r--test/units/modules/network/fortios/test_fortios_web_proxy_profile.py289
-rw-r--r--test/units/modules/network/fortios/test_fortios_web_proxy_url_match.py249
-rw-r--r--test/units/modules/network/fortios/test_fortios_web_proxy_wisp.py259
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_content.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_content_header.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_fortiguard.py231
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_ftgd_local_cat.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_ftgd_local_rating.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_cache_setting.py159
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_setting.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_setting6.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_override.py299
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_profile.py479
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_search_engine.py259
-rw-r--r--test/units/modules/network/fortios/test_fortios_webfilter_urlfilter.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_ap_status.py229
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_ble_profile.py319
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_bonjour_profile.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_global.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_3gpp_cellular.py189
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_ip_address_type.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_nai_realm.py189
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_network_auth_type.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_roaming_consortium.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_venue_name.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_conn_capability.py309
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_operator_name.py209
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_osu_provider.py239
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_wan_metric.py279
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_hs_profile.py489
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_icon.py189
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_qos_map.py189
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_inter_controller.py183
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_qos_profile.py329
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_setting.py175
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_timers.py255
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_utm_profile.py269
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_vap.py1109
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_vap_group.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_wids_profile.py679
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_wtp.py509
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_wtp_group.py219
-rw-r--r--test/units/modules/network/fortios/test_fortios_wireless_controller_wtp_profile.py439
423 files changed, 0 insertions, 118002 deletions
diff --git a/test/units/modules/network/fortios/test_fortios_alertemail_setting.py b/test/units/modules/network/fortios/test_fortios_alertemail_setting.py
deleted file mode 100644
index 1b9617f181..0000000000
--- a/test/units/modules/network/fortios/test_fortios_alertemail_setting.py
+++ /dev/null
@@ -1,431 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_alertemail_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_alertemail_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_alertemail_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'alertemail_setting': {
- 'admin_login_logs': 'enable',
- 'alert_interval': '4',
- 'amc_interface_bypass_mode': 'enable',
- 'antivirus_logs': 'enable',
- 'configuration_changes_logs': 'enable',
- 'critical_interval': '8',
- 'debug_interval': '9',
- 'email_interval': '10',
- 'emergency_interval': '11',
- 'error_interval': '12',
- 'FDS_license_expiring_days': '13',
- 'FDS_license_expiring_warning': 'enable',
- 'FDS_update_logs': 'enable',
- 'filter_mode': 'category',
- 'FIPS_CC_errors': 'enable',
- 'firewall_authentication_failure_logs': 'enable',
- 'fortiguard_log_quota_warning': 'enable',
- 'FSSO_disconnect_logs': 'enable',
- 'HA_logs': 'enable',
- 'information_interval': '22',
- 'IPS_logs': 'enable',
- 'IPsec_errors_logs': 'enable',
- 'local_disk_usage': '25',
- 'log_disk_usage_warning': 'enable',
- 'mailto1': 'test_value_27',
- 'mailto2': 'test_value_28',
- 'mailto3': 'test_value_29',
- 'notification_interval': '30',
- 'PPP_errors_logs': 'enable',
- 'severity': 'emergency',
- 'ssh_logs': 'enable',
- 'sslvpn_authentication_errors_logs': 'enable',
- 'username': 'test_value_35',
- 'violation_traffic_logs': 'enable',
- 'warning_interval': '37',
- 'webfilter_logs': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_alertemail_setting.fortios_alertemail(input_data, fos_instance)
-
- expected_data = {
- 'admin-login-logs': 'enable',
- 'alert-interval': '4',
- 'amc-interface-bypass-mode': 'enable',
- 'antivirus-logs': 'enable',
- 'configuration-changes-logs': 'enable',
- 'critical-interval': '8',
- 'debug-interval': '9',
- 'email-interval': '10',
- 'emergency-interval': '11',
- 'error-interval': '12',
- 'FDS-license-expiring-days': '13',
- 'FDS-license-expiring-warning': 'enable',
- 'FDS-update-logs': 'enable',
- 'filter-mode': 'category',
- 'FIPS-CC-errors': 'enable',
- 'firewall-authentication-failure-logs': 'enable',
- 'fortiguard-log-quota-warning': 'enable',
- 'FSSO-disconnect-logs': 'enable',
- 'HA-logs': 'enable',
- 'information-interval': '22',
- 'IPS-logs': 'enable',
- 'IPsec-errors-logs': 'enable',
- 'local-disk-usage': '25',
- 'log-disk-usage-warning': 'enable',
- 'mailto1': 'test_value_27',
- 'mailto2': 'test_value_28',
- 'mailto3': 'test_value_29',
- 'notification-interval': '30',
- 'PPP-errors-logs': 'enable',
- 'severity': 'emergency',
- 'ssh-logs': 'enable',
- 'sslvpn-authentication-errors-logs': 'enable',
- 'username': 'test_value_35',
- 'violation-traffic-logs': 'enable',
- 'warning-interval': '37',
- 'webfilter-logs': 'enable'
- }
-
- set_method_mock.assert_called_with('alertemail', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_alertemail_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'alertemail_setting': {
- 'admin_login_logs': 'enable',
- 'alert_interval': '4',
- 'amc_interface_bypass_mode': 'enable',
- 'antivirus_logs': 'enable',
- 'configuration_changes_logs': 'enable',
- 'critical_interval': '8',
- 'debug_interval': '9',
- 'email_interval': '10',
- 'emergency_interval': '11',
- 'error_interval': '12',
- 'FDS_license_expiring_days': '13',
- 'FDS_license_expiring_warning': 'enable',
- 'FDS_update_logs': 'enable',
- 'filter_mode': 'category',
- 'FIPS_CC_errors': 'enable',
- 'firewall_authentication_failure_logs': 'enable',
- 'fortiguard_log_quota_warning': 'enable',
- 'FSSO_disconnect_logs': 'enable',
- 'HA_logs': 'enable',
- 'information_interval': '22',
- 'IPS_logs': 'enable',
- 'IPsec_errors_logs': 'enable',
- 'local_disk_usage': '25',
- 'log_disk_usage_warning': 'enable',
- 'mailto1': 'test_value_27',
- 'mailto2': 'test_value_28',
- 'mailto3': 'test_value_29',
- 'notification_interval': '30',
- 'PPP_errors_logs': 'enable',
- 'severity': 'emergency',
- 'ssh_logs': 'enable',
- 'sslvpn_authentication_errors_logs': 'enable',
- 'username': 'test_value_35',
- 'violation_traffic_logs': 'enable',
- 'warning_interval': '37',
- 'webfilter_logs': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_alertemail_setting.fortios_alertemail(input_data, fos_instance)
-
- expected_data = {
- 'admin-login-logs': 'enable',
- 'alert-interval': '4',
- 'amc-interface-bypass-mode': 'enable',
- 'antivirus-logs': 'enable',
- 'configuration-changes-logs': 'enable',
- 'critical-interval': '8',
- 'debug-interval': '9',
- 'email-interval': '10',
- 'emergency-interval': '11',
- 'error-interval': '12',
- 'FDS-license-expiring-days': '13',
- 'FDS-license-expiring-warning': 'enable',
- 'FDS-update-logs': 'enable',
- 'filter-mode': 'category',
- 'FIPS-CC-errors': 'enable',
- 'firewall-authentication-failure-logs': 'enable',
- 'fortiguard-log-quota-warning': 'enable',
- 'FSSO-disconnect-logs': 'enable',
- 'HA-logs': 'enable',
- 'information-interval': '22',
- 'IPS-logs': 'enable',
- 'IPsec-errors-logs': 'enable',
- 'local-disk-usage': '25',
- 'log-disk-usage-warning': 'enable',
- 'mailto1': 'test_value_27',
- 'mailto2': 'test_value_28',
- 'mailto3': 'test_value_29',
- 'notification-interval': '30',
- 'PPP-errors-logs': 'enable',
- 'severity': 'emergency',
- 'ssh-logs': 'enable',
- 'sslvpn-authentication-errors-logs': 'enable',
- 'username': 'test_value_35',
- 'violation-traffic-logs': 'enable',
- 'warning-interval': '37',
- 'webfilter-logs': 'enable'
- }
-
- set_method_mock.assert_called_with('alertemail', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_alertemail_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'alertemail_setting': {
- 'admin_login_logs': 'enable',
- 'alert_interval': '4',
- 'amc_interface_bypass_mode': 'enable',
- 'antivirus_logs': 'enable',
- 'configuration_changes_logs': 'enable',
- 'critical_interval': '8',
- 'debug_interval': '9',
- 'email_interval': '10',
- 'emergency_interval': '11',
- 'error_interval': '12',
- 'FDS_license_expiring_days': '13',
- 'FDS_license_expiring_warning': 'enable',
- 'FDS_update_logs': 'enable',
- 'filter_mode': 'category',
- 'FIPS_CC_errors': 'enable',
- 'firewall_authentication_failure_logs': 'enable',
- 'fortiguard_log_quota_warning': 'enable',
- 'FSSO_disconnect_logs': 'enable',
- 'HA_logs': 'enable',
- 'information_interval': '22',
- 'IPS_logs': 'enable',
- 'IPsec_errors_logs': 'enable',
- 'local_disk_usage': '25',
- 'log_disk_usage_warning': 'enable',
- 'mailto1': 'test_value_27',
- 'mailto2': 'test_value_28',
- 'mailto3': 'test_value_29',
- 'notification_interval': '30',
- 'PPP_errors_logs': 'enable',
- 'severity': 'emergency',
- 'ssh_logs': 'enable',
- 'sslvpn_authentication_errors_logs': 'enable',
- 'username': 'test_value_35',
- 'violation_traffic_logs': 'enable',
- 'warning_interval': '37',
- 'webfilter_logs': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_alertemail_setting.fortios_alertemail(input_data, fos_instance)
-
- expected_data = {
- 'admin-login-logs': 'enable',
- 'alert-interval': '4',
- 'amc-interface-bypass-mode': 'enable',
- 'antivirus-logs': 'enable',
- 'configuration-changes-logs': 'enable',
- 'critical-interval': '8',
- 'debug-interval': '9',
- 'email-interval': '10',
- 'emergency-interval': '11',
- 'error-interval': '12',
- 'FDS-license-expiring-days': '13',
- 'FDS-license-expiring-warning': 'enable',
- 'FDS-update-logs': 'enable',
- 'filter-mode': 'category',
- 'FIPS-CC-errors': 'enable',
- 'firewall-authentication-failure-logs': 'enable',
- 'fortiguard-log-quota-warning': 'enable',
- 'FSSO-disconnect-logs': 'enable',
- 'HA-logs': 'enable',
- 'information-interval': '22',
- 'IPS-logs': 'enable',
- 'IPsec-errors-logs': 'enable',
- 'local-disk-usage': '25',
- 'log-disk-usage-warning': 'enable',
- 'mailto1': 'test_value_27',
- 'mailto2': 'test_value_28',
- 'mailto3': 'test_value_29',
- 'notification-interval': '30',
- 'PPP-errors-logs': 'enable',
- 'severity': 'emergency',
- 'ssh-logs': 'enable',
- 'sslvpn-authentication-errors-logs': 'enable',
- 'username': 'test_value_35',
- 'violation-traffic-logs': 'enable',
- 'warning-interval': '37',
- 'webfilter-logs': 'enable'
- }
-
- set_method_mock.assert_called_with('alertemail', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_alertemail_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'alertemail_setting': {
- 'random_attribute_not_valid': 'tag',
- 'admin_login_logs': 'enable',
- 'alert_interval': '4',
- 'amc_interface_bypass_mode': 'enable',
- 'antivirus_logs': 'enable',
- 'configuration_changes_logs': 'enable',
- 'critical_interval': '8',
- 'debug_interval': '9',
- 'email_interval': '10',
- 'emergency_interval': '11',
- 'error_interval': '12',
- 'FDS_license_expiring_days': '13',
- 'FDS_license_expiring_warning': 'enable',
- 'FDS_update_logs': 'enable',
- 'filter_mode': 'category',
- 'FIPS_CC_errors': 'enable',
- 'firewall_authentication_failure_logs': 'enable',
- 'fortiguard_log_quota_warning': 'enable',
- 'FSSO_disconnect_logs': 'enable',
- 'HA_logs': 'enable',
- 'information_interval': '22',
- 'IPS_logs': 'enable',
- 'IPsec_errors_logs': 'enable',
- 'local_disk_usage': '25',
- 'log_disk_usage_warning': 'enable',
- 'mailto1': 'test_value_27',
- 'mailto2': 'test_value_28',
- 'mailto3': 'test_value_29',
- 'notification_interval': '30',
- 'PPP_errors_logs': 'enable',
- 'severity': 'emergency',
- 'ssh_logs': 'enable',
- 'sslvpn_authentication_errors_logs': 'enable',
- 'username': 'test_value_35',
- 'violation_traffic_logs': 'enable',
- 'warning_interval': '37',
- 'webfilter_logs': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_alertemail_setting.fortios_alertemail(input_data, fos_instance)
-
- expected_data = {
- 'admin-login-logs': 'enable',
- 'alert-interval': '4',
- 'amc-interface-bypass-mode': 'enable',
- 'antivirus-logs': 'enable',
- 'configuration-changes-logs': 'enable',
- 'critical-interval': '8',
- 'debug-interval': '9',
- 'email-interval': '10',
- 'emergency-interval': '11',
- 'error-interval': '12',
- 'FDS-license-expiring-days': '13',
- 'FDS-license-expiring-warning': 'enable',
- 'FDS-update-logs': 'enable',
- 'filter-mode': 'category',
- 'FIPS-CC-errors': 'enable',
- 'firewall-authentication-failure-logs': 'enable',
- 'fortiguard-log-quota-warning': 'enable',
- 'FSSO-disconnect-logs': 'enable',
- 'HA-logs': 'enable',
- 'information-interval': '22',
- 'IPS-logs': 'enable',
- 'IPsec-errors-logs': 'enable',
- 'local-disk-usage': '25',
- 'log-disk-usage-warning': 'enable',
- 'mailto1': 'test_value_27',
- 'mailto2': 'test_value_28',
- 'mailto3': 'test_value_29',
- 'notification-interval': '30',
- 'PPP-errors-logs': 'enable',
- 'severity': 'emergency',
- 'ssh-logs': 'enable',
- 'sslvpn-authentication-errors-logs': 'enable',
- 'username': 'test_value_35',
- 'violation-traffic-logs': 'enable',
- 'warning-interval': '37',
- 'webfilter-logs': 'enable'
- }
-
- set_method_mock.assert_called_with('alertemail', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_antivirus_heuristic.py b/test/units/modules/network/fortios/test_fortios_antivirus_heuristic.py
deleted file mode 100644
index 83073e4864..0000000000
--- a/test/units/modules/network/fortios/test_fortios_antivirus_heuristic.py
+++ /dev/null
@@ -1,151 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_antivirus_heuristic
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_antivirus_heuristic.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_antivirus_heuristic_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_heuristic': {
- 'mode': 'pass'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_heuristic.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'mode': 'pass'
- }
-
- set_method_mock.assert_called_with('antivirus', 'heuristic', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_antivirus_heuristic_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_heuristic': {
- 'mode': 'pass'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_heuristic.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'mode': 'pass'
- }
-
- set_method_mock.assert_called_with('antivirus', 'heuristic', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_antivirus_heuristic_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_heuristic': {
- 'mode': 'pass'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_heuristic.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'mode': 'pass'
- }
-
- set_method_mock.assert_called_with('antivirus', 'heuristic', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_antivirus_heuristic_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_heuristic': {
- 'random_attribute_not_valid': 'tag',
- 'mode': 'pass'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_heuristic.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'mode': 'pass'
- }
-
- set_method_mock.assert_called_with('antivirus', 'heuristic', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_antivirus_profile.py b/test/units/modules/network/fortios/test_fortios_antivirus_profile.py
deleted file mode 100644
index d0a804a4ab..0000000000
--- a/test/units/modules/network/fortios/test_fortios_antivirus_profile.py
+++ /dev/null
@@ -1,339 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_antivirus_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_antivirus_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_antivirus_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_profile': {
- 'analytics_bl_filetype': '3',
- 'analytics_db': 'disable',
- 'analytics_max_upload': '5',
- 'analytics_wl_filetype': '6',
- 'av_block_log': 'enable',
- 'av_virus_log': 'enable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'ftgd_analytics': 'disable',
- 'inspection_mode': 'proxy',
- 'mobile_malware_db': 'disable',
- 'name': 'default_name_14',
- 'replacemsg_group': 'test_value_15',
- 'scan_mode': 'quick',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_profile.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'analytics-bl-filetype': '3',
- 'analytics-db': 'disable',
- 'analytics-max-upload': '5',
- 'analytics-wl-filetype': '6',
- 'av-block-log': 'enable',
- 'av-virus-log': 'enable',
- 'comment': 'Comment.',
- 'extended-log': 'enable',
- 'ftgd-analytics': 'disable',
- 'inspection-mode': 'proxy',
- 'mobile-malware-db': 'disable',
- 'name': 'default_name_14',
- 'replacemsg-group': 'test_value_15',
- 'scan-mode': 'quick',
-
- }
-
- set_method_mock.assert_called_with('antivirus', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_antivirus_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_profile': {
- 'analytics_bl_filetype': '3',
- 'analytics_db': 'disable',
- 'analytics_max_upload': '5',
- 'analytics_wl_filetype': '6',
- 'av_block_log': 'enable',
- 'av_virus_log': 'enable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'ftgd_analytics': 'disable',
- 'inspection_mode': 'proxy',
- 'mobile_malware_db': 'disable',
- 'name': 'default_name_14',
- 'replacemsg_group': 'test_value_15',
- 'scan_mode': 'quick',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_profile.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'analytics-bl-filetype': '3',
- 'analytics-db': 'disable',
- 'analytics-max-upload': '5',
- 'analytics-wl-filetype': '6',
- 'av-block-log': 'enable',
- 'av-virus-log': 'enable',
- 'comment': 'Comment.',
- 'extended-log': 'enable',
- 'ftgd-analytics': 'disable',
- 'inspection-mode': 'proxy',
- 'mobile-malware-db': 'disable',
- 'name': 'default_name_14',
- 'replacemsg-group': 'test_value_15',
- 'scan-mode': 'quick',
-
- }
-
- set_method_mock.assert_called_with('antivirus', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_antivirus_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'antivirus_profile': {
- 'analytics_bl_filetype': '3',
- 'analytics_db': 'disable',
- 'analytics_max_upload': '5',
- 'analytics_wl_filetype': '6',
- 'av_block_log': 'enable',
- 'av_virus_log': 'enable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'ftgd_analytics': 'disable',
- 'inspection_mode': 'proxy',
- 'mobile_malware_db': 'disable',
- 'name': 'default_name_14',
- 'replacemsg_group': 'test_value_15',
- 'scan_mode': 'quick',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_profile.fortios_antivirus(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('antivirus', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_antivirus_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'antivirus_profile': {
- 'analytics_bl_filetype': '3',
- 'analytics_db': 'disable',
- 'analytics_max_upload': '5',
- 'analytics_wl_filetype': '6',
- 'av_block_log': 'enable',
- 'av_virus_log': 'enable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'ftgd_analytics': 'disable',
- 'inspection_mode': 'proxy',
- 'mobile_malware_db': 'disable',
- 'name': 'default_name_14',
- 'replacemsg_group': 'test_value_15',
- 'scan_mode': 'quick',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_profile.fortios_antivirus(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('antivirus', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_antivirus_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_profile': {
- 'analytics_bl_filetype': '3',
- 'analytics_db': 'disable',
- 'analytics_max_upload': '5',
- 'analytics_wl_filetype': '6',
- 'av_block_log': 'enable',
- 'av_virus_log': 'enable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'ftgd_analytics': 'disable',
- 'inspection_mode': 'proxy',
- 'mobile_malware_db': 'disable',
- 'name': 'default_name_14',
- 'replacemsg_group': 'test_value_15',
- 'scan_mode': 'quick',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_profile.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'analytics-bl-filetype': '3',
- 'analytics-db': 'disable',
- 'analytics-max-upload': '5',
- 'analytics-wl-filetype': '6',
- 'av-block-log': 'enable',
- 'av-virus-log': 'enable',
- 'comment': 'Comment.',
- 'extended-log': 'enable',
- 'ftgd-analytics': 'disable',
- 'inspection-mode': 'proxy',
- 'mobile-malware-db': 'disable',
- 'name': 'default_name_14',
- 'replacemsg-group': 'test_value_15',
- 'scan-mode': 'quick',
-
- }
-
- set_method_mock.assert_called_with('antivirus', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_antivirus_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_profile': {
- 'random_attribute_not_valid': 'tag',
- 'analytics_bl_filetype': '3',
- 'analytics_db': 'disable',
- 'analytics_max_upload': '5',
- 'analytics_wl_filetype': '6',
- 'av_block_log': 'enable',
- 'av_virus_log': 'enable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'ftgd_analytics': 'disable',
- 'inspection_mode': 'proxy',
- 'mobile_malware_db': 'disable',
- 'name': 'default_name_14',
- 'replacemsg_group': 'test_value_15',
- 'scan_mode': 'quick',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_profile.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'analytics-bl-filetype': '3',
- 'analytics-db': 'disable',
- 'analytics-max-upload': '5',
- 'analytics-wl-filetype': '6',
- 'av-block-log': 'enable',
- 'av-virus-log': 'enable',
- 'comment': 'Comment.',
- 'extended-log': 'enable',
- 'ftgd-analytics': 'disable',
- 'inspection-mode': 'proxy',
- 'mobile-malware-db': 'disable',
- 'name': 'default_name_14',
- 'replacemsg-group': 'test_value_15',
- 'scan-mode': 'quick',
-
- }
-
- set_method_mock.assert_called_with('antivirus', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_antivirus_quarantine.py b/test/units/modules/network/fortios/test_fortios_antivirus_quarantine.py
deleted file mode 100644
index 8d2cf19e06..0000000000
--- a/test/units/modules/network/fortios/test_fortios_antivirus_quarantine.py
+++ /dev/null
@@ -1,231 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_antivirus_quarantine
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_antivirus_quarantine.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_antivirus_quarantine_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_quarantine': {
- 'agelimit': '3',
- 'destination': 'NULL',
- 'drop_blocked': 'imap',
- 'drop_heuristic': 'imap',
- 'drop_infected': 'imap',
- 'lowspace': 'drop-new',
- 'maxfilesize': '9',
- 'quarantine_quota': '10',
- 'store_blocked': 'imap',
- 'store_heuristic': 'imap',
- 'store_infected': 'imap'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_quarantine.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'agelimit': '3',
- 'destination': 'NULL',
- 'drop-blocked': 'imap',
- 'drop-heuristic': 'imap',
- 'drop-infected': 'imap',
- 'lowspace': 'drop-new',
- 'maxfilesize': '9',
- 'quarantine-quota': '10',
- 'store-blocked': 'imap',
- 'store-heuristic': 'imap',
- 'store-infected': 'imap'
- }
-
- set_method_mock.assert_called_with('antivirus', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_antivirus_quarantine_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_quarantine': {
- 'agelimit': '3',
- 'destination': 'NULL',
- 'drop_blocked': 'imap',
- 'drop_heuristic': 'imap',
- 'drop_infected': 'imap',
- 'lowspace': 'drop-new',
- 'maxfilesize': '9',
- 'quarantine_quota': '10',
- 'store_blocked': 'imap',
- 'store_heuristic': 'imap',
- 'store_infected': 'imap'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_quarantine.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'agelimit': '3',
- 'destination': 'NULL',
- 'drop-blocked': 'imap',
- 'drop-heuristic': 'imap',
- 'drop-infected': 'imap',
- 'lowspace': 'drop-new',
- 'maxfilesize': '9',
- 'quarantine-quota': '10',
- 'store-blocked': 'imap',
- 'store-heuristic': 'imap',
- 'store-infected': 'imap'
- }
-
- set_method_mock.assert_called_with('antivirus', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_antivirus_quarantine_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_quarantine': {
- 'agelimit': '3',
- 'destination': 'NULL',
- 'drop_blocked': 'imap',
- 'drop_heuristic': 'imap',
- 'drop_infected': 'imap',
- 'lowspace': 'drop-new',
- 'maxfilesize': '9',
- 'quarantine_quota': '10',
- 'store_blocked': 'imap',
- 'store_heuristic': 'imap',
- 'store_infected': 'imap'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_quarantine.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'agelimit': '3',
- 'destination': 'NULL',
- 'drop-blocked': 'imap',
- 'drop-heuristic': 'imap',
- 'drop-infected': 'imap',
- 'lowspace': 'drop-new',
- 'maxfilesize': '9',
- 'quarantine-quota': '10',
- 'store-blocked': 'imap',
- 'store-heuristic': 'imap',
- 'store-infected': 'imap'
- }
-
- set_method_mock.assert_called_with('antivirus', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_antivirus_quarantine_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_quarantine': {
- 'random_attribute_not_valid': 'tag',
- 'agelimit': '3',
- 'destination': 'NULL',
- 'drop_blocked': 'imap',
- 'drop_heuristic': 'imap',
- 'drop_infected': 'imap',
- 'lowspace': 'drop-new',
- 'maxfilesize': '9',
- 'quarantine_quota': '10',
- 'store_blocked': 'imap',
- 'store_heuristic': 'imap',
- 'store_infected': 'imap'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_quarantine.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'agelimit': '3',
- 'destination': 'NULL',
- 'drop-blocked': 'imap',
- 'drop-heuristic': 'imap',
- 'drop-infected': 'imap',
- 'lowspace': 'drop-new',
- 'maxfilesize': '9',
- 'quarantine-quota': '10',
- 'store-blocked': 'imap',
- 'store-heuristic': 'imap',
- 'store-infected': 'imap'
- }
-
- set_method_mock.assert_called_with('antivirus', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_antivirus_settings.py b/test/units/modules/network/fortios/test_fortios_antivirus_settings.py
deleted file mode 100644
index 7651eb98e9..0000000000
--- a/test/units/modules/network/fortios/test_fortios_antivirus_settings.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_antivirus_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_antivirus_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_antivirus_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_settings': {
- 'default_db': 'normal',
- 'grayware': 'enable',
- 'override_timeout': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_settings.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'default-db': 'normal',
- 'grayware': 'enable',
- 'override-timeout': '5'
- }
-
- set_method_mock.assert_called_with('antivirus', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_antivirus_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_settings': {
- 'default_db': 'normal',
- 'grayware': 'enable',
- 'override_timeout': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_settings.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'default-db': 'normal',
- 'grayware': 'enable',
- 'override-timeout': '5'
- }
-
- set_method_mock.assert_called_with('antivirus', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_antivirus_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_settings': {
- 'default_db': 'normal',
- 'grayware': 'enable',
- 'override_timeout': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_settings.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'default-db': 'normal',
- 'grayware': 'enable',
- 'override-timeout': '5'
- }
-
- set_method_mock.assert_called_with('antivirus', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_antivirus_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'antivirus_settings': {
- 'random_attribute_not_valid': 'tag',
- 'default_db': 'normal',
- 'grayware': 'enable',
- 'override_timeout': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_antivirus_settings.fortios_antivirus(input_data, fos_instance)
-
- expected_data = {
- 'default-db': 'normal',
- 'grayware': 'enable',
- 'override-timeout': '5'
- }
-
- set_method_mock.assert_called_with('antivirus', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_application_custom.py b/test/units/modules/network/fortios/test_fortios_application_custom.py
deleted file mode 100644
index d0d332d80a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_application_custom.py
+++ /dev/null
@@ -1,289 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_application_custom
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_application_custom.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_application_custom_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_custom': {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'comment': 'Comment.',
- 'id': '6',
- 'name': 'default_name_7',
- 'protocol': 'test_value_8',
- 'signature': 'test_value_9',
- 'tag': 'test_value_10',
- 'technology': 'test_value_11',
- 'vendor': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_custom.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'comment': 'Comment.',
- 'id': '6',
- 'name': 'default_name_7',
- 'protocol': 'test_value_8',
- 'signature': 'test_value_9',
- 'tag': 'test_value_10',
- 'technology': 'test_value_11',
- 'vendor': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('application', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_application_custom_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_custom': {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'comment': 'Comment.',
- 'id': '6',
- 'name': 'default_name_7',
- 'protocol': 'test_value_8',
- 'signature': 'test_value_9',
- 'tag': 'test_value_10',
- 'technology': 'test_value_11',
- 'vendor': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_custom.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'comment': 'Comment.',
- 'id': '6',
- 'name': 'default_name_7',
- 'protocol': 'test_value_8',
- 'signature': 'test_value_9',
- 'tag': 'test_value_10',
- 'technology': 'test_value_11',
- 'vendor': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('application', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_application_custom_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'application_custom': {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'comment': 'Comment.',
- 'id': '6',
- 'name': 'default_name_7',
- 'protocol': 'test_value_8',
- 'signature': 'test_value_9',
- 'tag': 'test_value_10',
- 'technology': 'test_value_11',
- 'vendor': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_custom.fortios_application(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('application', 'custom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_application_custom_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'application_custom': {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'comment': 'Comment.',
- 'id': '6',
- 'name': 'default_name_7',
- 'protocol': 'test_value_8',
- 'signature': 'test_value_9',
- 'tag': 'test_value_10',
- 'technology': 'test_value_11',
- 'vendor': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_custom.fortios_application(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('application', 'custom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_application_custom_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_custom': {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'comment': 'Comment.',
- 'id': '6',
- 'name': 'default_name_7',
- 'protocol': 'test_value_8',
- 'signature': 'test_value_9',
- 'tag': 'test_value_10',
- 'technology': 'test_value_11',
- 'vendor': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_custom.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'comment': 'Comment.',
- 'id': '6',
- 'name': 'default_name_7',
- 'protocol': 'test_value_8',
- 'signature': 'test_value_9',
- 'tag': 'test_value_10',
- 'technology': 'test_value_11',
- 'vendor': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('application', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_application_custom_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_custom': {
- 'random_attribute_not_valid': 'tag',
- 'behavior': 'test_value_3',
- 'category': '4',
- 'comment': 'Comment.',
- 'id': '6',
- 'name': 'default_name_7',
- 'protocol': 'test_value_8',
- 'signature': 'test_value_9',
- 'tag': 'test_value_10',
- 'technology': 'test_value_11',
- 'vendor': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_custom.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'comment': 'Comment.',
- 'id': '6',
- 'name': 'default_name_7',
- 'protocol': 'test_value_8',
- 'signature': 'test_value_9',
- 'tag': 'test_value_10',
- 'technology': 'test_value_11',
- 'vendor': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('application', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_application_group.py b/test/units/modules/network/fortios/test_fortios_application_group.py
deleted file mode 100644
index 881735cc14..0000000000
--- a/test/units/modules/network/fortios/test_fortios_application_group.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_application_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_application_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_application_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_group': {'comment': 'Comment',
- 'name': 'default_name_4',
- 'type': 'application'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_group.fortios_application(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment',
- 'name': 'default_name_4',
- 'type': 'application'
- }
-
- set_method_mock.assert_called_with('application', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_application_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_group': {'comment': 'Comment',
- 'name': 'default_name_4',
- 'type': 'application'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_group.fortios_application(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment',
- 'name': 'default_name_4',
- 'type': 'application'
- }
-
- set_method_mock.assert_called_with('application', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_application_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'application_group': {'comment': 'Comment',
- 'name': 'default_name_4',
- 'type': 'application'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_group.fortios_application(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('application', 'group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_application_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'application_group': {'comment': 'Comment',
- 'name': 'default_name_4',
- 'type': 'application'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_group.fortios_application(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('application', 'group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_application_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_group': {'comment': 'Comment',
- 'name': 'default_name_4',
- 'type': 'application'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_group.fortios_application(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment',
- 'name': 'default_name_4',
- 'type': 'application'
- }
-
- set_method_mock.assert_called_with('application', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_application_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_group': {
- 'random_attribute_not_valid': 'tag', 'comment': 'Comment',
- 'name': 'default_name_4',
- 'type': 'application'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_group.fortios_application(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment',
- 'name': 'default_name_4',
- 'type': 'application'
- }
-
- set_method_mock.assert_called_with('application', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_application_list.py b/test/units/modules/network/fortios/test_fortios_application_list.py
deleted file mode 100644
index 41810cbe21..0000000000
--- a/test/units/modules/network/fortios/test_fortios_application_list.py
+++ /dev/null
@@ -1,309 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_application_list
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_application_list.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_application_list_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_list': {
- 'app_replacemsg': 'disable',
- 'comment': 'comments',
- 'deep_app_inspection': 'disable',
- 'extended_log': 'enable',
- 'name': 'default_name_7',
- 'options': 'allow-dns',
- 'other_application_action': 'pass',
- 'other_application_log': 'disable',
- 'p2p_black_list': 'skype',
- 'replacemsg_group': 'test_value_12',
- 'unknown_application_action': 'pass',
- 'unknown_application_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_list.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'app-replacemsg': 'disable',
- 'comment': 'comments',
- 'deep-app-inspection': 'disable',
- 'extended-log': 'enable',
- 'name': 'default_name_7',
- 'options': 'allow-dns',
- 'other-application-action': 'pass',
- 'other-application-log': 'disable',
- 'p2p-black-list': 'skype',
- 'replacemsg-group': 'test_value_12',
- 'unknown-application-action': 'pass',
- 'unknown-application-log': 'disable'
- }
-
- set_method_mock.assert_called_with('application', 'list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_application_list_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_list': {
- 'app_replacemsg': 'disable',
- 'comment': 'comments',
- 'deep_app_inspection': 'disable',
- 'extended_log': 'enable',
- 'name': 'default_name_7',
- 'options': 'allow-dns',
- 'other_application_action': 'pass',
- 'other_application_log': 'disable',
- 'p2p_black_list': 'skype',
- 'replacemsg_group': 'test_value_12',
- 'unknown_application_action': 'pass',
- 'unknown_application_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_list.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'app-replacemsg': 'disable',
- 'comment': 'comments',
- 'deep-app-inspection': 'disable',
- 'extended-log': 'enable',
- 'name': 'default_name_7',
- 'options': 'allow-dns',
- 'other-application-action': 'pass',
- 'other-application-log': 'disable',
- 'p2p-black-list': 'skype',
- 'replacemsg-group': 'test_value_12',
- 'unknown-application-action': 'pass',
- 'unknown-application-log': 'disable'
- }
-
- set_method_mock.assert_called_with('application', 'list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_application_list_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'application_list': {
- 'app_replacemsg': 'disable',
- 'comment': 'comments',
- 'deep_app_inspection': 'disable',
- 'extended_log': 'enable',
- 'name': 'default_name_7',
- 'options': 'allow-dns',
- 'other_application_action': 'pass',
- 'other_application_log': 'disable',
- 'p2p_black_list': 'skype',
- 'replacemsg_group': 'test_value_12',
- 'unknown_application_action': 'pass',
- 'unknown_application_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_list.fortios_application(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('application', 'list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_application_list_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'application_list': {
- 'app_replacemsg': 'disable',
- 'comment': 'comments',
- 'deep_app_inspection': 'disable',
- 'extended_log': 'enable',
- 'name': 'default_name_7',
- 'options': 'allow-dns',
- 'other_application_action': 'pass',
- 'other_application_log': 'disable',
- 'p2p_black_list': 'skype',
- 'replacemsg_group': 'test_value_12',
- 'unknown_application_action': 'pass',
- 'unknown_application_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_list.fortios_application(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('application', 'list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_application_list_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_list': {
- 'app_replacemsg': 'disable',
- 'comment': 'comments',
- 'deep_app_inspection': 'disable',
- 'extended_log': 'enable',
- 'name': 'default_name_7',
- 'options': 'allow-dns',
- 'other_application_action': 'pass',
- 'other_application_log': 'disable',
- 'p2p_black_list': 'skype',
- 'replacemsg_group': 'test_value_12',
- 'unknown_application_action': 'pass',
- 'unknown_application_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_list.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'app-replacemsg': 'disable',
- 'comment': 'comments',
- 'deep-app-inspection': 'disable',
- 'extended-log': 'enable',
- 'name': 'default_name_7',
- 'options': 'allow-dns',
- 'other-application-action': 'pass',
- 'other-application-log': 'disable',
- 'p2p-black-list': 'skype',
- 'replacemsg-group': 'test_value_12',
- 'unknown-application-action': 'pass',
- 'unknown-application-log': 'disable'
- }
-
- set_method_mock.assert_called_with('application', 'list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_application_list_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_list': {
- 'random_attribute_not_valid': 'tag',
- 'app_replacemsg': 'disable',
- 'comment': 'comments',
- 'deep_app_inspection': 'disable',
- 'extended_log': 'enable',
- 'name': 'default_name_7',
- 'options': 'allow-dns',
- 'other_application_action': 'pass',
- 'other_application_log': 'disable',
- 'p2p_black_list': 'skype',
- 'replacemsg_group': 'test_value_12',
- 'unknown_application_action': 'pass',
- 'unknown_application_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_list.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'app-replacemsg': 'disable',
- 'comment': 'comments',
- 'deep-app-inspection': 'disable',
- 'extended-log': 'enable',
- 'name': 'default_name_7',
- 'options': 'allow-dns',
- 'other-application-action': 'pass',
- 'other-application-log': 'disable',
- 'p2p-black-list': 'skype',
- 'replacemsg-group': 'test_value_12',
- 'unknown-application-action': 'pass',
- 'unknown-application-log': 'disable'
- }
-
- set_method_mock.assert_called_with('application', 'list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_application_name.py b/test/units/modules/network/fortios/test_fortios_application_name.py
deleted file mode 100644
index 23f0e0f071..0000000000
--- a/test/units/modules/network/fortios/test_fortios_application_name.py
+++ /dev/null
@@ -1,309 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_application_name
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_application_name.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_application_name_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_name': {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'id': '5',
- 'name': 'default_name_6',
- 'parameter': 'test_value_7',
- 'popularity': '8',
- 'protocol': 'test_value_9',
- 'risk': '10',
- 'sub_category': '11',
- 'technology': 'test_value_12',
- 'vendor': 'test_value_13',
- 'weight': '14'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_name.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'id': '5',
- 'name': 'default_name_6',
- 'parameter': 'test_value_7',
- 'popularity': '8',
- 'protocol': 'test_value_9',
- 'risk': '10',
- 'sub-category': '11',
- 'technology': 'test_value_12',
- 'vendor': 'test_value_13',
- 'weight': '14'
- }
-
- set_method_mock.assert_called_with('application', 'name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_application_name_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_name': {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'id': '5',
- 'name': 'default_name_6',
- 'parameter': 'test_value_7',
- 'popularity': '8',
- 'protocol': 'test_value_9',
- 'risk': '10',
- 'sub_category': '11',
- 'technology': 'test_value_12',
- 'vendor': 'test_value_13',
- 'weight': '14'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_name.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'id': '5',
- 'name': 'default_name_6',
- 'parameter': 'test_value_7',
- 'popularity': '8',
- 'protocol': 'test_value_9',
- 'risk': '10',
- 'sub-category': '11',
- 'technology': 'test_value_12',
- 'vendor': 'test_value_13',
- 'weight': '14'
- }
-
- set_method_mock.assert_called_with('application', 'name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_application_name_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'application_name': {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'id': '5',
- 'name': 'default_name_6',
- 'parameter': 'test_value_7',
- 'popularity': '8',
- 'protocol': 'test_value_9',
- 'risk': '10',
- 'sub_category': '11',
- 'technology': 'test_value_12',
- 'vendor': 'test_value_13',
- 'weight': '14'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_name.fortios_application(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('application', 'name', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_application_name_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'application_name': {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'id': '5',
- 'name': 'default_name_6',
- 'parameter': 'test_value_7',
- 'popularity': '8',
- 'protocol': 'test_value_9',
- 'risk': '10',
- 'sub_category': '11',
- 'technology': 'test_value_12',
- 'vendor': 'test_value_13',
- 'weight': '14'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_name.fortios_application(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('application', 'name', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_application_name_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_name': {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'id': '5',
- 'name': 'default_name_6',
- 'parameter': 'test_value_7',
- 'popularity': '8',
- 'protocol': 'test_value_9',
- 'risk': '10',
- 'sub_category': '11',
- 'technology': 'test_value_12',
- 'vendor': 'test_value_13',
- 'weight': '14'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_name.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'id': '5',
- 'name': 'default_name_6',
- 'parameter': 'test_value_7',
- 'popularity': '8',
- 'protocol': 'test_value_9',
- 'risk': '10',
- 'sub-category': '11',
- 'technology': 'test_value_12',
- 'vendor': 'test_value_13',
- 'weight': '14'
- }
-
- set_method_mock.assert_called_with('application', 'name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_application_name_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_name': {
- 'random_attribute_not_valid': 'tag',
- 'behavior': 'test_value_3',
- 'category': '4',
- 'id': '5',
- 'name': 'default_name_6',
- 'parameter': 'test_value_7',
- 'popularity': '8',
- 'protocol': 'test_value_9',
- 'risk': '10',
- 'sub_category': '11',
- 'technology': 'test_value_12',
- 'vendor': 'test_value_13',
- 'weight': '14'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_name.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'behavior': 'test_value_3',
- 'category': '4',
- 'id': '5',
- 'name': 'default_name_6',
- 'parameter': 'test_value_7',
- 'popularity': '8',
- 'protocol': 'test_value_9',
- 'risk': '10',
- 'sub-category': '11',
- 'technology': 'test_value_12',
- 'vendor': 'test_value_13',
- 'weight': '14'
- }
-
- set_method_mock.assert_called_with('application', 'name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_application_rule_settings.py b/test/units/modules/network/fortios/test_fortios_application_rule_settings.py
deleted file mode 100644
index e880e8126d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_application_rule_settings.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_application_rule_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_application_rule_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_application_rule_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_rule_settings': {
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_rule_settings.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'id': '3'
- }
-
- set_method_mock.assert_called_with('application', 'rule-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_application_rule_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_rule_settings': {
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_rule_settings.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'id': '3'
- }
-
- set_method_mock.assert_called_with('application', 'rule-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_application_rule_settings_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'application_rule_settings': {
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_rule_settings.fortios_application(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('application', 'rule-settings', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_application_rule_settings_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'application_rule_settings': {
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_rule_settings.fortios_application(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('application', 'rule-settings', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_application_rule_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_rule_settings': {
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_rule_settings.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'id': '3'
- }
-
- set_method_mock.assert_called_with('application', 'rule-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_application_rule_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'application_rule_settings': {
- 'random_attribute_not_valid': 'tag',
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_application_rule_settings.fortios_application(input_data, fos_instance)
-
- expected_data = {
- 'id': '3'
- }
-
- set_method_mock.assert_called_with('application', 'rule-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_authentication_rule.py b/test/units/modules/network/fortios/test_fortios_authentication_rule.py
deleted file mode 100644
index dbca5e9a88..0000000000
--- a/test/units/modules/network/fortios/test_fortios_authentication_rule.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_authentication_rule
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_authentication_rule.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_authentication_rule_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_rule': {
- 'active_auth_method': 'test_value_3',
- 'comments': 'test_value_4',
- 'ip_based': 'enable',
- 'name': 'default_name_6',
- 'protocol': 'http',
- 'sso_auth_method': 'test_value_8',
- 'status': 'enable',
- 'transaction_based': 'enable',
- 'web_auth_cookie': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_rule.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'active-auth-method': 'test_value_3',
- 'comments': 'test_value_4',
- 'ip-based': 'enable',
- 'name': 'default_name_6',
- 'protocol': 'http',
- 'sso-auth-method': 'test_value_8',
- 'status': 'enable',
- 'transaction-based': 'enable',
- 'web-auth-cookie': 'enable'
- }
-
- set_method_mock.assert_called_with('authentication', 'rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_authentication_rule_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_rule': {
- 'active_auth_method': 'test_value_3',
- 'comments': 'test_value_4',
- 'ip_based': 'enable',
- 'name': 'default_name_6',
- 'protocol': 'http',
- 'sso_auth_method': 'test_value_8',
- 'status': 'enable',
- 'transaction_based': 'enable',
- 'web_auth_cookie': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_rule.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'active-auth-method': 'test_value_3',
- 'comments': 'test_value_4',
- 'ip-based': 'enable',
- 'name': 'default_name_6',
- 'protocol': 'http',
- 'sso-auth-method': 'test_value_8',
- 'status': 'enable',
- 'transaction-based': 'enable',
- 'web-auth-cookie': 'enable'
- }
-
- set_method_mock.assert_called_with('authentication', 'rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_authentication_rule_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'authentication_rule': {
- 'active_auth_method': 'test_value_3',
- 'comments': 'test_value_4',
- 'ip_based': 'enable',
- 'name': 'default_name_6',
- 'protocol': 'http',
- 'sso_auth_method': 'test_value_8',
- 'status': 'enable',
- 'transaction_based': 'enable',
- 'web_auth_cookie': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_rule.fortios_authentication(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('authentication', 'rule', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_authentication_rule_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'authentication_rule': {
- 'active_auth_method': 'test_value_3',
- 'comments': 'test_value_4',
- 'ip_based': 'enable',
- 'name': 'default_name_6',
- 'protocol': 'http',
- 'sso_auth_method': 'test_value_8',
- 'status': 'enable',
- 'transaction_based': 'enable',
- 'web_auth_cookie': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_rule.fortios_authentication(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('authentication', 'rule', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_authentication_rule_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_rule': {
- 'active_auth_method': 'test_value_3',
- 'comments': 'test_value_4',
- 'ip_based': 'enable',
- 'name': 'default_name_6',
- 'protocol': 'http',
- 'sso_auth_method': 'test_value_8',
- 'status': 'enable',
- 'transaction_based': 'enable',
- 'web_auth_cookie': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_rule.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'active-auth-method': 'test_value_3',
- 'comments': 'test_value_4',
- 'ip-based': 'enable',
- 'name': 'default_name_6',
- 'protocol': 'http',
- 'sso-auth-method': 'test_value_8',
- 'status': 'enable',
- 'transaction-based': 'enable',
- 'web-auth-cookie': 'enable'
- }
-
- set_method_mock.assert_called_with('authentication', 'rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_authentication_rule_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_rule': {
- 'random_attribute_not_valid': 'tag',
- 'active_auth_method': 'test_value_3',
- 'comments': 'test_value_4',
- 'ip_based': 'enable',
- 'name': 'default_name_6',
- 'protocol': 'http',
- 'sso_auth_method': 'test_value_8',
- 'status': 'enable',
- 'transaction_based': 'enable',
- 'web_auth_cookie': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_rule.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'active-auth-method': 'test_value_3',
- 'comments': 'test_value_4',
- 'ip-based': 'enable',
- 'name': 'default_name_6',
- 'protocol': 'http',
- 'sso-auth-method': 'test_value_8',
- 'status': 'enable',
- 'transaction-based': 'enable',
- 'web-auth-cookie': 'enable'
- }
-
- set_method_mock.assert_called_with('authentication', 'rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_authentication_scheme.py b/test/units/modules/network/fortios/test_fortios_authentication_scheme.py
deleted file mode 100644
index 82d2ac1546..0000000000
--- a/test/units/modules/network/fortios/test_fortios_authentication_scheme.py
+++ /dev/null
@@ -1,289 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_authentication_scheme
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_authentication_scheme.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_authentication_scheme_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_scheme': {
- 'domain_controller': 'test_value_3',
- 'fsso_agent_for_ntlm': 'test_value_4',
- 'fsso_guest': 'enable',
- 'kerberos_keytab': 'test_value_6',
- 'method': 'ntlm',
- 'name': 'default_name_8',
- 'negotiate_ntlm': 'enable',
- 'require_tfa': 'enable',
- 'ssh_ca': 'test_value_11',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_scheme.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'domain-controller': 'test_value_3',
- 'fsso-agent-for-ntlm': 'test_value_4',
- 'fsso-guest': 'enable',
- 'kerberos-keytab': 'test_value_6',
- 'method': 'ntlm',
- 'name': 'default_name_8',
- 'negotiate-ntlm': 'enable',
- 'require-tfa': 'enable',
- 'ssh-ca': 'test_value_11',
-
- }
-
- set_method_mock.assert_called_with('authentication', 'scheme', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_authentication_scheme_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_scheme': {
- 'domain_controller': 'test_value_3',
- 'fsso_agent_for_ntlm': 'test_value_4',
- 'fsso_guest': 'enable',
- 'kerberos_keytab': 'test_value_6',
- 'method': 'ntlm',
- 'name': 'default_name_8',
- 'negotiate_ntlm': 'enable',
- 'require_tfa': 'enable',
- 'ssh_ca': 'test_value_11',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_scheme.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'domain-controller': 'test_value_3',
- 'fsso-agent-for-ntlm': 'test_value_4',
- 'fsso-guest': 'enable',
- 'kerberos-keytab': 'test_value_6',
- 'method': 'ntlm',
- 'name': 'default_name_8',
- 'negotiate-ntlm': 'enable',
- 'require-tfa': 'enable',
- 'ssh-ca': 'test_value_11',
-
- }
-
- set_method_mock.assert_called_with('authentication', 'scheme', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_authentication_scheme_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'authentication_scheme': {
- 'domain_controller': 'test_value_3',
- 'fsso_agent_for_ntlm': 'test_value_4',
- 'fsso_guest': 'enable',
- 'kerberos_keytab': 'test_value_6',
- 'method': 'ntlm',
- 'name': 'default_name_8',
- 'negotiate_ntlm': 'enable',
- 'require_tfa': 'enable',
- 'ssh_ca': 'test_value_11',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_scheme.fortios_authentication(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('authentication', 'scheme', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_authentication_scheme_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'authentication_scheme': {
- 'domain_controller': 'test_value_3',
- 'fsso_agent_for_ntlm': 'test_value_4',
- 'fsso_guest': 'enable',
- 'kerberos_keytab': 'test_value_6',
- 'method': 'ntlm',
- 'name': 'default_name_8',
- 'negotiate_ntlm': 'enable',
- 'require_tfa': 'enable',
- 'ssh_ca': 'test_value_11',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_scheme.fortios_authentication(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('authentication', 'scheme', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_authentication_scheme_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_scheme': {
- 'domain_controller': 'test_value_3',
- 'fsso_agent_for_ntlm': 'test_value_4',
- 'fsso_guest': 'enable',
- 'kerberos_keytab': 'test_value_6',
- 'method': 'ntlm',
- 'name': 'default_name_8',
- 'negotiate_ntlm': 'enable',
- 'require_tfa': 'enable',
- 'ssh_ca': 'test_value_11',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_scheme.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'domain-controller': 'test_value_3',
- 'fsso-agent-for-ntlm': 'test_value_4',
- 'fsso-guest': 'enable',
- 'kerberos-keytab': 'test_value_6',
- 'method': 'ntlm',
- 'name': 'default_name_8',
- 'negotiate-ntlm': 'enable',
- 'require-tfa': 'enable',
- 'ssh-ca': 'test_value_11',
-
- }
-
- set_method_mock.assert_called_with('authentication', 'scheme', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_authentication_scheme_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_scheme': {
- 'random_attribute_not_valid': 'tag',
- 'domain_controller': 'test_value_3',
- 'fsso_agent_for_ntlm': 'test_value_4',
- 'fsso_guest': 'enable',
- 'kerberos_keytab': 'test_value_6',
- 'method': 'ntlm',
- 'name': 'default_name_8',
- 'negotiate_ntlm': 'enable',
- 'require_tfa': 'enable',
- 'ssh_ca': 'test_value_11',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_scheme.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'domain-controller': 'test_value_3',
- 'fsso-agent-for-ntlm': 'test_value_4',
- 'fsso-guest': 'enable',
- 'kerberos-keytab': 'test_value_6',
- 'method': 'ntlm',
- 'name': 'default_name_8',
- 'negotiate-ntlm': 'enable',
- 'require-tfa': 'enable',
- 'ssh-ca': 'test_value_11',
-
- }
-
- set_method_mock.assert_called_with('authentication', 'scheme', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_authentication_setting.py b/test/units/modules/network/fortios/test_fortios_authentication_setting.py
deleted file mode 100644
index 36b6fd98ef..0000000000
--- a/test/units/modules/network/fortios/test_fortios_authentication_setting.py
+++ /dev/null
@@ -1,207 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_authentication_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_authentication_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_authentication_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_setting': {
- 'active_auth_scheme': 'test_value_3',
- 'captive_portal': 'test_value_4',
- 'captive_portal_ip': 'test_value_5',
- 'captive_portal_ip6': 'test_value_6',
- 'captive_portal_port': '7',
- 'captive_portal_type': 'fqdn',
- 'captive_portal6': 'test_value_9',
- 'sso_auth_scheme': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_setting.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'active-auth-scheme': 'test_value_3',
- 'captive-portal': 'test_value_4',
- 'captive-portal-ip': 'test_value_5',
- 'captive-portal-ip6': 'test_value_6',
- 'captive-portal-port': '7',
- 'captive-portal-type': 'fqdn',
- 'captive-portal6': 'test_value_9',
- 'sso-auth-scheme': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('authentication', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_authentication_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_setting': {
- 'active_auth_scheme': 'test_value_3',
- 'captive_portal': 'test_value_4',
- 'captive_portal_ip': 'test_value_5',
- 'captive_portal_ip6': 'test_value_6',
- 'captive_portal_port': '7',
- 'captive_portal_type': 'fqdn',
- 'captive_portal6': 'test_value_9',
- 'sso_auth_scheme': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_setting.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'active-auth-scheme': 'test_value_3',
- 'captive-portal': 'test_value_4',
- 'captive-portal-ip': 'test_value_5',
- 'captive-portal-ip6': 'test_value_6',
- 'captive-portal-port': '7',
- 'captive-portal-type': 'fqdn',
- 'captive-portal6': 'test_value_9',
- 'sso-auth-scheme': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('authentication', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_authentication_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_setting': {
- 'active_auth_scheme': 'test_value_3',
- 'captive_portal': 'test_value_4',
- 'captive_portal_ip': 'test_value_5',
- 'captive_portal_ip6': 'test_value_6',
- 'captive_portal_port': '7',
- 'captive_portal_type': 'fqdn',
- 'captive_portal6': 'test_value_9',
- 'sso_auth_scheme': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_setting.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'active-auth-scheme': 'test_value_3',
- 'captive-portal': 'test_value_4',
- 'captive-portal-ip': 'test_value_5',
- 'captive-portal-ip6': 'test_value_6',
- 'captive-portal-port': '7',
- 'captive-portal-type': 'fqdn',
- 'captive-portal6': 'test_value_9',
- 'sso-auth-scheme': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('authentication', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_authentication_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'authentication_setting': {
- 'random_attribute_not_valid': 'tag',
- 'active_auth_scheme': 'test_value_3',
- 'captive_portal': 'test_value_4',
- 'captive_portal_ip': 'test_value_5',
- 'captive_portal_ip6': 'test_value_6',
- 'captive_portal_port': '7',
- 'captive_portal_type': 'fqdn',
- 'captive_portal6': 'test_value_9',
- 'sso_auth_scheme': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_authentication_setting.fortios_authentication(input_data, fos_instance)
-
- expected_data = {
- 'active-auth-scheme': 'test_value_3',
- 'captive-portal': 'test_value_4',
- 'captive-portal-ip': 'test_value_5',
- 'captive-portal-ip6': 'test_value_6',
- 'captive-portal-port': '7',
- 'captive-portal-type': 'fqdn',
- 'captive-portal6': 'test_value_9',
- 'sso-auth-scheme': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('authentication', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_dlp_filepattern.py b/test/units/modules/network/fortios/test_fortios_dlp_filepattern.py
deleted file mode 100644
index 44f728eae4..0000000000
--- a/test/units/modules/network/fortios/test_fortios_dlp_filepattern.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_dlp_filepattern
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_dlp_filepattern.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_dlp_filepattern_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_filepattern': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_filepattern.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('dlp', 'filepattern', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dlp_filepattern_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_filepattern': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_filepattern.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('dlp', 'filepattern', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dlp_filepattern_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dlp_filepattern': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_filepattern.fortios_dlp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dlp', 'filepattern', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dlp_filepattern_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dlp_filepattern': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_filepattern.fortios_dlp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dlp', 'filepattern', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dlp_filepattern_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_filepattern': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_filepattern.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('dlp', 'filepattern', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_dlp_filepattern_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_filepattern': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_filepattern.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('dlp', 'filepattern', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_dlp_fp_doc_source.py b/test/units/modules/network/fortios/test_fortios_dlp_fp_doc_source.py
deleted file mode 100644
index 07e79ac364..0000000000
--- a/test/units/modules/network/fortios/test_fortios_dlp_fp_doc_source.py
+++ /dev/null
@@ -1,369 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_dlp_fp_doc_source
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_dlp_fp_doc_source.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_dlp_fp_doc_source_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_fp_doc_source': {
- 'date': '3',
- 'file_path': 'test_value_4',
- 'file_pattern': 'test_value_5',
- 'keep_modified': 'enable',
- 'name': 'default_name_7',
- 'password': 'test_value_8',
- 'period': 'none',
- 'remove_deleted': 'enable',
- 'scan_on_creation': 'enable',
- 'scan_subdirectories': 'enable',
- 'sensitivity': 'test_value_13',
- 'server': '192.168.100.14',
- 'server_type': 'samba',
- 'tod_hour': '16',
- 'tod_min': '17',
- 'username': 'test_value_18',
- 'vdom': 'mgmt',
- 'weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_doc_source.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'date': '3',
- 'file-path': 'test_value_4',
- 'file-pattern': 'test_value_5',
- 'keep-modified': 'enable',
- 'name': 'default_name_7',
- 'password': 'test_value_8',
- 'period': 'none',
- 'remove-deleted': 'enable',
- 'scan-on-creation': 'enable',
- 'scan-subdirectories': 'enable',
- 'sensitivity': 'test_value_13',
- 'server': '192.168.100.14',
- 'server-type': 'samba',
- 'tod-hour': '16',
- 'tod-min': '17',
- 'username': 'test_value_18',
- 'vdom': 'mgmt',
- 'weekday': 'sunday'
- }
-
- set_method_mock.assert_called_with('dlp', 'fp-doc-source', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dlp_fp_doc_source_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_fp_doc_source': {
- 'date': '3',
- 'file_path': 'test_value_4',
- 'file_pattern': 'test_value_5',
- 'keep_modified': 'enable',
- 'name': 'default_name_7',
- 'password': 'test_value_8',
- 'period': 'none',
- 'remove_deleted': 'enable',
- 'scan_on_creation': 'enable',
- 'scan_subdirectories': 'enable',
- 'sensitivity': 'test_value_13',
- 'server': '192.168.100.14',
- 'server_type': 'samba',
- 'tod_hour': '16',
- 'tod_min': '17',
- 'username': 'test_value_18',
- 'vdom': 'mgmt',
- 'weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_doc_source.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'date': '3',
- 'file-path': 'test_value_4',
- 'file-pattern': 'test_value_5',
- 'keep-modified': 'enable',
- 'name': 'default_name_7',
- 'password': 'test_value_8',
- 'period': 'none',
- 'remove-deleted': 'enable',
- 'scan-on-creation': 'enable',
- 'scan-subdirectories': 'enable',
- 'sensitivity': 'test_value_13',
- 'server': '192.168.100.14',
- 'server-type': 'samba',
- 'tod-hour': '16',
- 'tod-min': '17',
- 'username': 'test_value_18',
- 'vdom': 'mgmt',
- 'weekday': 'sunday'
- }
-
- set_method_mock.assert_called_with('dlp', 'fp-doc-source', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dlp_fp_doc_source_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dlp_fp_doc_source': {
- 'date': '3',
- 'file_path': 'test_value_4',
- 'file_pattern': 'test_value_5',
- 'keep_modified': 'enable',
- 'name': 'default_name_7',
- 'password': 'test_value_8',
- 'period': 'none',
- 'remove_deleted': 'enable',
- 'scan_on_creation': 'enable',
- 'scan_subdirectories': 'enable',
- 'sensitivity': 'test_value_13',
- 'server': '192.168.100.14',
- 'server_type': 'samba',
- 'tod_hour': '16',
- 'tod_min': '17',
- 'username': 'test_value_18',
- 'vdom': 'mgmt',
- 'weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_doc_source.fortios_dlp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dlp', 'fp-doc-source', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dlp_fp_doc_source_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dlp_fp_doc_source': {
- 'date': '3',
- 'file_path': 'test_value_4',
- 'file_pattern': 'test_value_5',
- 'keep_modified': 'enable',
- 'name': 'default_name_7',
- 'password': 'test_value_8',
- 'period': 'none',
- 'remove_deleted': 'enable',
- 'scan_on_creation': 'enable',
- 'scan_subdirectories': 'enable',
- 'sensitivity': 'test_value_13',
- 'server': '192.168.100.14',
- 'server_type': 'samba',
- 'tod_hour': '16',
- 'tod_min': '17',
- 'username': 'test_value_18',
- 'vdom': 'mgmt',
- 'weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_doc_source.fortios_dlp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dlp', 'fp-doc-source', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dlp_fp_doc_source_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_fp_doc_source': {
- 'date': '3',
- 'file_path': 'test_value_4',
- 'file_pattern': 'test_value_5',
- 'keep_modified': 'enable',
- 'name': 'default_name_7',
- 'password': 'test_value_8',
- 'period': 'none',
- 'remove_deleted': 'enable',
- 'scan_on_creation': 'enable',
- 'scan_subdirectories': 'enable',
- 'sensitivity': 'test_value_13',
- 'server': '192.168.100.14',
- 'server_type': 'samba',
- 'tod_hour': '16',
- 'tod_min': '17',
- 'username': 'test_value_18',
- 'vdom': 'mgmt',
- 'weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_doc_source.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'date': '3',
- 'file-path': 'test_value_4',
- 'file-pattern': 'test_value_5',
- 'keep-modified': 'enable',
- 'name': 'default_name_7',
- 'password': 'test_value_8',
- 'period': 'none',
- 'remove-deleted': 'enable',
- 'scan-on-creation': 'enable',
- 'scan-subdirectories': 'enable',
- 'sensitivity': 'test_value_13',
- 'server': '192.168.100.14',
- 'server-type': 'samba',
- 'tod-hour': '16',
- 'tod-min': '17',
- 'username': 'test_value_18',
- 'vdom': 'mgmt',
- 'weekday': 'sunday'
- }
-
- set_method_mock.assert_called_with('dlp', 'fp-doc-source', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_dlp_fp_doc_source_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_fp_doc_source': {
- 'random_attribute_not_valid': 'tag',
- 'date': '3',
- 'file_path': 'test_value_4',
- 'file_pattern': 'test_value_5',
- 'keep_modified': 'enable',
- 'name': 'default_name_7',
- 'password': 'test_value_8',
- 'period': 'none',
- 'remove_deleted': 'enable',
- 'scan_on_creation': 'enable',
- 'scan_subdirectories': 'enable',
- 'sensitivity': 'test_value_13',
- 'server': '192.168.100.14',
- 'server_type': 'samba',
- 'tod_hour': '16',
- 'tod_min': '17',
- 'username': 'test_value_18',
- 'vdom': 'mgmt',
- 'weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_doc_source.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'date': '3',
- 'file-path': 'test_value_4',
- 'file-pattern': 'test_value_5',
- 'keep-modified': 'enable',
- 'name': 'default_name_7',
- 'password': 'test_value_8',
- 'period': 'none',
- 'remove-deleted': 'enable',
- 'scan-on-creation': 'enable',
- 'scan-subdirectories': 'enable',
- 'sensitivity': 'test_value_13',
- 'server': '192.168.100.14',
- 'server-type': 'samba',
- 'tod-hour': '16',
- 'tod-min': '17',
- 'username': 'test_value_18',
- 'vdom': 'mgmt',
- 'weekday': 'sunday'
- }
-
- set_method_mock.assert_called_with('dlp', 'fp-doc-source', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_dlp_fp_sensitivity.py b/test/units/modules/network/fortios/test_fortios_dlp_fp_sensitivity.py
deleted file mode 100644
index 132f51281a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_dlp_fp_sensitivity.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_dlp_fp_sensitivity
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_dlp_fp_sensitivity.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_dlp_fp_sensitivity_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_fp_sensitivity': {
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_sensitivity.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('dlp', 'fp-sensitivity', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dlp_fp_sensitivity_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_fp_sensitivity': {
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_sensitivity.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('dlp', 'fp-sensitivity', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dlp_fp_sensitivity_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dlp_fp_sensitivity': {
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_sensitivity.fortios_dlp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dlp', 'fp-sensitivity', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dlp_fp_sensitivity_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dlp_fp_sensitivity': {
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_sensitivity.fortios_dlp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dlp', 'fp-sensitivity', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dlp_fp_sensitivity_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_fp_sensitivity': {
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_sensitivity.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('dlp', 'fp-sensitivity', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_dlp_fp_sensitivity_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_fp_sensitivity': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_fp_sensitivity.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('dlp', 'fp-sensitivity', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_dlp_sensor.py b/test/units/modules/network/fortios/test_fortios_dlp_sensor.py
deleted file mode 100644
index 91dc19373d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_dlp_sensor.py
+++ /dev/null
@@ -1,289 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_dlp_sensor
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_dlp_sensor.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_dlp_sensor_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_sensor': {
- 'comment': 'Comment.',
- 'dlp_log': 'enable',
- 'extended_log': 'enable',
- 'flow_based': 'enable',
- 'full_archive_proto': 'smtp',
- 'nac_quar_log': 'enable',
- 'name': 'default_name_9',
- 'options': 'test_value_10,',
- 'replacemsg_group': 'test_value_11',
- 'summary_proto': 'smtp'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_sensor.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'dlp-log': 'enable',
- 'extended-log': 'enable',
- 'flow-based': 'enable',
- 'full-archive-proto': 'smtp',
- 'nac-quar-log': 'enable',
- 'name': 'default_name_9',
- 'options': 'test_value_10,',
- 'replacemsg-group': 'test_value_11',
- 'summary-proto': 'smtp'
- }
-
- set_method_mock.assert_called_with('dlp', 'sensor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dlp_sensor_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_sensor': {
- 'comment': 'Comment.',
- 'dlp_log': 'enable',
- 'extended_log': 'enable',
- 'flow_based': 'enable',
- 'full_archive_proto': 'smtp',
- 'nac_quar_log': 'enable',
- 'name': 'default_name_9',
- 'options': 'test_value_10,',
- 'replacemsg_group': 'test_value_11',
- 'summary_proto': 'smtp'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_sensor.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'dlp-log': 'enable',
- 'extended-log': 'enable',
- 'flow-based': 'enable',
- 'full-archive-proto': 'smtp',
- 'nac-quar-log': 'enable',
- 'name': 'default_name_9',
- 'options': 'test_value_10,',
- 'replacemsg-group': 'test_value_11',
- 'summary-proto': 'smtp'
- }
-
- set_method_mock.assert_called_with('dlp', 'sensor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dlp_sensor_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dlp_sensor': {
- 'comment': 'Comment.',
- 'dlp_log': 'enable',
- 'extended_log': 'enable',
- 'flow_based': 'enable',
- 'full_archive_proto': 'smtp',
- 'nac_quar_log': 'enable',
- 'name': 'default_name_9',
- 'options': 'test_value_10,',
- 'replacemsg_group': 'test_value_11',
- 'summary_proto': 'smtp'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_sensor.fortios_dlp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dlp', 'sensor', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dlp_sensor_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dlp_sensor': {
- 'comment': 'Comment.',
- 'dlp_log': 'enable',
- 'extended_log': 'enable',
- 'flow_based': 'enable',
- 'full_archive_proto': 'smtp',
- 'nac_quar_log': 'enable',
- 'name': 'default_name_9',
- 'options': 'test_value_10,',
- 'replacemsg_group': 'test_value_11',
- 'summary_proto': 'smtp'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_sensor.fortios_dlp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dlp', 'sensor', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dlp_sensor_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_sensor': {
- 'comment': 'Comment.',
- 'dlp_log': 'enable',
- 'extended_log': 'enable',
- 'flow_based': 'enable',
- 'full_archive_proto': 'smtp',
- 'nac_quar_log': 'enable',
- 'name': 'default_name_9',
- 'options': 'test_value_10,',
- 'replacemsg_group': 'test_value_11',
- 'summary_proto': 'smtp'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_sensor.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'dlp-log': 'enable',
- 'extended-log': 'enable',
- 'flow-based': 'enable',
- 'full-archive-proto': 'smtp',
- 'nac-quar-log': 'enable',
- 'name': 'default_name_9',
- 'options': 'test_value_10,',
- 'replacemsg-group': 'test_value_11',
- 'summary-proto': 'smtp'
- }
-
- set_method_mock.assert_called_with('dlp', 'sensor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_dlp_sensor_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_sensor': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'dlp_log': 'enable',
- 'extended_log': 'enable',
- 'flow_based': 'enable',
- 'full_archive_proto': 'smtp',
- 'nac_quar_log': 'enable',
- 'name': 'default_name_9',
- 'options': 'test_value_10,',
- 'replacemsg_group': 'test_value_11',
- 'summary_proto': 'smtp'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_sensor.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'dlp-log': 'enable',
- 'extended-log': 'enable',
- 'flow-based': 'enable',
- 'full-archive-proto': 'smtp',
- 'nac-quar-log': 'enable',
- 'name': 'default_name_9',
- 'options': 'test_value_10,',
- 'replacemsg-group': 'test_value_11',
- 'summary-proto': 'smtp'
- }
-
- set_method_mock.assert_called_with('dlp', 'sensor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_dlp_settings.py b/test/units/modules/network/fortios/test_fortios_dlp_settings.py
deleted file mode 100644
index 5e0f79e83b..0000000000
--- a/test/units/modules/network/fortios/test_fortios_dlp_settings.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_dlp_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_dlp_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_dlp_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_settings': {
- 'cache_mem_percent': '3',
- 'chunk_size': '4',
- 'db_mode': 'stop-adding',
- 'size': '6',
- 'storage_device': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_settings.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'cache-mem-percent': '3',
- 'chunk-size': '4',
- 'db-mode': 'stop-adding',
- 'size': '6',
- 'storage-device': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('dlp', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dlp_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_settings': {
- 'cache_mem_percent': '3',
- 'chunk_size': '4',
- 'db_mode': 'stop-adding',
- 'size': '6',
- 'storage_device': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_settings.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'cache-mem-percent': '3',
- 'chunk-size': '4',
- 'db-mode': 'stop-adding',
- 'size': '6',
- 'storage-device': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('dlp', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dlp_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_settings': {
- 'cache_mem_percent': '3',
- 'chunk_size': '4',
- 'db_mode': 'stop-adding',
- 'size': '6',
- 'storage_device': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_settings.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'cache-mem-percent': '3',
- 'chunk-size': '4',
- 'db-mode': 'stop-adding',
- 'size': '6',
- 'storage-device': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('dlp', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_dlp_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dlp_settings': {
- 'random_attribute_not_valid': 'tag',
- 'cache_mem_percent': '3',
- 'chunk_size': '4',
- 'db_mode': 'stop-adding',
- 'size': '6',
- 'storage_device': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dlp_settings.fortios_dlp(input_data, fos_instance)
-
- expected_data = {
- 'cache-mem-percent': '3',
- 'chunk-size': '4',
- 'db-mode': 'stop-adding',
- 'size': '6',
- 'storage-device': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('dlp', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_dnsfilter_domain_filter.py b/test/units/modules/network/fortios/test_fortios_dnsfilter_domain_filter.py
deleted file mode 100644
index 2424e3b84b..0000000000
--- a/test/units/modules/network/fortios/test_fortios_dnsfilter_domain_filter.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_dnsfilter_domain_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_dnsfilter_domain_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_dnsfilter_domain_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dnsfilter_domain_filter': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_domain_filter.fortios_dnsfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('dnsfilter', 'domain-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dnsfilter_domain_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dnsfilter_domain_filter': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_domain_filter.fortios_dnsfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('dnsfilter', 'domain-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dnsfilter_domain_filter_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dnsfilter_domain_filter': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_domain_filter.fortios_dnsfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dnsfilter', 'domain-filter', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dnsfilter_domain_filter_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dnsfilter_domain_filter': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_domain_filter.fortios_dnsfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dnsfilter', 'domain-filter', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dnsfilter_domain_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dnsfilter_domain_filter': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_domain_filter.fortios_dnsfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('dnsfilter', 'domain-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_dnsfilter_domain_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dnsfilter_domain_filter': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_domain_filter.fortios_dnsfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('dnsfilter', 'domain-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_dnsfilter_profile.py b/test/units/modules/network/fortios/test_fortios_dnsfilter_profile.py
deleted file mode 100644
index ef536a674c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_dnsfilter_profile.py
+++ /dev/null
@@ -1,289 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_dnsfilter_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_dnsfilter_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_dnsfilter_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dnsfilter_profile': {
- 'block_action': 'block',
- 'block_botnet': 'disable',
- 'comment': 'Comment.',
- 'log_all_domain': 'enable',
- 'name': 'default_name_7',
- 'redirect_portal': 'test_value_8',
- 'safe_search': 'disable',
- 'sdns_domain_log': 'enable',
- 'sdns_ftgd_err_log': 'enable',
- 'youtube_restrict': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_profile.fortios_dnsfilter(input_data, fos_instance)
-
- expected_data = {
- 'block-action': 'block',
- 'block-botnet': 'disable',
- 'comment': 'Comment.',
- 'log-all-domain': 'enable',
- 'name': 'default_name_7',
- 'redirect-portal': 'test_value_8',
- 'safe-search': 'disable',
- 'sdns-domain-log': 'enable',
- 'sdns-ftgd-err-log': 'enable',
- 'youtube-restrict': 'strict'
- }
-
- set_method_mock.assert_called_with('dnsfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dnsfilter_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dnsfilter_profile': {
- 'block_action': 'block',
- 'block_botnet': 'disable',
- 'comment': 'Comment.',
- 'log_all_domain': 'enable',
- 'name': 'default_name_7',
- 'redirect_portal': 'test_value_8',
- 'safe_search': 'disable',
- 'sdns_domain_log': 'enable',
- 'sdns_ftgd_err_log': 'enable',
- 'youtube_restrict': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_profile.fortios_dnsfilter(input_data, fos_instance)
-
- expected_data = {
- 'block-action': 'block',
- 'block-botnet': 'disable',
- 'comment': 'Comment.',
- 'log-all-domain': 'enable',
- 'name': 'default_name_7',
- 'redirect-portal': 'test_value_8',
- 'safe-search': 'disable',
- 'sdns-domain-log': 'enable',
- 'sdns-ftgd-err-log': 'enable',
- 'youtube-restrict': 'strict'
- }
-
- set_method_mock.assert_called_with('dnsfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dnsfilter_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dnsfilter_profile': {
- 'block_action': 'block',
- 'block_botnet': 'disable',
- 'comment': 'Comment.',
- 'log_all_domain': 'enable',
- 'name': 'default_name_7',
- 'redirect_portal': 'test_value_8',
- 'safe_search': 'disable',
- 'sdns_domain_log': 'enable',
- 'sdns_ftgd_err_log': 'enable',
- 'youtube_restrict': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_profile.fortios_dnsfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dnsfilter', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_dnsfilter_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'dnsfilter_profile': {
- 'block_action': 'block',
- 'block_botnet': 'disable',
- 'comment': 'Comment.',
- 'log_all_domain': 'enable',
- 'name': 'default_name_7',
- 'redirect_portal': 'test_value_8',
- 'safe_search': 'disable',
- 'sdns_domain_log': 'enable',
- 'sdns_ftgd_err_log': 'enable',
- 'youtube_restrict': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_profile.fortios_dnsfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('dnsfilter', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_dnsfilter_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dnsfilter_profile': {
- 'block_action': 'block',
- 'block_botnet': 'disable',
- 'comment': 'Comment.',
- 'log_all_domain': 'enable',
- 'name': 'default_name_7',
- 'redirect_portal': 'test_value_8',
- 'safe_search': 'disable',
- 'sdns_domain_log': 'enable',
- 'sdns_ftgd_err_log': 'enable',
- 'youtube_restrict': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_profile.fortios_dnsfilter(input_data, fos_instance)
-
- expected_data = {
- 'block-action': 'block',
- 'block-botnet': 'disable',
- 'comment': 'Comment.',
- 'log-all-domain': 'enable',
- 'name': 'default_name_7',
- 'redirect-portal': 'test_value_8',
- 'safe-search': 'disable',
- 'sdns-domain-log': 'enable',
- 'sdns-ftgd-err-log': 'enable',
- 'youtube-restrict': 'strict'
- }
-
- set_method_mock.assert_called_with('dnsfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_dnsfilter_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'dnsfilter_profile': {
- 'random_attribute_not_valid': 'tag',
- 'block_action': 'block',
- 'block_botnet': 'disable',
- 'comment': 'Comment.',
- 'log_all_domain': 'enable',
- 'name': 'default_name_7',
- 'redirect_portal': 'test_value_8',
- 'safe_search': 'disable',
- 'sdns_domain_log': 'enable',
- 'sdns_ftgd_err_log': 'enable',
- 'youtube_restrict': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_dnsfilter_profile.fortios_dnsfilter(input_data, fos_instance)
-
- expected_data = {
- 'block-action': 'block',
- 'block-botnet': 'disable',
- 'comment': 'Comment.',
- 'log-all-domain': 'enable',
- 'name': 'default_name_7',
- 'redirect-portal': 'test_value_8',
- 'safe-search': 'disable',
- 'sdns-domain-log': 'enable',
- 'sdns-ftgd-err-log': 'enable',
- 'youtube-restrict': 'strict'
- }
-
- set_method_mock.assert_called_with('dnsfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_endpoint_control_client.py b/test/units/modules/network/fortios/test_fortios_endpoint_control_client.py
deleted file mode 100644
index d67f85c039..0000000000
--- a/test/units/modules/network/fortios/test_fortios_endpoint_control_client.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_endpoint_control_client
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_endpoint_control_client.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_endpoint_control_client_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_client': {
- 'ad_groups': 'test_value_3',
- 'ftcl_uid': 'test_value_4',
- 'id': '5',
- 'info': 'test_value_6',
- 'src_ip': 'test_value_7',
- 'src_mac': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_client.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'ad-groups': 'test_value_3',
- 'ftcl-uid': 'test_value_4',
- 'id': '5',
- 'info': 'test_value_6',
- 'src-ip': 'test_value_7',
- 'src-mac': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'client', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_endpoint_control_client_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_client': {
- 'ad_groups': 'test_value_3',
- 'ftcl_uid': 'test_value_4',
- 'id': '5',
- 'info': 'test_value_6',
- 'src_ip': 'test_value_7',
- 'src_mac': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_client.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'ad-groups': 'test_value_3',
- 'ftcl-uid': 'test_value_4',
- 'id': '5',
- 'info': 'test_value_6',
- 'src-ip': 'test_value_7',
- 'src-mac': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'client', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_endpoint_control_client_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'endpoint_control_client': {
- 'ad_groups': 'test_value_3',
- 'ftcl_uid': 'test_value_4',
- 'id': '5',
- 'info': 'test_value_6',
- 'src_ip': 'test_value_7',
- 'src_mac': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_client.fortios_endpoint_control(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('endpoint-control', 'client', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_endpoint_control_client_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'endpoint_control_client': {
- 'ad_groups': 'test_value_3',
- 'ftcl_uid': 'test_value_4',
- 'id': '5',
- 'info': 'test_value_6',
- 'src_ip': 'test_value_7',
- 'src_mac': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_client.fortios_endpoint_control(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('endpoint-control', 'client', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_endpoint_control_client_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_client': {
- 'ad_groups': 'test_value_3',
- 'ftcl_uid': 'test_value_4',
- 'id': '5',
- 'info': 'test_value_6',
- 'src_ip': 'test_value_7',
- 'src_mac': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_client.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'ad-groups': 'test_value_3',
- 'ftcl-uid': 'test_value_4',
- 'id': '5',
- 'info': 'test_value_6',
- 'src-ip': 'test_value_7',
- 'src-mac': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'client', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_endpoint_control_client_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_client': {
- 'random_attribute_not_valid': 'tag',
- 'ad_groups': 'test_value_3',
- 'ftcl_uid': 'test_value_4',
- 'id': '5',
- 'info': 'test_value_6',
- 'src_ip': 'test_value_7',
- 'src_mac': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_client.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'ad-groups': 'test_value_3',
- 'ftcl-uid': 'test_value_4',
- 'id': '5',
- 'info': 'test_value_6',
- 'src-ip': 'test_value_7',
- 'src-mac': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'client', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_endpoint_control_forticlient_ems.py b/test/units/modules/network/fortios/test_fortios_endpoint_control_forticlient_ems.py
deleted file mode 100644
index 2328910dec..0000000000
--- a/test/units/modules/network/fortios/test_fortios_endpoint_control_forticlient_ems.py
+++ /dev/null
@@ -1,289 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_endpoint_control_forticlient_ems
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_endpoint_control_forticlient_ems.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_endpoint_control_forticlient_ems_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_forticlient_ems': {
- 'address': 'test_value_3',
- 'admin_password': 'test_value_4',
- 'admin_type': 'Windows',
- 'admin_username': 'test_value_6',
- 'https_port': '7',
- 'listen_port': '8',
- 'name': 'default_name_9',
- 'rest_api_auth': 'disable',
- 'serial_number': 'test_value_11',
- 'upload_port': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_ems.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'admin-password': 'test_value_4',
- 'admin-type': 'Windows',
- 'admin-username': 'test_value_6',
- 'https-port': '7',
- 'listen-port': '8',
- 'name': 'default_name_9',
- 'rest-api-auth': 'disable',
- 'serial-number': 'test_value_11',
- 'upload-port': '12'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'forticlient-ems', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_endpoint_control_forticlient_ems_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_forticlient_ems': {
- 'address': 'test_value_3',
- 'admin_password': 'test_value_4',
- 'admin_type': 'Windows',
- 'admin_username': 'test_value_6',
- 'https_port': '7',
- 'listen_port': '8',
- 'name': 'default_name_9',
- 'rest_api_auth': 'disable',
- 'serial_number': 'test_value_11',
- 'upload_port': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_ems.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'admin-password': 'test_value_4',
- 'admin-type': 'Windows',
- 'admin-username': 'test_value_6',
- 'https-port': '7',
- 'listen-port': '8',
- 'name': 'default_name_9',
- 'rest-api-auth': 'disable',
- 'serial-number': 'test_value_11',
- 'upload-port': '12'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'forticlient-ems', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_endpoint_control_forticlient_ems_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'endpoint_control_forticlient_ems': {
- 'address': 'test_value_3',
- 'admin_password': 'test_value_4',
- 'admin_type': 'Windows',
- 'admin_username': 'test_value_6',
- 'https_port': '7',
- 'listen_port': '8',
- 'name': 'default_name_9',
- 'rest_api_auth': 'disable',
- 'serial_number': 'test_value_11',
- 'upload_port': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_ems.fortios_endpoint_control(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('endpoint-control', 'forticlient-ems', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_endpoint_control_forticlient_ems_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'endpoint_control_forticlient_ems': {
- 'address': 'test_value_3',
- 'admin_password': 'test_value_4',
- 'admin_type': 'Windows',
- 'admin_username': 'test_value_6',
- 'https_port': '7',
- 'listen_port': '8',
- 'name': 'default_name_9',
- 'rest_api_auth': 'disable',
- 'serial_number': 'test_value_11',
- 'upload_port': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_ems.fortios_endpoint_control(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('endpoint-control', 'forticlient-ems', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_endpoint_control_forticlient_ems_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_forticlient_ems': {
- 'address': 'test_value_3',
- 'admin_password': 'test_value_4',
- 'admin_type': 'Windows',
- 'admin_username': 'test_value_6',
- 'https_port': '7',
- 'listen_port': '8',
- 'name': 'default_name_9',
- 'rest_api_auth': 'disable',
- 'serial_number': 'test_value_11',
- 'upload_port': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_ems.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'admin-password': 'test_value_4',
- 'admin-type': 'Windows',
- 'admin-username': 'test_value_6',
- 'https-port': '7',
- 'listen-port': '8',
- 'name': 'default_name_9',
- 'rest-api-auth': 'disable',
- 'serial-number': 'test_value_11',
- 'upload-port': '12'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'forticlient-ems', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_endpoint_control_forticlient_ems_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_forticlient_ems': {
- 'random_attribute_not_valid': 'tag',
- 'address': 'test_value_3',
- 'admin_password': 'test_value_4',
- 'admin_type': 'Windows',
- 'admin_username': 'test_value_6',
- 'https_port': '7',
- 'listen_port': '8',
- 'name': 'default_name_9',
- 'rest_api_auth': 'disable',
- 'serial_number': 'test_value_11',
- 'upload_port': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_ems.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'admin-password': 'test_value_4',
- 'admin-type': 'Windows',
- 'admin-username': 'test_value_6',
- 'https-port': '7',
- 'listen-port': '8',
- 'name': 'default_name_9',
- 'rest-api-auth': 'disable',
- 'serial-number': 'test_value_11',
- 'upload-port': '12'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'forticlient-ems', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_endpoint_control_forticlient_registration_sync.py b/test/units/modules/network/fortios/test_fortios_endpoint_control_forticlient_registration_sync.py
deleted file mode 100644
index 571f845462..0000000000
--- a/test/units/modules/network/fortios/test_fortios_endpoint_control_forticlient_registration_sync.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_endpoint_control_forticlient_registration_sync
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_endpoint_control_forticlient_registration_sync.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_endpoint_control_forticlient_registration_sync_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_forticlient_registration_sync': {
- 'peer_ip': 'test_value_3',
- 'peer_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_registration_sync.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'peer-ip': 'test_value_3',
- 'peer-name': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'forticlient-registration-sync', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_endpoint_control_forticlient_registration_sync_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_forticlient_registration_sync': {
- 'peer_ip': 'test_value_3',
- 'peer_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_registration_sync.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'peer-ip': 'test_value_3',
- 'peer-name': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'forticlient-registration-sync', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_endpoint_control_forticlient_registration_sync_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'endpoint_control_forticlient_registration_sync': {
- 'peer_ip': 'test_value_3',
- 'peer_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_registration_sync.fortios_endpoint_control(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('endpoint-control', 'forticlient-registration-sync', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_endpoint_control_forticlient_registration_sync_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'endpoint_control_forticlient_registration_sync': {
- 'peer_ip': 'test_value_3',
- 'peer_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_registration_sync.fortios_endpoint_control(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('endpoint-control', 'forticlient-registration-sync', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_endpoint_control_forticlient_registration_sync_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_forticlient_registration_sync': {
- 'peer_ip': 'test_value_3',
- 'peer_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_registration_sync.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'peer-ip': 'test_value_3',
- 'peer-name': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'forticlient-registration-sync', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_endpoint_control_forticlient_registration_sync_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_forticlient_registration_sync': {
- 'random_attribute_not_valid': 'tag',
- 'peer_ip': 'test_value_3',
- 'peer_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_forticlient_registration_sync.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'peer-ip': 'test_value_3',
- 'peer-name': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'forticlient-registration-sync', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_endpoint_control_profile.py b/test/units/modules/network/fortios/test_fortios_endpoint_control_profile.py
deleted file mode 100644
index 2f97cf1c6d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_endpoint_control_profile.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_endpoint_control_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_endpoint_control_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_endpoint_control_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_profile': {
- 'description': 'test_value_3',
- 'profile_name': 'test_value_4',
- 'replacemsg_override_group': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_profile.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'profile-name': 'test_value_4',
- 'replacemsg-override-group': 'test_value_5',
-
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_endpoint_control_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_profile': {
- 'description': 'test_value_3',
- 'profile_name': 'test_value_4',
- 'replacemsg_override_group': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_profile.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'profile-name': 'test_value_4',
- 'replacemsg-override-group': 'test_value_5',
-
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_endpoint_control_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'endpoint_control_profile': {
- 'description': 'test_value_3',
- 'profile_name': 'test_value_4',
- 'replacemsg_override_group': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_profile.fortios_endpoint_control(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('endpoint-control', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_endpoint_control_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'endpoint_control_profile': {
- 'description': 'test_value_3',
- 'profile_name': 'test_value_4',
- 'replacemsg_override_group': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_profile.fortios_endpoint_control(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('endpoint-control', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_endpoint_control_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_profile': {
- 'description': 'test_value_3',
- 'profile_name': 'test_value_4',
- 'replacemsg_override_group': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_profile.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'profile-name': 'test_value_4',
- 'replacemsg-override-group': 'test_value_5',
-
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_endpoint_control_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_profile': {
- 'random_attribute_not_valid': 'tag',
- 'description': 'test_value_3',
- 'profile_name': 'test_value_4',
- 'replacemsg_override_group': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_profile.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'profile-name': 'test_value_4',
- 'replacemsg-override-group': 'test_value_5',
-
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_endpoint_control_settings.py b/test/units/modules/network/fortios/test_fortios_endpoint_control_settings.py
deleted file mode 100644
index a8289860d8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_endpoint_control_settings.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_endpoint_control_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_endpoint_control_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_endpoint_control_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_settings': {
- 'download_custom_link': 'test_value_3',
- 'download_location': 'fortiguard',
- 'forticlient_avdb_update_interval': '5',
- 'forticlient_dereg_unsupported_client': 'enable',
- 'forticlient_ems_rest_api_call_timeout': '7',
- 'forticlient_keepalive_interval': '8',
- 'forticlient_offline_grace': 'enable',
- 'forticlient_offline_grace_interval': '10',
- 'forticlient_reg_key': 'test_value_11',
- 'forticlient_reg_key_enforce': 'enable',
- 'forticlient_reg_timeout': '13',
- 'forticlient_sys_update_interval': '14',
- 'forticlient_user_avatar': 'enable',
- 'forticlient_warning_interval': '16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_settings.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'download-custom-link': 'test_value_3',
- 'download-location': 'fortiguard',
- 'forticlient-avdb-update-interval': '5',
- 'forticlient-dereg-unsupported-client': 'enable',
- 'forticlient-ems-rest-api-call-timeout': '7',
- 'forticlient-keepalive-interval': '8',
- 'forticlient-offline-grace': 'enable',
- 'forticlient-offline-grace-interval': '10',
- 'forticlient-reg-key': 'test_value_11',
- 'forticlient-reg-key-enforce': 'enable',
- 'forticlient-reg-timeout': '13',
- 'forticlient-sys-update-interval': '14',
- 'forticlient-user-avatar': 'enable',
- 'forticlient-warning-interval': '16'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_endpoint_control_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_settings': {
- 'download_custom_link': 'test_value_3',
- 'download_location': 'fortiguard',
- 'forticlient_avdb_update_interval': '5',
- 'forticlient_dereg_unsupported_client': 'enable',
- 'forticlient_ems_rest_api_call_timeout': '7',
- 'forticlient_keepalive_interval': '8',
- 'forticlient_offline_grace': 'enable',
- 'forticlient_offline_grace_interval': '10',
- 'forticlient_reg_key': 'test_value_11',
- 'forticlient_reg_key_enforce': 'enable',
- 'forticlient_reg_timeout': '13',
- 'forticlient_sys_update_interval': '14',
- 'forticlient_user_avatar': 'enable',
- 'forticlient_warning_interval': '16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_settings.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'download-custom-link': 'test_value_3',
- 'download-location': 'fortiguard',
- 'forticlient-avdb-update-interval': '5',
- 'forticlient-dereg-unsupported-client': 'enable',
- 'forticlient-ems-rest-api-call-timeout': '7',
- 'forticlient-keepalive-interval': '8',
- 'forticlient-offline-grace': 'enable',
- 'forticlient-offline-grace-interval': '10',
- 'forticlient-reg-key': 'test_value_11',
- 'forticlient-reg-key-enforce': 'enable',
- 'forticlient-reg-timeout': '13',
- 'forticlient-sys-update-interval': '14',
- 'forticlient-user-avatar': 'enable',
- 'forticlient-warning-interval': '16'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_endpoint_control_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_settings': {
- 'download_custom_link': 'test_value_3',
- 'download_location': 'fortiguard',
- 'forticlient_avdb_update_interval': '5',
- 'forticlient_dereg_unsupported_client': 'enable',
- 'forticlient_ems_rest_api_call_timeout': '7',
- 'forticlient_keepalive_interval': '8',
- 'forticlient_offline_grace': 'enable',
- 'forticlient_offline_grace_interval': '10',
- 'forticlient_reg_key': 'test_value_11',
- 'forticlient_reg_key_enforce': 'enable',
- 'forticlient_reg_timeout': '13',
- 'forticlient_sys_update_interval': '14',
- 'forticlient_user_avatar': 'enable',
- 'forticlient_warning_interval': '16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_settings.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'download-custom-link': 'test_value_3',
- 'download-location': 'fortiguard',
- 'forticlient-avdb-update-interval': '5',
- 'forticlient-dereg-unsupported-client': 'enable',
- 'forticlient-ems-rest-api-call-timeout': '7',
- 'forticlient-keepalive-interval': '8',
- 'forticlient-offline-grace': 'enable',
- 'forticlient-offline-grace-interval': '10',
- 'forticlient-reg-key': 'test_value_11',
- 'forticlient-reg-key-enforce': 'enable',
- 'forticlient-reg-timeout': '13',
- 'forticlient-sys-update-interval': '14',
- 'forticlient-user-avatar': 'enable',
- 'forticlient-warning-interval': '16'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_endpoint_control_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'endpoint_control_settings': {
- 'random_attribute_not_valid': 'tag',
- 'download_custom_link': 'test_value_3',
- 'download_location': 'fortiguard',
- 'forticlient_avdb_update_interval': '5',
- 'forticlient_dereg_unsupported_client': 'enable',
- 'forticlient_ems_rest_api_call_timeout': '7',
- 'forticlient_keepalive_interval': '8',
- 'forticlient_offline_grace': 'enable',
- 'forticlient_offline_grace_interval': '10',
- 'forticlient_reg_key': 'test_value_11',
- 'forticlient_reg_key_enforce': 'enable',
- 'forticlient_reg_timeout': '13',
- 'forticlient_sys_update_interval': '14',
- 'forticlient_user_avatar': 'enable',
- 'forticlient_warning_interval': '16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_endpoint_control_settings.fortios_endpoint_control(input_data, fos_instance)
-
- expected_data = {
- 'download-custom-link': 'test_value_3',
- 'download-location': 'fortiguard',
- 'forticlient-avdb-update-interval': '5',
- 'forticlient-dereg-unsupported-client': 'enable',
- 'forticlient-ems-rest-api-call-timeout': '7',
- 'forticlient-keepalive-interval': '8',
- 'forticlient-offline-grace': 'enable',
- 'forticlient-offline-grace-interval': '10',
- 'forticlient-reg-key': 'test_value_11',
- 'forticlient-reg-key-enforce': 'enable',
- 'forticlient-reg-timeout': '13',
- 'forticlient-sys-update-interval': '14',
- 'forticlient-user-avatar': 'enable',
- 'forticlient-warning-interval': '16'
- }
-
- set_method_mock.assert_called_with('endpoint-control', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_extender_controller_extender.py b/test/units/modules/network/fortios/test_fortios_extender_controller_extender.py
deleted file mode 100644
index 7d3bd9e108..0000000000
--- a/test/units/modules/network/fortios/test_fortios_extender_controller_extender.py
+++ /dev/null
@@ -1,559 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_extender_controller_extender
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_extender_controller_extender.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_extender_controller_extender_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'extender_controller_extender': {
- 'aaa_shared_secret': 'test_value_3',
- 'access_point_name': 'test_value_4',
- 'admin': 'disable',
- 'at_dial_script': 'test_value_6',
- 'billing_start_day': '7',
- 'cdma_aaa_spi': 'test_value_8',
- 'cdma_ha_spi': 'test_value_9',
- 'cdma_nai': 'test_value_10',
- 'conn_status': '11',
- 'description': 'test_value_12',
- 'dial_mode': 'dial-on-demand',
- 'dial_status': '14',
- 'ext_name': 'test_value_15',
- 'ha_shared_secret': 'test_value_16',
- 'id': '17',
- 'ifname': 'test_value_18',
- 'initiated_update': 'enable',
- 'mode': 'standalone',
- 'modem_passwd': 'test_value_21',
- 'modem_type': 'cdma',
- 'multi_mode': 'auto',
- 'ppp_auth_protocol': 'auto',
- 'ppp_echo_request': 'enable',
- 'ppp_password': 'test_value_26',
- 'ppp_username': 'test_value_27',
- 'primary_ha': 'test_value_28',
- 'quota_limit_mb': '29',
- 'redial': 'none',
- 'redundant_intf': 'test_value_31',
- 'roaming': 'enable',
- 'role': 'none',
- 'secondary_ha': 'test_value_34',
- 'sim_pin': 'test_value_35',
- 'vdom': '36',
- 'wimax_auth_protocol': 'tls',
- 'wimax_carrier': 'test_value_38',
- 'wimax_realm': 'test_value_39'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_extender_controller_extender.fortios_extender_controller(input_data, fos_instance)
-
- expected_data = {
- 'aaa-shared-secret': 'test_value_3',
- 'access-point-name': 'test_value_4',
- 'admin': 'disable',
- 'at-dial-script': 'test_value_6',
- 'billing-start-day': '7',
- 'cdma-aaa-spi': 'test_value_8',
- 'cdma-ha-spi': 'test_value_9',
- 'cdma-nai': 'test_value_10',
- 'conn-status': '11',
- 'description': 'test_value_12',
- 'dial-mode': 'dial-on-demand',
- 'dial-status': '14',
- 'ext-name': 'test_value_15',
- 'ha-shared-secret': 'test_value_16',
- 'id': '17',
- 'ifname': 'test_value_18',
- 'initiated-update': 'enable',
- 'mode': 'standalone',
- 'modem-passwd': 'test_value_21',
- 'modem-type': 'cdma',
- 'multi-mode': 'auto',
- 'ppp-auth-protocol': 'auto',
- 'ppp-echo-request': 'enable',
- 'ppp-password': 'test_value_26',
- 'ppp-username': 'test_value_27',
- 'primary-ha': 'test_value_28',
- 'quota-limit-mb': '29',
- 'redial': 'none',
- 'redundant-intf': 'test_value_31',
- 'roaming': 'enable',
- 'role': 'none',
- 'secondary-ha': 'test_value_34',
- 'sim-pin': 'test_value_35',
- 'vdom': '36',
- 'wimax-auth-protocol': 'tls',
- 'wimax-carrier': 'test_value_38',
- 'wimax-realm': 'test_value_39'
- }
-
- set_method_mock.assert_called_with('extender-controller', 'extender', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_extender_controller_extender_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'extender_controller_extender': {
- 'aaa_shared_secret': 'test_value_3',
- 'access_point_name': 'test_value_4',
- 'admin': 'disable',
- 'at_dial_script': 'test_value_6',
- 'billing_start_day': '7',
- 'cdma_aaa_spi': 'test_value_8',
- 'cdma_ha_spi': 'test_value_9',
- 'cdma_nai': 'test_value_10',
- 'conn_status': '11',
- 'description': 'test_value_12',
- 'dial_mode': 'dial-on-demand',
- 'dial_status': '14',
- 'ext_name': 'test_value_15',
- 'ha_shared_secret': 'test_value_16',
- 'id': '17',
- 'ifname': 'test_value_18',
- 'initiated_update': 'enable',
- 'mode': 'standalone',
- 'modem_passwd': 'test_value_21',
- 'modem_type': 'cdma',
- 'multi_mode': 'auto',
- 'ppp_auth_protocol': 'auto',
- 'ppp_echo_request': 'enable',
- 'ppp_password': 'test_value_26',
- 'ppp_username': 'test_value_27',
- 'primary_ha': 'test_value_28',
- 'quota_limit_mb': '29',
- 'redial': 'none',
- 'redundant_intf': 'test_value_31',
- 'roaming': 'enable',
- 'role': 'none',
- 'secondary_ha': 'test_value_34',
- 'sim_pin': 'test_value_35',
- 'vdom': '36',
- 'wimax_auth_protocol': 'tls',
- 'wimax_carrier': 'test_value_38',
- 'wimax_realm': 'test_value_39'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_extender_controller_extender.fortios_extender_controller(input_data, fos_instance)
-
- expected_data = {
- 'aaa-shared-secret': 'test_value_3',
- 'access-point-name': 'test_value_4',
- 'admin': 'disable',
- 'at-dial-script': 'test_value_6',
- 'billing-start-day': '7',
- 'cdma-aaa-spi': 'test_value_8',
- 'cdma-ha-spi': 'test_value_9',
- 'cdma-nai': 'test_value_10',
- 'conn-status': '11',
- 'description': 'test_value_12',
- 'dial-mode': 'dial-on-demand',
- 'dial-status': '14',
- 'ext-name': 'test_value_15',
- 'ha-shared-secret': 'test_value_16',
- 'id': '17',
- 'ifname': 'test_value_18',
- 'initiated-update': 'enable',
- 'mode': 'standalone',
- 'modem-passwd': 'test_value_21',
- 'modem-type': 'cdma',
- 'multi-mode': 'auto',
- 'ppp-auth-protocol': 'auto',
- 'ppp-echo-request': 'enable',
- 'ppp-password': 'test_value_26',
- 'ppp-username': 'test_value_27',
- 'primary-ha': 'test_value_28',
- 'quota-limit-mb': '29',
- 'redial': 'none',
- 'redundant-intf': 'test_value_31',
- 'roaming': 'enable',
- 'role': 'none',
- 'secondary-ha': 'test_value_34',
- 'sim-pin': 'test_value_35',
- 'vdom': '36',
- 'wimax-auth-protocol': 'tls',
- 'wimax-carrier': 'test_value_38',
- 'wimax-realm': 'test_value_39'
- }
-
- set_method_mock.assert_called_with('extender-controller', 'extender', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_extender_controller_extender_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'extender_controller_extender': {
- 'aaa_shared_secret': 'test_value_3',
- 'access_point_name': 'test_value_4',
- 'admin': 'disable',
- 'at_dial_script': 'test_value_6',
- 'billing_start_day': '7',
- 'cdma_aaa_spi': 'test_value_8',
- 'cdma_ha_spi': 'test_value_9',
- 'cdma_nai': 'test_value_10',
- 'conn_status': '11',
- 'description': 'test_value_12',
- 'dial_mode': 'dial-on-demand',
- 'dial_status': '14',
- 'ext_name': 'test_value_15',
- 'ha_shared_secret': 'test_value_16',
- 'id': '17',
- 'ifname': 'test_value_18',
- 'initiated_update': 'enable',
- 'mode': 'standalone',
- 'modem_passwd': 'test_value_21',
- 'modem_type': 'cdma',
- 'multi_mode': 'auto',
- 'ppp_auth_protocol': 'auto',
- 'ppp_echo_request': 'enable',
- 'ppp_password': 'test_value_26',
- 'ppp_username': 'test_value_27',
- 'primary_ha': 'test_value_28',
- 'quota_limit_mb': '29',
- 'redial': 'none',
- 'redundant_intf': 'test_value_31',
- 'roaming': 'enable',
- 'role': 'none',
- 'secondary_ha': 'test_value_34',
- 'sim_pin': 'test_value_35',
- 'vdom': '36',
- 'wimax_auth_protocol': 'tls',
- 'wimax_carrier': 'test_value_38',
- 'wimax_realm': 'test_value_39'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_extender_controller_extender.fortios_extender_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('extender-controller', 'extender', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_extender_controller_extender_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'extender_controller_extender': {
- 'aaa_shared_secret': 'test_value_3',
- 'access_point_name': 'test_value_4',
- 'admin': 'disable',
- 'at_dial_script': 'test_value_6',
- 'billing_start_day': '7',
- 'cdma_aaa_spi': 'test_value_8',
- 'cdma_ha_spi': 'test_value_9',
- 'cdma_nai': 'test_value_10',
- 'conn_status': '11',
- 'description': 'test_value_12',
- 'dial_mode': 'dial-on-demand',
- 'dial_status': '14',
- 'ext_name': 'test_value_15',
- 'ha_shared_secret': 'test_value_16',
- 'id': '17',
- 'ifname': 'test_value_18',
- 'initiated_update': 'enable',
- 'mode': 'standalone',
- 'modem_passwd': 'test_value_21',
- 'modem_type': 'cdma',
- 'multi_mode': 'auto',
- 'ppp_auth_protocol': 'auto',
- 'ppp_echo_request': 'enable',
- 'ppp_password': 'test_value_26',
- 'ppp_username': 'test_value_27',
- 'primary_ha': 'test_value_28',
- 'quota_limit_mb': '29',
- 'redial': 'none',
- 'redundant_intf': 'test_value_31',
- 'roaming': 'enable',
- 'role': 'none',
- 'secondary_ha': 'test_value_34',
- 'sim_pin': 'test_value_35',
- 'vdom': '36',
- 'wimax_auth_protocol': 'tls',
- 'wimax_carrier': 'test_value_38',
- 'wimax_realm': 'test_value_39'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_extender_controller_extender.fortios_extender_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('extender-controller', 'extender', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_extender_controller_extender_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'extender_controller_extender': {
- 'aaa_shared_secret': 'test_value_3',
- 'access_point_name': 'test_value_4',
- 'admin': 'disable',
- 'at_dial_script': 'test_value_6',
- 'billing_start_day': '7',
- 'cdma_aaa_spi': 'test_value_8',
- 'cdma_ha_spi': 'test_value_9',
- 'cdma_nai': 'test_value_10',
- 'conn_status': '11',
- 'description': 'test_value_12',
- 'dial_mode': 'dial-on-demand',
- 'dial_status': '14',
- 'ext_name': 'test_value_15',
- 'ha_shared_secret': 'test_value_16',
- 'id': '17',
- 'ifname': 'test_value_18',
- 'initiated_update': 'enable',
- 'mode': 'standalone',
- 'modem_passwd': 'test_value_21',
- 'modem_type': 'cdma',
- 'multi_mode': 'auto',
- 'ppp_auth_protocol': 'auto',
- 'ppp_echo_request': 'enable',
- 'ppp_password': 'test_value_26',
- 'ppp_username': 'test_value_27',
- 'primary_ha': 'test_value_28',
- 'quota_limit_mb': '29',
- 'redial': 'none',
- 'redundant_intf': 'test_value_31',
- 'roaming': 'enable',
- 'role': 'none',
- 'secondary_ha': 'test_value_34',
- 'sim_pin': 'test_value_35',
- 'vdom': '36',
- 'wimax_auth_protocol': 'tls',
- 'wimax_carrier': 'test_value_38',
- 'wimax_realm': 'test_value_39'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_extender_controller_extender.fortios_extender_controller(input_data, fos_instance)
-
- expected_data = {
- 'aaa-shared-secret': 'test_value_3',
- 'access-point-name': 'test_value_4',
- 'admin': 'disable',
- 'at-dial-script': 'test_value_6',
- 'billing-start-day': '7',
- 'cdma-aaa-spi': 'test_value_8',
- 'cdma-ha-spi': 'test_value_9',
- 'cdma-nai': 'test_value_10',
- 'conn-status': '11',
- 'description': 'test_value_12',
- 'dial-mode': 'dial-on-demand',
- 'dial-status': '14',
- 'ext-name': 'test_value_15',
- 'ha-shared-secret': 'test_value_16',
- 'id': '17',
- 'ifname': 'test_value_18',
- 'initiated-update': 'enable',
- 'mode': 'standalone',
- 'modem-passwd': 'test_value_21',
- 'modem-type': 'cdma',
- 'multi-mode': 'auto',
- 'ppp-auth-protocol': 'auto',
- 'ppp-echo-request': 'enable',
- 'ppp-password': 'test_value_26',
- 'ppp-username': 'test_value_27',
- 'primary-ha': 'test_value_28',
- 'quota-limit-mb': '29',
- 'redial': 'none',
- 'redundant-intf': 'test_value_31',
- 'roaming': 'enable',
- 'role': 'none',
- 'secondary-ha': 'test_value_34',
- 'sim-pin': 'test_value_35',
- 'vdom': '36',
- 'wimax-auth-protocol': 'tls',
- 'wimax-carrier': 'test_value_38',
- 'wimax-realm': 'test_value_39'
- }
-
- set_method_mock.assert_called_with('extender-controller', 'extender', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_extender_controller_extender_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'extender_controller_extender': {
- 'random_attribute_not_valid': 'tag',
- 'aaa_shared_secret': 'test_value_3',
- 'access_point_name': 'test_value_4',
- 'admin': 'disable',
- 'at_dial_script': 'test_value_6',
- 'billing_start_day': '7',
- 'cdma_aaa_spi': 'test_value_8',
- 'cdma_ha_spi': 'test_value_9',
- 'cdma_nai': 'test_value_10',
- 'conn_status': '11',
- 'description': 'test_value_12',
- 'dial_mode': 'dial-on-demand',
- 'dial_status': '14',
- 'ext_name': 'test_value_15',
- 'ha_shared_secret': 'test_value_16',
- 'id': '17',
- 'ifname': 'test_value_18',
- 'initiated_update': 'enable',
- 'mode': 'standalone',
- 'modem_passwd': 'test_value_21',
- 'modem_type': 'cdma',
- 'multi_mode': 'auto',
- 'ppp_auth_protocol': 'auto',
- 'ppp_echo_request': 'enable',
- 'ppp_password': 'test_value_26',
- 'ppp_username': 'test_value_27',
- 'primary_ha': 'test_value_28',
- 'quota_limit_mb': '29',
- 'redial': 'none',
- 'redundant_intf': 'test_value_31',
- 'roaming': 'enable',
- 'role': 'none',
- 'secondary_ha': 'test_value_34',
- 'sim_pin': 'test_value_35',
- 'vdom': '36',
- 'wimax_auth_protocol': 'tls',
- 'wimax_carrier': 'test_value_38',
- 'wimax_realm': 'test_value_39'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_extender_controller_extender.fortios_extender_controller(input_data, fos_instance)
-
- expected_data = {
- 'aaa-shared-secret': 'test_value_3',
- 'access-point-name': 'test_value_4',
- 'admin': 'disable',
- 'at-dial-script': 'test_value_6',
- 'billing-start-day': '7',
- 'cdma-aaa-spi': 'test_value_8',
- 'cdma-ha-spi': 'test_value_9',
- 'cdma-nai': 'test_value_10',
- 'conn-status': '11',
- 'description': 'test_value_12',
- 'dial-mode': 'dial-on-demand',
- 'dial-status': '14',
- 'ext-name': 'test_value_15',
- 'ha-shared-secret': 'test_value_16',
- 'id': '17',
- 'ifname': 'test_value_18',
- 'initiated-update': 'enable',
- 'mode': 'standalone',
- 'modem-passwd': 'test_value_21',
- 'modem-type': 'cdma',
- 'multi-mode': 'auto',
- 'ppp-auth-protocol': 'auto',
- 'ppp-echo-request': 'enable',
- 'ppp-password': 'test_value_26',
- 'ppp-username': 'test_value_27',
- 'primary-ha': 'test_value_28',
- 'quota-limit-mb': '29',
- 'redial': 'none',
- 'redundant-intf': 'test_value_31',
- 'roaming': 'enable',
- 'role': 'none',
- 'secondary-ha': 'test_value_34',
- 'sim-pin': 'test_value_35',
- 'vdom': '36',
- 'wimax-auth-protocol': 'tls',
- 'wimax-carrier': 'test_value_38',
- 'wimax-realm': 'test_value_39'
- }
-
- set_method_mock.assert_called_with('extender-controller', 'extender', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_facts.py b/test/units/modules/network/fortios/test_fortios_facts.py
deleted file mode 100644
index 8b9a4145d7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_facts.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from units.modules.utils import exit_json, fail_json
-from units.compat import unittest
-from units.compat.mock import patch
-from ansible.module_utils import basic
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.module_utils.network.fortios.facts.facts import Facts
- from ansible.modules.network.fortios import fortios_facts
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_facts.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_facts_get(mocker):
- monitor_method_result = {'status': 'success', 'http_method': 'GET', 'http_status': 200}
- monitor_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.monitor', return_value=monitor_method_result)
- mock_module = patch.multiple(basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json)
- mock_module._connection = connection_mock
-
- # test case 01, args with single gather_subset
- args = {
- 'vdom': 'root',
- 'gather_subset': [
- {'fact': 'system_status_select'},
- ]
- }
- mock_module.params = args
-
- response, ignore = Facts(mock_module, fos_instance).get_facts()
-
- monitor_method_mock.assert_called_with('system', 'status/select', vdom='root')
- assert response['ansible_network_resources']['system_status_select']['status'] == 'success'
- assert response['ansible_network_resources']['system_status_select']['http_status'] == 200
-
- # test case 02, args with single gather_subset with filters
- args = {
- 'vdom': 'root',
- 'gather_subset': [
- {'fact': 'system_interface_select', 'filters': [{'include_vlan': 'true'}, {'interface_name': 'port3'}]},
- ]
- }
-
- mock_module.params = args
-
- response, ignore = Facts(mock_module, fos_instance).get_facts()
-
- monitor_method_mock.assert_called_with('system', 'interface/select?vdom=root&include_vlan=true&interface_name=port3', vdom=None)
- assert response['ansible_network_resources']['system_interface_select']['status'] == 'success'
- assert response['ansible_network_resources']['system_interface_select']['http_status'] == 200
-
- # test case 03, args with multiple gather_subset
- args = {
- 'vdom': 'root',
- 'gather_subset': [
- {'fact': 'system_current-admins_select'},
- {'fact': 'system_firmware_select'},
- {'fact': 'system_fortimanager_status'},
- {'fact': 'system_ha-checksums_select'},
- ]
- }
-
- mock_module.params = args
-
- response, ignore = Facts(mock_module, fos_instance).get_facts()
-
- monitor_method_mock.assert_any_call('system', 'current-admins/select', vdom='root')
- monitor_method_mock.assert_any_call('system', 'firmware/select', vdom='root')
- monitor_method_mock.assert_any_call('system', 'fortimanager/status', vdom='root')
- monitor_method_mock.assert_any_call('system', 'ha-checksums/select', vdom='root')
- assert response['ansible_network_resources']['system_ha-checksums_select']['status'] == 'success'
- assert response['ansible_network_resources']['system_ha-checksums_select']['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_DoS_policy.py b/test/units/modules/network/fortios/test_fortios_firewall_DoS_policy.py
deleted file mode 100644
index 428843a453..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_DoS_policy.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_DoS_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_DoS_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_DoS_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_DoS_policy': {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'DoS-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_DoS_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_DoS_policy': {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'DoS-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_DoS_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_DoS_policy': {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'DoS-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_DoS_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_DoS_policy': {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'DoS-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_DoS_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_DoS_policy': {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'DoS-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_DoS_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_DoS_policy': {
- 'random_attribute_not_valid': 'tag', 'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'DoS-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_DoS_policy6.py b/test/units/modules/network/fortios/test_fortios_firewall_DoS_policy6.py
deleted file mode 100644
index 02c87150b1..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_DoS_policy6.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_DoS_policy6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_DoS_policy6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_DoS_policy6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_DoS_policy6': {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'DoS-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_DoS_policy6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_DoS_policy6': {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'DoS-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_DoS_policy6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_DoS_policy6': {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'DoS-policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_DoS_policy6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_DoS_policy6': {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'DoS-policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_DoS_policy6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_DoS_policy6': {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'DoS-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_DoS_policy6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_DoS_policy6': {
- 'random_attribute_not_valid': 'tag', 'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_DoS_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'comments': 'test_value_3',
- 'interface': 'test_value_4',
- 'policyid': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'DoS-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_address.py b/test/units/modules/network/fortios/test_fortios_firewall_address.py
deleted file mode 100644
index ca164d8c11..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_address.py
+++ /dev/null
@@ -1,439 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_address
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_address.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_address_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address': {
- 'allow_routing': 'enable',
- 'associated_interface': 'test_value_4',
- 'cache_ttl': '5',
- 'color': '6',
- 'comment': 'Comment.',
- 'country': 'test_value_8',
- 'end_ip': 'test_value_9',
- 'epg_name': 'test_value_10',
- 'filter': 'test_value_11',
- 'fqdn': 'test_value_12',
- 'name': 'default_name_13',
- 'obj_id': 'test_value_14',
- 'organization': 'test_value_15',
- 'policy_group': 'test_value_16',
- 'sdn': 'aci',
- 'sdn_tag': 'test_value_18',
- 'start_ip': 'test_value_19',
- 'subnet': 'test_value_20',
- 'subnet_name': 'test_value_21',
- 'tenant': 'test_value_22',
- 'type': 'ipmask',
- 'uuid': 'test_value_24',
- 'visibility': 'enable',
- 'wildcard': 'test_value_26',
- 'wildcard_fqdn': 'test_value_27'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'allow-routing': 'enable',
- 'associated-interface': 'test_value_4',
- 'cache-ttl': '5',
- 'color': '6',
- 'comment': 'Comment.',
- 'country': 'test_value_8',
- 'end-ip': 'test_value_9',
- 'epg-name': 'test_value_10',
- 'filter': 'test_value_11',
- 'fqdn': 'test_value_12',
- 'name': 'default_name_13',
- 'obj-id': 'test_value_14',
- 'organization': 'test_value_15',
- 'policy-group': 'test_value_16',
- 'sdn': 'aci',
- 'sdn-tag': 'test_value_18',
- 'start-ip': 'test_value_19',
- 'subnet': 'test_value_20',
- 'subnet-name': 'test_value_21',
- 'tenant': 'test_value_22',
- 'type': 'ipmask',
- 'uuid': 'test_value_24',
- 'visibility': 'enable',
- 'wildcard': 'test_value_26',
- 'wildcard-fqdn': 'test_value_27'
- }
-
- set_method_mock.assert_called_with('firewall', 'address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_address_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address': {
- 'allow_routing': 'enable',
- 'associated_interface': 'test_value_4',
- 'cache_ttl': '5',
- 'color': '6',
- 'comment': 'Comment.',
- 'country': 'test_value_8',
- 'end_ip': 'test_value_9',
- 'epg_name': 'test_value_10',
- 'filter': 'test_value_11',
- 'fqdn': 'test_value_12',
- 'name': 'default_name_13',
- 'obj_id': 'test_value_14',
- 'organization': 'test_value_15',
- 'policy_group': 'test_value_16',
- 'sdn': 'aci',
- 'sdn_tag': 'test_value_18',
- 'start_ip': 'test_value_19',
- 'subnet': 'test_value_20',
- 'subnet_name': 'test_value_21',
- 'tenant': 'test_value_22',
- 'type': 'ipmask',
- 'uuid': 'test_value_24',
- 'visibility': 'enable',
- 'wildcard': 'test_value_26',
- 'wildcard_fqdn': 'test_value_27'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'allow-routing': 'enable',
- 'associated-interface': 'test_value_4',
- 'cache-ttl': '5',
- 'color': '6',
- 'comment': 'Comment.',
- 'country': 'test_value_8',
- 'end-ip': 'test_value_9',
- 'epg-name': 'test_value_10',
- 'filter': 'test_value_11',
- 'fqdn': 'test_value_12',
- 'name': 'default_name_13',
- 'obj-id': 'test_value_14',
- 'organization': 'test_value_15',
- 'policy-group': 'test_value_16',
- 'sdn': 'aci',
- 'sdn-tag': 'test_value_18',
- 'start-ip': 'test_value_19',
- 'subnet': 'test_value_20',
- 'subnet-name': 'test_value_21',
- 'tenant': 'test_value_22',
- 'type': 'ipmask',
- 'uuid': 'test_value_24',
- 'visibility': 'enable',
- 'wildcard': 'test_value_26',
- 'wildcard-fqdn': 'test_value_27'
- }
-
- set_method_mock.assert_called_with('firewall', 'address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_address_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_address': {
- 'allow_routing': 'enable',
- 'associated_interface': 'test_value_4',
- 'cache_ttl': '5',
- 'color': '6',
- 'comment': 'Comment.',
- 'country': 'test_value_8',
- 'end_ip': 'test_value_9',
- 'epg_name': 'test_value_10',
- 'filter': 'test_value_11',
- 'fqdn': 'test_value_12',
- 'name': 'default_name_13',
- 'obj_id': 'test_value_14',
- 'organization': 'test_value_15',
- 'policy_group': 'test_value_16',
- 'sdn': 'aci',
- 'sdn_tag': 'test_value_18',
- 'start_ip': 'test_value_19',
- 'subnet': 'test_value_20',
- 'subnet_name': 'test_value_21',
- 'tenant': 'test_value_22',
- 'type': 'ipmask',
- 'uuid': 'test_value_24',
- 'visibility': 'enable',
- 'wildcard': 'test_value_26',
- 'wildcard_fqdn': 'test_value_27'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'address', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_address_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_address': {
- 'allow_routing': 'enable',
- 'associated_interface': 'test_value_4',
- 'cache_ttl': '5',
- 'color': '6',
- 'comment': 'Comment.',
- 'country': 'test_value_8',
- 'end_ip': 'test_value_9',
- 'epg_name': 'test_value_10',
- 'filter': 'test_value_11',
- 'fqdn': 'test_value_12',
- 'name': 'default_name_13',
- 'obj_id': 'test_value_14',
- 'organization': 'test_value_15',
- 'policy_group': 'test_value_16',
- 'sdn': 'aci',
- 'sdn_tag': 'test_value_18',
- 'start_ip': 'test_value_19',
- 'subnet': 'test_value_20',
- 'subnet_name': 'test_value_21',
- 'tenant': 'test_value_22',
- 'type': 'ipmask',
- 'uuid': 'test_value_24',
- 'visibility': 'enable',
- 'wildcard': 'test_value_26',
- 'wildcard_fqdn': 'test_value_27'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'address', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_address_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address': {
- 'allow_routing': 'enable',
- 'associated_interface': 'test_value_4',
- 'cache_ttl': '5',
- 'color': '6',
- 'comment': 'Comment.',
- 'country': 'test_value_8',
- 'end_ip': 'test_value_9',
- 'epg_name': 'test_value_10',
- 'filter': 'test_value_11',
- 'fqdn': 'test_value_12',
- 'name': 'default_name_13',
- 'obj_id': 'test_value_14',
- 'organization': 'test_value_15',
- 'policy_group': 'test_value_16',
- 'sdn': 'aci',
- 'sdn_tag': 'test_value_18',
- 'start_ip': 'test_value_19',
- 'subnet': 'test_value_20',
- 'subnet_name': 'test_value_21',
- 'tenant': 'test_value_22',
- 'type': 'ipmask',
- 'uuid': 'test_value_24',
- 'visibility': 'enable',
- 'wildcard': 'test_value_26',
- 'wildcard_fqdn': 'test_value_27'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'allow-routing': 'enable',
- 'associated-interface': 'test_value_4',
- 'cache-ttl': '5',
- 'color': '6',
- 'comment': 'Comment.',
- 'country': 'test_value_8',
- 'end-ip': 'test_value_9',
- 'epg-name': 'test_value_10',
- 'filter': 'test_value_11',
- 'fqdn': 'test_value_12',
- 'name': 'default_name_13',
- 'obj-id': 'test_value_14',
- 'organization': 'test_value_15',
- 'policy-group': 'test_value_16',
- 'sdn': 'aci',
- 'sdn-tag': 'test_value_18',
- 'start-ip': 'test_value_19',
- 'subnet': 'test_value_20',
- 'subnet-name': 'test_value_21',
- 'tenant': 'test_value_22',
- 'type': 'ipmask',
- 'uuid': 'test_value_24',
- 'visibility': 'enable',
- 'wildcard': 'test_value_26',
- 'wildcard-fqdn': 'test_value_27'
- }
-
- set_method_mock.assert_called_with('firewall', 'address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_address_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address': {
- 'random_attribute_not_valid': 'tag',
- 'allow_routing': 'enable',
- 'associated_interface': 'test_value_4',
- 'cache_ttl': '5',
- 'color': '6',
- 'comment': 'Comment.',
- 'country': 'test_value_8',
- 'end_ip': 'test_value_9',
- 'epg_name': 'test_value_10',
- 'filter': 'test_value_11',
- 'fqdn': 'test_value_12',
- 'name': 'default_name_13',
- 'obj_id': 'test_value_14',
- 'organization': 'test_value_15',
- 'policy_group': 'test_value_16',
- 'sdn': 'aci',
- 'sdn_tag': 'test_value_18',
- 'start_ip': 'test_value_19',
- 'subnet': 'test_value_20',
- 'subnet_name': 'test_value_21',
- 'tenant': 'test_value_22',
- 'type': 'ipmask',
- 'uuid': 'test_value_24',
- 'visibility': 'enable',
- 'wildcard': 'test_value_26',
- 'wildcard_fqdn': 'test_value_27'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'allow-routing': 'enable',
- 'associated-interface': 'test_value_4',
- 'cache-ttl': '5',
- 'color': '6',
- 'comment': 'Comment.',
- 'country': 'test_value_8',
- 'end-ip': 'test_value_9',
- 'epg-name': 'test_value_10',
- 'filter': 'test_value_11',
- 'fqdn': 'test_value_12',
- 'name': 'default_name_13',
- 'obj-id': 'test_value_14',
- 'organization': 'test_value_15',
- 'policy-group': 'test_value_16',
- 'sdn': 'aci',
- 'sdn-tag': 'test_value_18',
- 'start-ip': 'test_value_19',
- 'subnet': 'test_value_20',
- 'subnet-name': 'test_value_21',
- 'tenant': 'test_value_22',
- 'type': 'ipmask',
- 'uuid': 'test_value_24',
- 'visibility': 'enable',
- 'wildcard': 'test_value_26',
- 'wildcard-fqdn': 'test_value_27'
- }
-
- set_method_mock.assert_called_with('firewall', 'address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_address6.py b/test/units/modules/network/fortios/test_fortios_firewall_address6.py
deleted file mode 100644
index 78d90b9c1e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_address6.py
+++ /dev/null
@@ -1,349 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_address6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_address6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_address6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address6': {
- 'cache_ttl': '3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'fqdn': 'test_value_7',
- 'host': 'test_value_8',
- 'host_type': 'any',
- 'ip6': 'test_value_10',
- 'name': 'default_name_11',
- 'obj_id': 'test_value_12',
- 'sdn': 'nsx',
- 'start_ip': 'test_value_14',
- 'template': 'test_value_15',
- 'type': 'ipprefix',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'cache-ttl': '3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end-ip': 'test_value_6',
- 'fqdn': 'test_value_7',
- 'host': 'test_value_8',
- 'host-type': 'any',
- 'ip6': 'test_value_10',
- 'name': 'default_name_11',
- 'obj-id': 'test_value_12',
- 'sdn': 'nsx',
- 'start-ip': 'test_value_14',
- 'template': 'test_value_15',
- 'type': 'ipprefix',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'address6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_address6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address6': {
- 'cache_ttl': '3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'fqdn': 'test_value_7',
- 'host': 'test_value_8',
- 'host_type': 'any',
- 'ip6': 'test_value_10',
- 'name': 'default_name_11',
- 'obj_id': 'test_value_12',
- 'sdn': 'nsx',
- 'start_ip': 'test_value_14',
- 'template': 'test_value_15',
- 'type': 'ipprefix',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'cache-ttl': '3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end-ip': 'test_value_6',
- 'fqdn': 'test_value_7',
- 'host': 'test_value_8',
- 'host-type': 'any',
- 'ip6': 'test_value_10',
- 'name': 'default_name_11',
- 'obj-id': 'test_value_12',
- 'sdn': 'nsx',
- 'start-ip': 'test_value_14',
- 'template': 'test_value_15',
- 'type': 'ipprefix',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'address6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_address6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_address6': {
- 'cache_ttl': '3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'fqdn': 'test_value_7',
- 'host': 'test_value_8',
- 'host_type': 'any',
- 'ip6': 'test_value_10',
- 'name': 'default_name_11',
- 'obj_id': 'test_value_12',
- 'sdn': 'nsx',
- 'start_ip': 'test_value_14',
- 'template': 'test_value_15',
- 'type': 'ipprefix',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'address6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_address6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_address6': {
- 'cache_ttl': '3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'fqdn': 'test_value_7',
- 'host': 'test_value_8',
- 'host_type': 'any',
- 'ip6': 'test_value_10',
- 'name': 'default_name_11',
- 'obj_id': 'test_value_12',
- 'sdn': 'nsx',
- 'start_ip': 'test_value_14',
- 'template': 'test_value_15',
- 'type': 'ipprefix',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'address6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_address6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address6': {
- 'cache_ttl': '3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'fqdn': 'test_value_7',
- 'host': 'test_value_8',
- 'host_type': 'any',
- 'ip6': 'test_value_10',
- 'name': 'default_name_11',
- 'obj_id': 'test_value_12',
- 'sdn': 'nsx',
- 'start_ip': 'test_value_14',
- 'template': 'test_value_15',
- 'type': 'ipprefix',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'cache-ttl': '3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end-ip': 'test_value_6',
- 'fqdn': 'test_value_7',
- 'host': 'test_value_8',
- 'host-type': 'any',
- 'ip6': 'test_value_10',
- 'name': 'default_name_11',
- 'obj-id': 'test_value_12',
- 'sdn': 'nsx',
- 'start-ip': 'test_value_14',
- 'template': 'test_value_15',
- 'type': 'ipprefix',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'address6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_address6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address6': {
- 'random_attribute_not_valid': 'tag',
- 'cache_ttl': '3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'fqdn': 'test_value_7',
- 'host': 'test_value_8',
- 'host_type': 'any',
- 'ip6': 'test_value_10',
- 'name': 'default_name_11',
- 'obj_id': 'test_value_12',
- 'sdn': 'nsx',
- 'start_ip': 'test_value_14',
- 'template': 'test_value_15',
- 'type': 'ipprefix',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'cache-ttl': '3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end-ip': 'test_value_6',
- 'fqdn': 'test_value_7',
- 'host': 'test_value_8',
- 'host-type': 'any',
- 'ip6': 'test_value_10',
- 'name': 'default_name_11',
- 'obj-id': 'test_value_12',
- 'sdn': 'nsx',
- 'start-ip': 'test_value_14',
- 'template': 'test_value_15',
- 'type': 'ipprefix',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'address6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_address6_template.py b/test/units/modules/network/fortios/test_fortios_firewall_address6_template.py
deleted file mode 100644
index afbb751892..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_address6_template.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_address6_template
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_address6_template.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_address6_template_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address6_template': {
- 'ip6': 'test_value_3',
- 'name': 'default_name_4',
- 'subnet_segment_count': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6_template.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'ip6': 'test_value_3',
- 'name': 'default_name_4',
- 'subnet-segment-count': '5'
- }
-
- set_method_mock.assert_called_with('firewall', 'address6-template', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_address6_template_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address6_template': {
- 'ip6': 'test_value_3',
- 'name': 'default_name_4',
- 'subnet_segment_count': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6_template.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'ip6': 'test_value_3',
- 'name': 'default_name_4',
- 'subnet-segment-count': '5'
- }
-
- set_method_mock.assert_called_with('firewall', 'address6-template', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_address6_template_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_address6_template': {
- 'ip6': 'test_value_3',
- 'name': 'default_name_4',
- 'subnet_segment_count': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6_template.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'address6-template', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_address6_template_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_address6_template': {
- 'ip6': 'test_value_3',
- 'name': 'default_name_4',
- 'subnet_segment_count': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6_template.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'address6-template', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_address6_template_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address6_template': {
- 'ip6': 'test_value_3',
- 'name': 'default_name_4',
- 'subnet_segment_count': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6_template.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'ip6': 'test_value_3',
- 'name': 'default_name_4',
- 'subnet-segment-count': '5'
- }
-
- set_method_mock.assert_called_with('firewall', 'address6-template', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_address6_template_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_address6_template': {
- 'random_attribute_not_valid': 'tag',
- 'ip6': 'test_value_3',
- 'name': 'default_name_4',
- 'subnet_segment_count': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_address6_template.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'ip6': 'test_value_3',
- 'name': 'default_name_4',
- 'subnet-segment-count': '5'
- }
-
- set_method_mock.assert_called_with('firewall', 'address6-template', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_addrgrp.py b/test/units/modules/network/fortios/test_fortios_firewall_addrgrp.py
deleted file mode 100644
index 51b3250106..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_addrgrp.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_addrgrp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_addrgrp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_addrgrp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_addrgrp': {
- 'allow_routing': 'enable',
- 'color': '4',
- 'comment': 'Comment.',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'allow-routing': 'enable',
- 'color': '4',
- 'comment': 'Comment.',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'addrgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_addrgrp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_addrgrp': {
- 'allow_routing': 'enable',
- 'color': '4',
- 'comment': 'Comment.',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'allow-routing': 'enable',
- 'color': '4',
- 'comment': 'Comment.',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'addrgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_addrgrp_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_addrgrp': {
- 'allow_routing': 'enable',
- 'color': '4',
- 'comment': 'Comment.',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'addrgrp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_addrgrp_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_addrgrp': {
- 'allow_routing': 'enable',
- 'color': '4',
- 'comment': 'Comment.',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'addrgrp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_addrgrp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_addrgrp': {
- 'allow_routing': 'enable',
- 'color': '4',
- 'comment': 'Comment.',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'allow-routing': 'enable',
- 'color': '4',
- 'comment': 'Comment.',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'addrgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_addrgrp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_addrgrp': {
- 'random_attribute_not_valid': 'tag',
- 'allow_routing': 'enable',
- 'color': '4',
- 'comment': 'Comment.',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'allow-routing': 'enable',
- 'color': '4',
- 'comment': 'Comment.',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'addrgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_addrgrp6.py b/test/units/modules/network/fortios/test_fortios_firewall_addrgrp6.py
deleted file mode 100644
index ce4eaa3a0e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_addrgrp6.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_addrgrp6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_addrgrp6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_addrgrp6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_addrgrp6': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'addrgrp6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_addrgrp6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_addrgrp6': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'addrgrp6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_addrgrp6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_addrgrp6': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'addrgrp6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_addrgrp6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_addrgrp6': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'addrgrp6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_addrgrp6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_addrgrp6': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'addrgrp6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_addrgrp6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_addrgrp6': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_addrgrp6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'addrgrp6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_auth_portal.py b/test/units/modules/network/fortios/test_fortios_firewall_auth_portal.py
deleted file mode 100644
index def708b3da..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_auth_portal.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_auth_portal
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_auth_portal.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_auth_portal_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_auth_portal': {'identity_based_route': 'test_value_3',
- 'portal_addr': 'test_value_4',
- 'portal_addr6': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_auth_portal.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'identity-based-route': 'test_value_3',
- 'portal-addr': 'test_value_4',
- 'portal-addr6': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('firewall', 'auth-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_auth_portal_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_auth_portal': {'identity_based_route': 'test_value_3',
- 'portal_addr': 'test_value_4',
- 'portal_addr6': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_auth_portal.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'identity-based-route': 'test_value_3',
- 'portal-addr': 'test_value_4',
- 'portal-addr6': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('firewall', 'auth-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_auth_portal_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_auth_portal': {'identity_based_route': 'test_value_3',
- 'portal_addr': 'test_value_4',
- 'portal_addr6': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_auth_portal.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'identity-based-route': 'test_value_3',
- 'portal-addr': 'test_value_4',
- 'portal-addr6': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('firewall', 'auth-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_auth_portal_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_auth_portal': {
- 'random_attribute_not_valid': 'tag', 'identity_based_route': 'test_value_3',
- 'portal_addr': 'test_value_4',
- 'portal_addr6': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_auth_portal.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'identity-based-route': 'test_value_3',
- 'portal-addr': 'test_value_4',
- 'portal-addr6': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('firewall', 'auth-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_central_snat_map.py b/test/units/modules/network/fortios/test_fortios_firewall_central_snat_map.py
deleted file mode 100644
index 4f808d45b8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_central_snat_map.py
+++ /dev/null
@@ -1,259 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_central_snat_map
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_central_snat_map.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_central_snat_map_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_central_snat_map': {
- 'comments': 'test_value_3',
- 'nat': 'disable',
- 'nat_port': 'test_value_5',
- 'orig_port': 'test_value_6',
- 'policyid': '7',
- 'protocol': '8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_central_snat_map.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'nat': 'disable',
- 'nat-port': 'test_value_5',
- 'orig-port': 'test_value_6',
- 'policyid': '7',
- 'protocol': '8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'central-snat-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_central_snat_map_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_central_snat_map': {
- 'comments': 'test_value_3',
- 'nat': 'disable',
- 'nat_port': 'test_value_5',
- 'orig_port': 'test_value_6',
- 'policyid': '7',
- 'protocol': '8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_central_snat_map.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'nat': 'disable',
- 'nat-port': 'test_value_5',
- 'orig-port': 'test_value_6',
- 'policyid': '7',
- 'protocol': '8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'central-snat-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_central_snat_map_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_central_snat_map': {
- 'comments': 'test_value_3',
- 'nat': 'disable',
- 'nat_port': 'test_value_5',
- 'orig_port': 'test_value_6',
- 'policyid': '7',
- 'protocol': '8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_central_snat_map.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'central-snat-map', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_central_snat_map_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_central_snat_map': {
- 'comments': 'test_value_3',
- 'nat': 'disable',
- 'nat_port': 'test_value_5',
- 'orig_port': 'test_value_6',
- 'policyid': '7',
- 'protocol': '8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_central_snat_map.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'central-snat-map', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_central_snat_map_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_central_snat_map': {
- 'comments': 'test_value_3',
- 'nat': 'disable',
- 'nat_port': 'test_value_5',
- 'orig_port': 'test_value_6',
- 'policyid': '7',
- 'protocol': '8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_central_snat_map.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'nat': 'disable',
- 'nat-port': 'test_value_5',
- 'orig-port': 'test_value_6',
- 'policyid': '7',
- 'protocol': '8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'central-snat-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_central_snat_map_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_central_snat_map': {
- 'random_attribute_not_valid': 'tag',
- 'comments': 'test_value_3',
- 'nat': 'disable',
- 'nat_port': 'test_value_5',
- 'orig_port': 'test_value_6',
- 'policyid': '7',
- 'protocol': '8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_central_snat_map.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'nat': 'disable',
- 'nat-port': 'test_value_5',
- 'orig-port': 'test_value_6',
- 'policyid': '7',
- 'protocol': '8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'central-snat-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_dnstranslation.py b/test/units/modules/network/fortios/test_fortios_firewall_dnstranslation.py
deleted file mode 100644
index c0edb64c39..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_dnstranslation.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_dnstranslation
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_dnstranslation.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_dnstranslation_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_dnstranslation': {
- 'dst': 'test_value_3',
- 'id': '4',
- 'netmask': 'test_value_5',
- 'src': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_dnstranslation.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'dst': 'test_value_3',
- 'id': '4',
- 'netmask': 'test_value_5',
- 'src': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'dnstranslation', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_dnstranslation_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_dnstranslation': {
- 'dst': 'test_value_3',
- 'id': '4',
- 'netmask': 'test_value_5',
- 'src': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_dnstranslation.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'dst': 'test_value_3',
- 'id': '4',
- 'netmask': 'test_value_5',
- 'src': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'dnstranslation', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_dnstranslation_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_dnstranslation': {
- 'dst': 'test_value_3',
- 'id': '4',
- 'netmask': 'test_value_5',
- 'src': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_dnstranslation.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'dnstranslation', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_dnstranslation_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_dnstranslation': {
- 'dst': 'test_value_3',
- 'id': '4',
- 'netmask': 'test_value_5',
- 'src': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_dnstranslation.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'dnstranslation', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_dnstranslation_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_dnstranslation': {
- 'dst': 'test_value_3',
- 'id': '4',
- 'netmask': 'test_value_5',
- 'src': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_dnstranslation.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'dst': 'test_value_3',
- 'id': '4',
- 'netmask': 'test_value_5',
- 'src': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'dnstranslation', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_dnstranslation_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_dnstranslation': {
- 'random_attribute_not_valid': 'tag',
- 'dst': 'test_value_3',
- 'id': '4',
- 'netmask': 'test_value_5',
- 'src': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_dnstranslation.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'dst': 'test_value_3',
- 'id': '4',
- 'netmask': 'test_value_5',
- 'src': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'dnstranslation', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_identity_based_route.py b/test/units/modules/network/fortios/test_fortios_firewall_identity_based_route.py
deleted file mode 100644
index 08d12c3245..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_identity_based_route.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_identity_based_route
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_identity_based_route.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_identity_based_route_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_identity_based_route': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_identity_based_route.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'identity-based-route', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_identity_based_route_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_identity_based_route': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_identity_based_route.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'identity-based-route', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_identity_based_route_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_identity_based_route': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_identity_based_route.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'identity-based-route', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_identity_based_route_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_identity_based_route': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_identity_based_route.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'identity-based-route', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_identity_based_route_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_identity_based_route': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_identity_based_route.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'identity-based-route', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_identity_based_route_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_identity_based_route': {
- 'random_attribute_not_valid': 'tag',
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_identity_based_route.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'identity-based-route', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_interface_policy.py b/test/units/modules/network/fortios/test_fortios_firewall_interface_policy.py
deleted file mode 100644
index 2ca1bd76ae..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_interface_policy.py
+++ /dev/null
@@ -1,399 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_interface_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_interface_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_interface_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_interface_policy': {
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'address-type': 'ipv4',
- 'application-list': 'test_value_4',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_6',
- 'av-profile-status': 'enable',
- 'comments': 'test_value_8',
- 'dlp-sensor': 'test_value_9',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips-sensor': 'test_value_13',
- 'ips-sensor-status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_19',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'webfilter-profile': 'test_value_22',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'interface-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_interface_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_interface_policy': {
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'address-type': 'ipv4',
- 'application-list': 'test_value_4',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_6',
- 'av-profile-status': 'enable',
- 'comments': 'test_value_8',
- 'dlp-sensor': 'test_value_9',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips-sensor': 'test_value_13',
- 'ips-sensor-status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_19',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'webfilter-profile': 'test_value_22',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'interface-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_interface_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_interface_policy': {
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'interface-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_interface_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_interface_policy': {
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'interface-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_interface_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_interface_policy': {
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'address-type': 'ipv4',
- 'application-list': 'test_value_4',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_6',
- 'av-profile-status': 'enable',
- 'comments': 'test_value_8',
- 'dlp-sensor': 'test_value_9',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips-sensor': 'test_value_13',
- 'ips-sensor-status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_19',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'webfilter-profile': 'test_value_22',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'interface-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_interface_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_interface_policy': {
- 'random_attribute_not_valid': 'tag',
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'address-type': 'ipv4',
- 'application-list': 'test_value_4',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_6',
- 'av-profile-status': 'enable',
- 'comments': 'test_value_8',
- 'dlp-sensor': 'test_value_9',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips-sensor': 'test_value_13',
- 'ips-sensor-status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_19',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'webfilter-profile': 'test_value_22',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'interface-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_interface_policy6.py b/test/units/modules/network/fortios/test_fortios_firewall_interface_policy6.py
deleted file mode 100644
index ab4d81af05..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_interface_policy6.py
+++ /dev/null
@@ -1,399 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_interface_policy6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_interface_policy6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_interface_policy6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_interface_policy6': {
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'address-type': 'ipv4',
- 'application-list': 'test_value_4',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_6',
- 'av-profile-status': 'enable',
- 'comments': 'test_value_8',
- 'dlp-sensor': 'test_value_9',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips-sensor': 'test_value_13',
- 'ips-sensor-status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_19',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'webfilter-profile': 'test_value_22',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'interface-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_interface_policy6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_interface_policy6': {
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'address-type': 'ipv4',
- 'application-list': 'test_value_4',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_6',
- 'av-profile-status': 'enable',
- 'comments': 'test_value_8',
- 'dlp-sensor': 'test_value_9',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips-sensor': 'test_value_13',
- 'ips-sensor-status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_19',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'webfilter-profile': 'test_value_22',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'interface-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_interface_policy6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_interface_policy6': {
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'interface-policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_interface_policy6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_interface_policy6': {
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'interface-policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_interface_policy6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_interface_policy6': {
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'address-type': 'ipv4',
- 'application-list': 'test_value_4',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_6',
- 'av-profile-status': 'enable',
- 'comments': 'test_value_8',
- 'dlp-sensor': 'test_value_9',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips-sensor': 'test_value_13',
- 'ips-sensor-status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_19',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'webfilter-profile': 'test_value_22',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'interface-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_interface_policy6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_interface_policy6': {
- 'random_attribute_not_valid': 'tag',
- 'address_type': 'ipv4',
- 'application_list': 'test_value_4',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_6',
- 'av_profile_status': 'enable',
- 'comments': 'test_value_8',
- 'dlp_sensor': 'test_value_9',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips_sensor': 'test_value_13',
- 'ips_sensor_status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_19',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'webfilter_profile': 'test_value_22',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_interface_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'address-type': 'ipv4',
- 'application-list': 'test_value_4',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_6',
- 'av-profile-status': 'enable',
- 'comments': 'test_value_8',
- 'dlp-sensor': 'test_value_9',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'interface': 'test_value_12',
- 'ips-sensor': 'test_value_13',
- 'ips-sensor-status': 'enable',
- 'label': 'test_value_15',
- 'logtraffic': 'all',
- 'policyid': '17',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_19',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'webfilter-profile': 'test_value_22',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'interface-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_internet_service.py b/test/units/modules/network/fortios/test_fortios_firewall_internet_service.py
deleted file mode 100644
index 992ba5c780..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_internet_service.py
+++ /dev/null
@@ -1,269 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_internet_service
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_internet_service.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_internet_service_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service': {
- 'database': 'isdb',
- 'direction': 'src',
- 'icon_id': '5',
- 'id': '6',
- 'name': 'default_name_7',
- 'offset': '8',
- 'reputation': '9',
- 'sld_id': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'database': 'isdb',
- 'direction': 'src',
- 'icon-id': '5',
- 'id': '6',
- 'name': 'default_name_7',
- 'offset': '8',
- 'reputation': '9',
- 'sld-id': '10'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_internet_service_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service': {
- 'database': 'isdb',
- 'direction': 'src',
- 'icon_id': '5',
- 'id': '6',
- 'name': 'default_name_7',
- 'offset': '8',
- 'reputation': '9',
- 'sld_id': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'database': 'isdb',
- 'direction': 'src',
- 'icon-id': '5',
- 'id': '6',
- 'name': 'default_name_7',
- 'offset': '8',
- 'reputation': '9',
- 'sld-id': '10'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_internet_service_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_internet_service': {
- 'database': 'isdb',
- 'direction': 'src',
- 'icon_id': '5',
- 'id': '6',
- 'name': 'default_name_7',
- 'offset': '8',
- 'reputation': '9',
- 'sld_id': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'internet-service', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_internet_service_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_internet_service': {
- 'database': 'isdb',
- 'direction': 'src',
- 'icon_id': '5',
- 'id': '6',
- 'name': 'default_name_7',
- 'offset': '8',
- 'reputation': '9',
- 'sld_id': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'internet-service', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_internet_service_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service': {
- 'database': 'isdb',
- 'direction': 'src',
- 'icon_id': '5',
- 'id': '6',
- 'name': 'default_name_7',
- 'offset': '8',
- 'reputation': '9',
- 'sld_id': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'database': 'isdb',
- 'direction': 'src',
- 'icon-id': '5',
- 'id': '6',
- 'name': 'default_name_7',
- 'offset': '8',
- 'reputation': '9',
- 'sld-id': '10'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_internet_service_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service': {
- 'random_attribute_not_valid': 'tag',
- 'database': 'isdb',
- 'direction': 'src',
- 'icon_id': '5',
- 'id': '6',
- 'name': 'default_name_7',
- 'offset': '8',
- 'reputation': '9',
- 'sld_id': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'database': 'isdb',
- 'direction': 'src',
- 'icon-id': '5',
- 'id': '6',
- 'name': 'default_name_7',
- 'offset': '8',
- 'reputation': '9',
- 'sld-id': '10'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_internet_service_custom.py b/test/units/modules/network/fortios/test_fortios_firewall_internet_service_custom.py
deleted file mode 100644
index ecb04b2bba..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_internet_service_custom.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_internet_service_custom
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_internet_service_custom.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_internet_service_custom_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service_custom': {
- 'comment': 'Comment.',
- 'master_service_id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_custom.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'master-service-id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service-custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_internet_service_custom_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service_custom': {
- 'comment': 'Comment.',
- 'master_service_id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_custom.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'master-service-id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service-custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_internet_service_custom_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_internet_service_custom': {
- 'comment': 'Comment.',
- 'master_service_id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_custom.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'internet-service-custom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_internet_service_custom_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_internet_service_custom': {
- 'comment': 'Comment.',
- 'master_service_id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_custom.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'internet-service-custom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_internet_service_custom_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service_custom': {
- 'comment': 'Comment.',
- 'master_service_id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_custom.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'master-service-id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service-custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_internet_service_custom_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service_custom': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'master_service_id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_custom.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'master-service-id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service-custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_internet_service_group.py b/test/units/modules/network/fortios/test_fortios_firewall_internet_service_group.py
deleted file mode 100644
index 897cf1d891..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_internet_service_group.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_internet_service_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_internet_service_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_internet_service_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_group.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_internet_service_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_group.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_internet_service_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_internet_service_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_group.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'internet-service-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_internet_service_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_internet_service_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_group.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'internet-service-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_internet_service_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_group.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_internet_service_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_internet_service_group': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_internet_service_group.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall', 'internet-service-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ip_translation.py b/test/units/modules/network/fortios/test_fortios_firewall_ip_translation.py
deleted file mode 100644
index 66feef8714..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ip_translation.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ip_translation
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ip_translation.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ip_translation_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ip_translation': {
- 'endip': 'test_value_3',
- 'map_startip': 'test_value_4',
- 'startip': 'test_value_5',
- 'transid': '6',
- 'type': 'SCTP'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ip_translation.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'endip': 'test_value_3',
- 'map-startip': 'test_value_4',
- 'startip': 'test_value_5',
- 'transid': '6',
- 'type': 'SCTP'
- }
-
- set_method_mock.assert_called_with('firewall', 'ip-translation', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ip_translation_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ip_translation': {
- 'endip': 'test_value_3',
- 'map_startip': 'test_value_4',
- 'startip': 'test_value_5',
- 'transid': '6',
- 'type': 'SCTP'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ip_translation.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'endip': 'test_value_3',
- 'map-startip': 'test_value_4',
- 'startip': 'test_value_5',
- 'transid': '6',
- 'type': 'SCTP'
- }
-
- set_method_mock.assert_called_with('firewall', 'ip-translation', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ip_translation_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ip_translation': {
- 'endip': 'test_value_3',
- 'map_startip': 'test_value_4',
- 'startip': 'test_value_5',
- 'transid': '6',
- 'type': 'SCTP'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ip_translation.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ip-translation', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ip_translation_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ip_translation': {
- 'endip': 'test_value_3',
- 'map_startip': 'test_value_4',
- 'startip': 'test_value_5',
- 'transid': '6',
- 'type': 'SCTP'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ip_translation.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ip-translation', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ip_translation_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ip_translation': {
- 'endip': 'test_value_3',
- 'map_startip': 'test_value_4',
- 'startip': 'test_value_5',
- 'transid': '6',
- 'type': 'SCTP'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ip_translation.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'endip': 'test_value_3',
- 'map-startip': 'test_value_4',
- 'startip': 'test_value_5',
- 'transid': '6',
- 'type': 'SCTP'
- }
-
- set_method_mock.assert_called_with('firewall', 'ip-translation', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ip_translation_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ip_translation': {
- 'random_attribute_not_valid': 'tag',
- 'endip': 'test_value_3',
- 'map_startip': 'test_value_4',
- 'startip': 'test_value_5',
- 'transid': '6',
- 'type': 'SCTP'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ip_translation.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'endip': 'test_value_3',
- 'map-startip': 'test_value_4',
- 'startip': 'test_value_5',
- 'transid': '6',
- 'type': 'SCTP'
- }
-
- set_method_mock.assert_called_with('firewall', 'ip-translation', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ipmacbinding_setting.py b/test/units/modules/network/fortios/test_fortios_firewall_ipmacbinding_setting.py
deleted file mode 100644
index c5b759a1d7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ipmacbinding_setting.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ipmacbinding_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ipmacbinding_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ipmacbinding_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipmacbinding_setting': {
- 'bindthroughfw': 'enable',
- 'bindtofw': 'enable',
- 'undefinedhost': 'allow'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipmacbinding_setting.fortios_firewall_ipmacbinding(input_data, fos_instance)
-
- expected_data = {
- 'bindthroughfw': 'enable',
- 'bindtofw': 'enable',
- 'undefinedhost': 'allow'
- }
-
- set_method_mock.assert_called_with('firewall.ipmacbinding', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ipmacbinding_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipmacbinding_setting': {
- 'bindthroughfw': 'enable',
- 'bindtofw': 'enable',
- 'undefinedhost': 'allow'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipmacbinding_setting.fortios_firewall_ipmacbinding(input_data, fos_instance)
-
- expected_data = {
- 'bindthroughfw': 'enable',
- 'bindtofw': 'enable',
- 'undefinedhost': 'allow'
- }
-
- set_method_mock.assert_called_with('firewall.ipmacbinding', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ipmacbinding_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipmacbinding_setting': {
- 'bindthroughfw': 'enable',
- 'bindtofw': 'enable',
- 'undefinedhost': 'allow'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipmacbinding_setting.fortios_firewall_ipmacbinding(input_data, fos_instance)
-
- expected_data = {
- 'bindthroughfw': 'enable',
- 'bindtofw': 'enable',
- 'undefinedhost': 'allow'
- }
-
- set_method_mock.assert_called_with('firewall.ipmacbinding', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ipmacbinding_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipmacbinding_setting': {
- 'random_attribute_not_valid': 'tag',
- 'bindthroughfw': 'enable',
- 'bindtofw': 'enable',
- 'undefinedhost': 'allow'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipmacbinding_setting.fortios_firewall_ipmacbinding(input_data, fos_instance)
-
- expected_data = {
- 'bindthroughfw': 'enable',
- 'bindtofw': 'enable',
- 'undefinedhost': 'allow'
- }
-
- set_method_mock.assert_called_with('firewall.ipmacbinding', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ipmacbinding_table.py b/test/units/modules/network/fortios/test_fortios_firewall_ipmacbinding_table.py
deleted file mode 100644
index 42ccc7ea22..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ipmacbinding_table.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ipmacbinding_table
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ipmacbinding_table.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ipmacbinding_table_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipmacbinding_table': {
- 'ip': 'test_value_3',
- 'mac': 'test_value_4',
- 'name': 'default_name_5',
- 'seq_num': '6',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipmacbinding_table.fortios_firewall_ipmacbinding(input_data, fos_instance)
-
- expected_data = {
- 'ip': 'test_value_3',
- 'mac': 'test_value_4',
- 'name': 'default_name_5',
- 'seq-num': '6',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.ipmacbinding', 'table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ipmacbinding_table_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipmacbinding_table': {
- 'ip': 'test_value_3',
- 'mac': 'test_value_4',
- 'name': 'default_name_5',
- 'seq_num': '6',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipmacbinding_table.fortios_firewall_ipmacbinding(input_data, fos_instance)
-
- expected_data = {
- 'ip': 'test_value_3',
- 'mac': 'test_value_4',
- 'name': 'default_name_5',
- 'seq-num': '6',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.ipmacbinding', 'table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ipmacbinding_table_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ipmacbinding_table': {
- 'ip': 'test_value_3',
- 'mac': 'test_value_4',
- 'name': 'default_name_5',
- 'seq_num': '6',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipmacbinding_table.fortios_firewall_ipmacbinding(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.ipmacbinding', 'table', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ipmacbinding_table_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ipmacbinding_table': {
- 'ip': 'test_value_3',
- 'mac': 'test_value_4',
- 'name': 'default_name_5',
- 'seq_num': '6',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipmacbinding_table.fortios_firewall_ipmacbinding(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.ipmacbinding', 'table', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ipmacbinding_table_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipmacbinding_table': {
- 'ip': 'test_value_3',
- 'mac': 'test_value_4',
- 'name': 'default_name_5',
- 'seq_num': '6',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipmacbinding_table.fortios_firewall_ipmacbinding(input_data, fos_instance)
-
- expected_data = {
- 'ip': 'test_value_3',
- 'mac': 'test_value_4',
- 'name': 'default_name_5',
- 'seq-num': '6',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.ipmacbinding', 'table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ipmacbinding_table_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipmacbinding_table': {
- 'random_attribute_not_valid': 'tag',
- 'ip': 'test_value_3',
- 'mac': 'test_value_4',
- 'name': 'default_name_5',
- 'seq_num': '6',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipmacbinding_table.fortios_firewall_ipmacbinding(input_data, fos_instance)
-
- expected_data = {
- 'ip': 'test_value_3',
- 'mac': 'test_value_4',
- 'name': 'default_name_5',
- 'seq-num': '6',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.ipmacbinding', 'table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ippool.py b/test/units/modules/network/fortios/test_fortios_firewall_ippool.py
deleted file mode 100644
index 607ba97222..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ippool.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ippool
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ippool.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ippool_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ippool': {
- 'arp_intf': 'test_value_3',
- 'arp_reply': 'disable',
- 'associated_interface': 'test_value_5',
- 'block_size': '6',
- 'comments': 'test_value_7',
- 'endip': 'test_value_8',
- 'name': 'default_name_9',
- 'num_blocks_per_user': '10',
- 'pba_timeout': '11',
- 'permit_any_host': 'disable',
- 'source_endip': 'test_value_13',
- 'source_startip': 'test_value_14',
- 'startip': 'test_value_15',
- 'type': 'overload'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-intf': 'test_value_3',
- 'arp-reply': 'disable',
- 'associated-interface': 'test_value_5',
- 'block-size': '6',
- 'comments': 'test_value_7',
- 'endip': 'test_value_8',
- 'name': 'default_name_9',
- 'num-blocks-per-user': '10',
- 'pba-timeout': '11',
- 'permit-any-host': 'disable',
- 'source-endip': 'test_value_13',
- 'source-startip': 'test_value_14',
- 'startip': 'test_value_15',
- 'type': 'overload'
- }
-
- set_method_mock.assert_called_with('firewall', 'ippool', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ippool_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ippool': {
- 'arp_intf': 'test_value_3',
- 'arp_reply': 'disable',
- 'associated_interface': 'test_value_5',
- 'block_size': '6',
- 'comments': 'test_value_7',
- 'endip': 'test_value_8',
- 'name': 'default_name_9',
- 'num_blocks_per_user': '10',
- 'pba_timeout': '11',
- 'permit_any_host': 'disable',
- 'source_endip': 'test_value_13',
- 'source_startip': 'test_value_14',
- 'startip': 'test_value_15',
- 'type': 'overload'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-intf': 'test_value_3',
- 'arp-reply': 'disable',
- 'associated-interface': 'test_value_5',
- 'block-size': '6',
- 'comments': 'test_value_7',
- 'endip': 'test_value_8',
- 'name': 'default_name_9',
- 'num-blocks-per-user': '10',
- 'pba-timeout': '11',
- 'permit-any-host': 'disable',
- 'source-endip': 'test_value_13',
- 'source-startip': 'test_value_14',
- 'startip': 'test_value_15',
- 'type': 'overload'
- }
-
- set_method_mock.assert_called_with('firewall', 'ippool', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ippool_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ippool': {
- 'arp_intf': 'test_value_3',
- 'arp_reply': 'disable',
- 'associated_interface': 'test_value_5',
- 'block_size': '6',
- 'comments': 'test_value_7',
- 'endip': 'test_value_8',
- 'name': 'default_name_9',
- 'num_blocks_per_user': '10',
- 'pba_timeout': '11',
- 'permit_any_host': 'disable',
- 'source_endip': 'test_value_13',
- 'source_startip': 'test_value_14',
- 'startip': 'test_value_15',
- 'type': 'overload'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ippool', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ippool_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ippool': {
- 'arp_intf': 'test_value_3',
- 'arp_reply': 'disable',
- 'associated_interface': 'test_value_5',
- 'block_size': '6',
- 'comments': 'test_value_7',
- 'endip': 'test_value_8',
- 'name': 'default_name_9',
- 'num_blocks_per_user': '10',
- 'pba_timeout': '11',
- 'permit_any_host': 'disable',
- 'source_endip': 'test_value_13',
- 'source_startip': 'test_value_14',
- 'startip': 'test_value_15',
- 'type': 'overload'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ippool', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ippool_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ippool': {
- 'arp_intf': 'test_value_3',
- 'arp_reply': 'disable',
- 'associated_interface': 'test_value_5',
- 'block_size': '6',
- 'comments': 'test_value_7',
- 'endip': 'test_value_8',
- 'name': 'default_name_9',
- 'num_blocks_per_user': '10',
- 'pba_timeout': '11',
- 'permit_any_host': 'disable',
- 'source_endip': 'test_value_13',
- 'source_startip': 'test_value_14',
- 'startip': 'test_value_15',
- 'type': 'overload'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-intf': 'test_value_3',
- 'arp-reply': 'disable',
- 'associated-interface': 'test_value_5',
- 'block-size': '6',
- 'comments': 'test_value_7',
- 'endip': 'test_value_8',
- 'name': 'default_name_9',
- 'num-blocks-per-user': '10',
- 'pba-timeout': '11',
- 'permit-any-host': 'disable',
- 'source-endip': 'test_value_13',
- 'source-startip': 'test_value_14',
- 'startip': 'test_value_15',
- 'type': 'overload'
- }
-
- set_method_mock.assert_called_with('firewall', 'ippool', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ippool_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ippool': {
- 'random_attribute_not_valid': 'tag',
- 'arp_intf': 'test_value_3',
- 'arp_reply': 'disable',
- 'associated_interface': 'test_value_5',
- 'block_size': '6',
- 'comments': 'test_value_7',
- 'endip': 'test_value_8',
- 'name': 'default_name_9',
- 'num_blocks_per_user': '10',
- 'pba_timeout': '11',
- 'permit_any_host': 'disable',
- 'source_endip': 'test_value_13',
- 'source_startip': 'test_value_14',
- 'startip': 'test_value_15',
- 'type': 'overload'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-intf': 'test_value_3',
- 'arp-reply': 'disable',
- 'associated-interface': 'test_value_5',
- 'block-size': '6',
- 'comments': 'test_value_7',
- 'endip': 'test_value_8',
- 'name': 'default_name_9',
- 'num-blocks-per-user': '10',
- 'pba-timeout': '11',
- 'permit-any-host': 'disable',
- 'source-endip': 'test_value_13',
- 'source-startip': 'test_value_14',
- 'startip': 'test_value_15',
- 'type': 'overload'
- }
-
- set_method_mock.assert_called_with('firewall', 'ippool', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ippool6.py b/test/units/modules/network/fortios/test_fortios_firewall_ippool6.py
deleted file mode 100644
index 69158059f7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ippool6.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ippool6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ippool6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ippool6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ippool6': {
- 'comments': 'test_value_3',
- 'endip': 'test_value_4',
- 'name': 'default_name_5',
- 'startip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'endip': 'test_value_4',
- 'name': 'default_name_5',
- 'startip': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'ippool6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ippool6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ippool6': {
- 'comments': 'test_value_3',
- 'endip': 'test_value_4',
- 'name': 'default_name_5',
- 'startip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'endip': 'test_value_4',
- 'name': 'default_name_5',
- 'startip': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'ippool6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ippool6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ippool6': {
- 'comments': 'test_value_3',
- 'endip': 'test_value_4',
- 'name': 'default_name_5',
- 'startip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ippool6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ippool6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ippool6': {
- 'comments': 'test_value_3',
- 'endip': 'test_value_4',
- 'name': 'default_name_5',
- 'startip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ippool6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ippool6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ippool6': {
- 'comments': 'test_value_3',
- 'endip': 'test_value_4',
- 'name': 'default_name_5',
- 'startip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'endip': 'test_value_4',
- 'name': 'default_name_5',
- 'startip': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'ippool6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ippool6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ippool6': {
- 'random_attribute_not_valid': 'tag',
- 'comments': 'test_value_3',
- 'endip': 'test_value_4',
- 'name': 'default_name_5',
- 'startip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ippool6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'endip': 'test_value_4',
- 'name': 'default_name_5',
- 'startip': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'ippool6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ipv6_eh_filter.py b/test/units/modules/network/fortios/test_fortios_firewall_ipv6_eh_filter.py
deleted file mode 100644
index f851a789ba..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ipv6_eh_filter.py
+++ /dev/null
@@ -1,207 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ipv6_eh_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ipv6_eh_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ipv6_eh_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipv6_eh_filter': {
- 'auth': 'enable',
- 'dest_opt': 'enable',
- 'fragment': 'enable',
- 'hdopt_type': '6',
- 'hop_opt': 'enable',
- 'no_next': 'enable',
- 'routing': 'enable',
- 'routing_type': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipv6_eh_filter.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'auth': 'enable',
- 'dest-opt': 'enable',
- 'fragment': 'enable',
- 'hdopt-type': '6',
- 'hop-opt': 'enable',
- 'no-next': 'enable',
- 'routing': 'enable',
- 'routing-type': '10'
- }
-
- set_method_mock.assert_called_with('firewall', 'ipv6-eh-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ipv6_eh_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipv6_eh_filter': {
- 'auth': 'enable',
- 'dest_opt': 'enable',
- 'fragment': 'enable',
- 'hdopt_type': '6',
- 'hop_opt': 'enable',
- 'no_next': 'enable',
- 'routing': 'enable',
- 'routing_type': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipv6_eh_filter.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'auth': 'enable',
- 'dest-opt': 'enable',
- 'fragment': 'enable',
- 'hdopt-type': '6',
- 'hop-opt': 'enable',
- 'no-next': 'enable',
- 'routing': 'enable',
- 'routing-type': '10'
- }
-
- set_method_mock.assert_called_with('firewall', 'ipv6-eh-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ipv6_eh_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipv6_eh_filter': {
- 'auth': 'enable',
- 'dest_opt': 'enable',
- 'fragment': 'enable',
- 'hdopt_type': '6',
- 'hop_opt': 'enable',
- 'no_next': 'enable',
- 'routing': 'enable',
- 'routing_type': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipv6_eh_filter.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'auth': 'enable',
- 'dest-opt': 'enable',
- 'fragment': 'enable',
- 'hdopt-type': '6',
- 'hop-opt': 'enable',
- 'no-next': 'enable',
- 'routing': 'enable',
- 'routing-type': '10'
- }
-
- set_method_mock.assert_called_with('firewall', 'ipv6-eh-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ipv6_eh_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ipv6_eh_filter': {
- 'random_attribute_not_valid': 'tag',
- 'auth': 'enable',
- 'dest_opt': 'enable',
- 'fragment': 'enable',
- 'hdopt_type': '6',
- 'hop_opt': 'enable',
- 'no_next': 'enable',
- 'routing': 'enable',
- 'routing_type': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ipv6_eh_filter.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'auth': 'enable',
- 'dest-opt': 'enable',
- 'fragment': 'enable',
- 'hdopt-type': '6',
- 'hop-opt': 'enable',
- 'no-next': 'enable',
- 'routing': 'enable',
- 'routing-type': '10'
- }
-
- set_method_mock.assert_called_with('firewall', 'ipv6-eh-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ldb_monitor.py b/test/units/modules/network/fortios/test_fortios_firewall_ldb_monitor.py
deleted file mode 100644
index ecd1396ee3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ldb_monitor.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ldb_monitor
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ldb_monitor.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ldb_monitor_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ldb_monitor': {
- 'http_get': 'test_value_3',
- 'http_match': 'test_value_4',
- 'http_max_redirects': '5',
- 'interval': '6',
- 'name': 'default_name_7',
- 'port': '8',
- 'retry': '9',
- 'timeout': '10',
- 'type': 'ping'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ldb_monitor.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'http-get': 'test_value_3',
- 'http-match': 'test_value_4',
- 'http-max-redirects': '5',
- 'interval': '6',
- 'name': 'default_name_7',
- 'port': '8',
- 'retry': '9',
- 'timeout': '10',
- 'type': 'ping'
- }
-
- set_method_mock.assert_called_with('firewall', 'ldb-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ldb_monitor_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ldb_monitor': {
- 'http_get': 'test_value_3',
- 'http_match': 'test_value_4',
- 'http_max_redirects': '5',
- 'interval': '6',
- 'name': 'default_name_7',
- 'port': '8',
- 'retry': '9',
- 'timeout': '10',
- 'type': 'ping'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ldb_monitor.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'http-get': 'test_value_3',
- 'http-match': 'test_value_4',
- 'http-max-redirects': '5',
- 'interval': '6',
- 'name': 'default_name_7',
- 'port': '8',
- 'retry': '9',
- 'timeout': '10',
- 'type': 'ping'
- }
-
- set_method_mock.assert_called_with('firewall', 'ldb-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ldb_monitor_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ldb_monitor': {
- 'http_get': 'test_value_3',
- 'http_match': 'test_value_4',
- 'http_max_redirects': '5',
- 'interval': '6',
- 'name': 'default_name_7',
- 'port': '8',
- 'retry': '9',
- 'timeout': '10',
- 'type': 'ping'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ldb_monitor.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ldb-monitor', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ldb_monitor_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ldb_monitor': {
- 'http_get': 'test_value_3',
- 'http_match': 'test_value_4',
- 'http_max_redirects': '5',
- 'interval': '6',
- 'name': 'default_name_7',
- 'port': '8',
- 'retry': '9',
- 'timeout': '10',
- 'type': 'ping'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ldb_monitor.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ldb-monitor', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ldb_monitor_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ldb_monitor': {
- 'http_get': 'test_value_3',
- 'http_match': 'test_value_4',
- 'http_max_redirects': '5',
- 'interval': '6',
- 'name': 'default_name_7',
- 'port': '8',
- 'retry': '9',
- 'timeout': '10',
- 'type': 'ping'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ldb_monitor.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'http-get': 'test_value_3',
- 'http-match': 'test_value_4',
- 'http-max-redirects': '5',
- 'interval': '6',
- 'name': 'default_name_7',
- 'port': '8',
- 'retry': '9',
- 'timeout': '10',
- 'type': 'ping'
- }
-
- set_method_mock.assert_called_with('firewall', 'ldb-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ldb_monitor_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ldb_monitor': {
- 'random_attribute_not_valid': 'tag',
- 'http_get': 'test_value_3',
- 'http_match': 'test_value_4',
- 'http_max_redirects': '5',
- 'interval': '6',
- 'name': 'default_name_7',
- 'port': '8',
- 'retry': '9',
- 'timeout': '10',
- 'type': 'ping'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ldb_monitor.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'http-get': 'test_value_3',
- 'http-match': 'test_value_4',
- 'http-max-redirects': '5',
- 'interval': '6',
- 'name': 'default_name_7',
- 'port': '8',
- 'retry': '9',
- 'timeout': '10',
- 'type': 'ping'
- }
-
- set_method_mock.assert_called_with('firewall', 'ldb-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_local_in_policy.py b/test/units/modules/network/fortios/test_fortios_firewall_local_in_policy.py
deleted file mode 100644
index 12f43ffe6e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_local_in_policy.py
+++ /dev/null
@@ -1,259 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_local_in_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_local_in_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_local_in_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_local_in_policy': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'ha_mgmt_intf_only': 'enable',
- 'intf': 'test_value_6',
- 'policyid': '7',
- 'schedule': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'ha-mgmt-intf-only': 'enable',
- 'intf': 'test_value_6',
- 'policyid': '7',
- 'schedule': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'local-in-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_local_in_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_local_in_policy': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'ha_mgmt_intf_only': 'enable',
- 'intf': 'test_value_6',
- 'policyid': '7',
- 'schedule': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'ha-mgmt-intf-only': 'enable',
- 'intf': 'test_value_6',
- 'policyid': '7',
- 'schedule': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'local-in-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_local_in_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_local_in_policy': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'ha_mgmt_intf_only': 'enable',
- 'intf': 'test_value_6',
- 'policyid': '7',
- 'schedule': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'local-in-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_local_in_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_local_in_policy': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'ha_mgmt_intf_only': 'enable',
- 'intf': 'test_value_6',
- 'policyid': '7',
- 'schedule': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'local-in-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_local_in_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_local_in_policy': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'ha_mgmt_intf_only': 'enable',
- 'intf': 'test_value_6',
- 'policyid': '7',
- 'schedule': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'ha-mgmt-intf-only': 'enable',
- 'intf': 'test_value_6',
- 'policyid': '7',
- 'schedule': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'local-in-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_local_in_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_local_in_policy': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'ha_mgmt_intf_only': 'enable',
- 'intf': 'test_value_6',
- 'policyid': '7',
- 'schedule': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'ha-mgmt-intf-only': 'enable',
- 'intf': 'test_value_6',
- 'policyid': '7',
- 'schedule': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'local-in-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_local_in_policy6.py b/test/units/modules/network/fortios/test_fortios_firewall_local_in_policy6.py
deleted file mode 100644
index 398ca1d418..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_local_in_policy6.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_local_in_policy6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_local_in_policy6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_local_in_policy6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_local_in_policy6': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'intf': 'test_value_5',
- 'policyid': '6',
- 'schedule': 'test_value_7',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'intf': 'test_value_5',
- 'policyid': '6',
- 'schedule': 'test_value_7',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'local-in-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_local_in_policy6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_local_in_policy6': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'intf': 'test_value_5',
- 'policyid': '6',
- 'schedule': 'test_value_7',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'intf': 'test_value_5',
- 'policyid': '6',
- 'schedule': 'test_value_7',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'local-in-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_local_in_policy6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_local_in_policy6': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'intf': 'test_value_5',
- 'policyid': '6',
- 'schedule': 'test_value_7',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'local-in-policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_local_in_policy6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_local_in_policy6': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'intf': 'test_value_5',
- 'policyid': '6',
- 'schedule': 'test_value_7',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'local-in-policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_local_in_policy6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_local_in_policy6': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'intf': 'test_value_5',
- 'policyid': '6',
- 'schedule': 'test_value_7',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'intf': 'test_value_5',
- 'policyid': '6',
- 'schedule': 'test_value_7',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'local-in-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_local_in_policy6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_local_in_policy6': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'intf': 'test_value_5',
- 'policyid': '6',
- 'schedule': 'test_value_7',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_local_in_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'intf': 'test_value_5',
- 'policyid': '6',
- 'schedule': 'test_value_7',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'local-in-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_multicast_address.py b/test/units/modules/network/fortios/test_fortios_firewall_multicast_address.py
deleted file mode 100644
index eefb547de9..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_multicast_address.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_multicast_address
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_multicast_address.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_multicast_address_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_address': {
- 'associated_interface': 'test_value_3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'name': 'default_name_7',
- 'start_ip': 'test_value_8',
- 'subnet': 'test_value_9',
- 'type': 'multicastrange',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'associated-interface': 'test_value_3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end-ip': 'test_value_6',
- 'name': 'default_name_7',
- 'start-ip': 'test_value_8',
- 'subnet': 'test_value_9',
- 'type': 'multicastrange',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_multicast_address_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_address': {
- 'associated_interface': 'test_value_3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'name': 'default_name_7',
- 'start_ip': 'test_value_8',
- 'subnet': 'test_value_9',
- 'type': 'multicastrange',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'associated-interface': 'test_value_3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end-ip': 'test_value_6',
- 'name': 'default_name_7',
- 'start-ip': 'test_value_8',
- 'subnet': 'test_value_9',
- 'type': 'multicastrange',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_multicast_address_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_multicast_address': {
- 'associated_interface': 'test_value_3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'name': 'default_name_7',
- 'start_ip': 'test_value_8',
- 'subnet': 'test_value_9',
- 'type': 'multicastrange',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'multicast-address', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_multicast_address_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_multicast_address': {
- 'associated_interface': 'test_value_3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'name': 'default_name_7',
- 'start_ip': 'test_value_8',
- 'subnet': 'test_value_9',
- 'type': 'multicastrange',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'multicast-address', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_multicast_address_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_address': {
- 'associated_interface': 'test_value_3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'name': 'default_name_7',
- 'start_ip': 'test_value_8',
- 'subnet': 'test_value_9',
- 'type': 'multicastrange',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'associated-interface': 'test_value_3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end-ip': 'test_value_6',
- 'name': 'default_name_7',
- 'start-ip': 'test_value_8',
- 'subnet': 'test_value_9',
- 'type': 'multicastrange',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_multicast_address_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_address': {
- 'random_attribute_not_valid': 'tag',
- 'associated_interface': 'test_value_3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end_ip': 'test_value_6',
- 'name': 'default_name_7',
- 'start_ip': 'test_value_8',
- 'subnet': 'test_value_9',
- 'type': 'multicastrange',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'associated-interface': 'test_value_3',
- 'color': '4',
- 'comment': 'Comment.',
- 'end-ip': 'test_value_6',
- 'name': 'default_name_7',
- 'start-ip': 'test_value_8',
- 'subnet': 'test_value_9',
- 'type': 'multicastrange',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_multicast_address6.py b/test/units/modules/network/fortios/test_fortios_firewall_multicast_address6.py
deleted file mode 100644
index 02f216671c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_multicast_address6.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_multicast_address6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_multicast_address6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_multicast_address6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_address6': {
- 'color': '3',
- 'comment': 'Comment.',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-address6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_multicast_address6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_address6': {
- 'color': '3',
- 'comment': 'Comment.',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-address6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_multicast_address6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_multicast_address6': {
- 'color': '3',
- 'comment': 'Comment.',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'multicast-address6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_multicast_address6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_multicast_address6': {
- 'color': '3',
- 'comment': 'Comment.',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'multicast-address6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_multicast_address6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_address6': {
- 'color': '3',
- 'comment': 'Comment.',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-address6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_multicast_address6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_address6': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'comment': 'Comment.',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_address6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-address6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_multicast_policy.py b/test/units/modules/network/fortios/test_fortios_firewall_multicast_policy.py
deleted file mode 100644
index 32c97ba581..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_multicast_policy.py
+++ /dev/null
@@ -1,309 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_multicast_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_multicast_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_multicast_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_policy': {
- 'action': 'accept',
- 'dnat': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'end_port': '6',
- 'id': '7',
- 'logtraffic': 'enable',
- 'protocol': '9',
- 'snat': 'enable',
- 'snat_ip': 'test_value_11',
- 'srcintf': 'test_value_12',
- 'start_port': '13',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'dnat': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'end-port': '6',
- 'id': '7',
- 'logtraffic': 'enable',
- 'protocol': '9',
- 'snat': 'enable',
- 'snat-ip': 'test_value_11',
- 'srcintf': 'test_value_12',
- 'start-port': '13',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_multicast_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_policy': {
- 'action': 'accept',
- 'dnat': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'end_port': '6',
- 'id': '7',
- 'logtraffic': 'enable',
- 'protocol': '9',
- 'snat': 'enable',
- 'snat_ip': 'test_value_11',
- 'srcintf': 'test_value_12',
- 'start_port': '13',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'dnat': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'end-port': '6',
- 'id': '7',
- 'logtraffic': 'enable',
- 'protocol': '9',
- 'snat': 'enable',
- 'snat-ip': 'test_value_11',
- 'srcintf': 'test_value_12',
- 'start-port': '13',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_multicast_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_multicast_policy': {
- 'action': 'accept',
- 'dnat': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'end_port': '6',
- 'id': '7',
- 'logtraffic': 'enable',
- 'protocol': '9',
- 'snat': 'enable',
- 'snat_ip': 'test_value_11',
- 'srcintf': 'test_value_12',
- 'start_port': '13',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'multicast-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_multicast_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_multicast_policy': {
- 'action': 'accept',
- 'dnat': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'end_port': '6',
- 'id': '7',
- 'logtraffic': 'enable',
- 'protocol': '9',
- 'snat': 'enable',
- 'snat_ip': 'test_value_11',
- 'srcintf': 'test_value_12',
- 'start_port': '13',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'multicast-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_multicast_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_policy': {
- 'action': 'accept',
- 'dnat': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'end_port': '6',
- 'id': '7',
- 'logtraffic': 'enable',
- 'protocol': '9',
- 'snat': 'enable',
- 'snat_ip': 'test_value_11',
- 'srcintf': 'test_value_12',
- 'start_port': '13',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'dnat': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'end-port': '6',
- 'id': '7',
- 'logtraffic': 'enable',
- 'protocol': '9',
- 'snat': 'enable',
- 'snat-ip': 'test_value_11',
- 'srcintf': 'test_value_12',
- 'start-port': '13',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_multicast_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_policy': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'accept',
- 'dnat': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'end_port': '6',
- 'id': '7',
- 'logtraffic': 'enable',
- 'protocol': '9',
- 'snat': 'enable',
- 'snat_ip': 'test_value_11',
- 'srcintf': 'test_value_12',
- 'start_port': '13',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'dnat': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'end-port': '6',
- 'id': '7',
- 'logtraffic': 'enable',
- 'protocol': '9',
- 'snat': 'enable',
- 'snat-ip': 'test_value_11',
- 'srcintf': 'test_value_12',
- 'start-port': '13',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_multicast_policy6.py b/test/units/modules/network/fortios/test_fortios_firewall_multicast_policy6.py
deleted file mode 100644
index c9e58511a5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_multicast_policy6.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_multicast_policy6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_multicast_policy6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_multicast_policy6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_policy6': {
- 'action': 'accept',
- 'dstintf': 'test_value_4',
- 'end_port': '5',
- 'id': '6',
- 'logtraffic': 'enable',
- 'protocol': '8',
- 'srcintf': 'test_value_9',
- 'start_port': '10',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'dstintf': 'test_value_4',
- 'end-port': '5',
- 'id': '6',
- 'logtraffic': 'enable',
- 'protocol': '8',
- 'srcintf': 'test_value_9',
- 'start-port': '10',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_multicast_policy6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_policy6': {
- 'action': 'accept',
- 'dstintf': 'test_value_4',
- 'end_port': '5',
- 'id': '6',
- 'logtraffic': 'enable',
- 'protocol': '8',
- 'srcintf': 'test_value_9',
- 'start_port': '10',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'dstintf': 'test_value_4',
- 'end-port': '5',
- 'id': '6',
- 'logtraffic': 'enable',
- 'protocol': '8',
- 'srcintf': 'test_value_9',
- 'start-port': '10',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_multicast_policy6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_multicast_policy6': {
- 'action': 'accept',
- 'dstintf': 'test_value_4',
- 'end_port': '5',
- 'id': '6',
- 'logtraffic': 'enable',
- 'protocol': '8',
- 'srcintf': 'test_value_9',
- 'start_port': '10',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'multicast-policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_multicast_policy6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_multicast_policy6': {
- 'action': 'accept',
- 'dstintf': 'test_value_4',
- 'end_port': '5',
- 'id': '6',
- 'logtraffic': 'enable',
- 'protocol': '8',
- 'srcintf': 'test_value_9',
- 'start_port': '10',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'multicast-policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_multicast_policy6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_policy6': {
- 'action': 'accept',
- 'dstintf': 'test_value_4',
- 'end_port': '5',
- 'id': '6',
- 'logtraffic': 'enable',
- 'protocol': '8',
- 'srcintf': 'test_value_9',
- 'start_port': '10',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'dstintf': 'test_value_4',
- 'end-port': '5',
- 'id': '6',
- 'logtraffic': 'enable',
- 'protocol': '8',
- 'srcintf': 'test_value_9',
- 'start-port': '10',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_multicast_policy6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_multicast_policy6': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'accept',
- 'dstintf': 'test_value_4',
- 'end_port': '5',
- 'id': '6',
- 'logtraffic': 'enable',
- 'protocol': '8',
- 'srcintf': 'test_value_9',
- 'start_port': '10',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_multicast_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'dstintf': 'test_value_4',
- 'end-port': '5',
- 'id': '6',
- 'logtraffic': 'enable',
- 'protocol': '8',
- 'srcintf': 'test_value_9',
- 'start-port': '10',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'multicast-policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_policy.py b/test/units/modules/network/fortios/test_fortios_firewall_policy.py
deleted file mode 100644
index 53d7d6c59d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_policy.py
+++ /dev/null
@@ -1,1169 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'auth_cert': 'test_value_5',
- 'auth_path': 'enable',
- 'auth_redirect_addr': 'test_value_7',
- 'av_profile': 'test_value_8',
- 'block_notification': 'enable',
- 'captive_portal_exempt': 'enable',
- 'capture_packet': 'enable',
- 'comments': 'test_value_12',
- 'delay_tcp_npu_session': 'enable',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_16',
- 'diffservcode_rev': 'test_value_17',
- 'disclaimer': 'enable',
- 'dlp_sensor': 'test_value_19',
- 'dnsfilter_profile': 'test_value_20',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_23',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'fsso': 'enable',
- 'fsso_agent_for_ntlm': 'test_value_29',
- 'global_label': 'test_value_30',
- 'icap_profile': 'test_value_31',
- 'identity_based_route': 'test_value_32',
- 'inbound': 'enable',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'internet_service_src': 'enable',
- 'internet_service_src_negate': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_39',
- 'label': 'test_value_40',
- 'learning_mode': 'enable',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'match_vip': 'enable',
- 'name': 'default_name_45',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natip': 'test_value_48',
- 'natoutbound': 'enable',
- 'ntlm': 'enable',
- 'ntlm_guest': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_53',
- 'permit_any_host': 'enable',
- 'permit_stun_host': 'enable',
- 'policyid': '56',
- 'profile_group': 'test_value_57',
- 'profile_protocol_options': 'test_value_58',
- 'profile_type': 'single',
- 'radius_mac_auth_bypass': 'enable',
- 'redirect_url': 'test_value_61',
- 'replacemsg_override_group': 'test_value_62',
- 'rsso': 'enable',
- 'rtp_nat': 'disable',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_66',
- 'schedule_timeout': 'enable',
- 'send_deny_packet': 'disable',
- 'service_negate': 'enable',
- 'session_ttl': '70',
- 'spamfilter_profile': 'test_value_71',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_73',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_75',
- 'status': 'enable',
- 'tcp_mss_receiver': '77',
- 'tcp_mss_sender': '78',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_81',
- 'traffic_shaper_reverse': 'test_value_82',
- 'utm_status': 'enable',
- 'uuid': 'test_value_84',
- 'vlan_cos_fwd': '85',
- 'vlan_cos_rev': '86',
- 'vlan_filter': 'test_value_87',
- 'voip_profile': 'test_value_88',
- 'vpntunnel': 'test_value_89',
- 'waf_profile': 'test_value_90',
- 'wanopt': 'enable',
- 'wanopt_detection': 'active',
- 'wanopt_passive_opt': 'default',
- 'wanopt_peer': 'test_value_94',
- 'wanopt_profile': 'test_value_95',
- 'wccp': 'enable',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_99',
- 'wsso': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'auth-cert': 'test_value_5',
- 'auth-path': 'enable',
- 'auth-redirect-addr': 'test_value_7',
- 'av-profile': 'test_value_8',
- 'block-notification': 'enable',
- 'captive-portal-exempt': 'enable',
- 'capture-packet': 'enable',
- 'comments': 'test_value_12',
- 'delay-tcp-npu-session': 'enable',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_16',
- 'diffservcode-rev': 'test_value_17',
- 'disclaimer': 'enable',
- 'dlp-sensor': 'test_value_19',
- 'dnsfilter-profile': 'test_value_20',
- 'dscp-match': 'enable',
- 'dscp-negate': 'enable',
- 'dscp-value': 'test_value_23',
- 'dsri': 'enable',
- 'dstaddr-negate': 'enable',
- 'firewall-session-dirty': 'check-all',
- 'fixedport': 'enable',
- 'fsso': 'enable',
- 'fsso-agent-for-ntlm': 'test_value_29',
- 'global-label': 'test_value_30',
- 'icap-profile': 'test_value_31',
- 'identity-based-route': 'test_value_32',
- 'inbound': 'enable',
- 'internet-service': 'enable',
- 'internet-service-negate': 'enable',
- 'internet-service-src': 'enable',
- 'internet-service-src-negate': 'enable',
- 'ippool': 'enable',
- 'ips-sensor': 'test_value_39',
- 'label': 'test_value_40',
- 'learning-mode': 'enable',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'match-vip': 'enable',
- 'name': 'default_name_45',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natip': 'test_value_48',
- 'natoutbound': 'enable',
- 'ntlm': 'enable',
- 'ntlm-guest': 'enable',
- 'outbound': 'enable',
- 'per-ip-shaper': 'test_value_53',
- 'permit-any-host': 'enable',
- 'permit-stun-host': 'enable',
- 'policyid': '56',
- 'profile-group': 'test_value_57',
- 'profile-protocol-options': 'test_value_58',
- 'profile-type': 'single',
- 'radius-mac-auth-bypass': 'enable',
- 'redirect-url': 'test_value_61',
- 'replacemsg-override-group': 'test_value_62',
- 'rsso': 'enable',
- 'rtp-nat': 'disable',
- 'scan-botnet-connections': 'disable',
- 'schedule': 'test_value_66',
- 'schedule-timeout': 'enable',
- 'send-deny-packet': 'disable',
- 'service-negate': 'enable',
- 'session-ttl': '70',
- 'spamfilter-profile': 'test_value_71',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_73',
- 'ssl-mirror': 'enable',
- 'ssl-ssh-profile': 'test_value_75',
- 'status': 'enable',
- 'tcp-mss-receiver': '77',
- 'tcp-mss-sender': '78',
- 'tcp-session-without-syn': 'all',
- 'timeout-send-rst': 'enable',
- 'traffic-shaper': 'test_value_81',
- 'traffic-shaper-reverse': 'test_value_82',
- 'utm-status': 'enable',
- 'uuid': 'test_value_84',
- 'vlan-cos-fwd': '85',
- 'vlan-cos-rev': '86',
- 'vlan-filter': 'test_value_87',
- 'voip-profile': 'test_value_88',
- 'vpntunnel': 'test_value_89',
- 'waf-profile': 'test_value_90',
- 'wanopt': 'enable',
- 'wanopt-detection': 'active',
- 'wanopt-passive-opt': 'default',
- 'wanopt-peer': 'test_value_94',
- 'wanopt-profile': 'test_value_95',
- 'wccp': 'enable',
- 'webcache': 'enable',
- 'webcache-https': 'disable',
- 'webfilter-profile': 'test_value_99',
- 'wsso': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'auth_cert': 'test_value_5',
- 'auth_path': 'enable',
- 'auth_redirect_addr': 'test_value_7',
- 'av_profile': 'test_value_8',
- 'block_notification': 'enable',
- 'captive_portal_exempt': 'enable',
- 'capture_packet': 'enable',
- 'comments': 'test_value_12',
- 'delay_tcp_npu_session': 'enable',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_16',
- 'diffservcode_rev': 'test_value_17',
- 'disclaimer': 'enable',
- 'dlp_sensor': 'test_value_19',
- 'dnsfilter_profile': 'test_value_20',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_23',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'fsso': 'enable',
- 'fsso_agent_for_ntlm': 'test_value_29',
- 'global_label': 'test_value_30',
- 'icap_profile': 'test_value_31',
- 'identity_based_route': 'test_value_32',
- 'inbound': 'enable',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'internet_service_src': 'enable',
- 'internet_service_src_negate': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_39',
- 'label': 'test_value_40',
- 'learning_mode': 'enable',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'match_vip': 'enable',
- 'name': 'default_name_45',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natip': 'test_value_48',
- 'natoutbound': 'enable',
- 'ntlm': 'enable',
- 'ntlm_guest': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_53',
- 'permit_any_host': 'enable',
- 'permit_stun_host': 'enable',
- 'policyid': '56',
- 'profile_group': 'test_value_57',
- 'profile_protocol_options': 'test_value_58',
- 'profile_type': 'single',
- 'radius_mac_auth_bypass': 'enable',
- 'redirect_url': 'test_value_61',
- 'replacemsg_override_group': 'test_value_62',
- 'rsso': 'enable',
- 'rtp_nat': 'disable',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_66',
- 'schedule_timeout': 'enable',
- 'send_deny_packet': 'disable',
- 'service_negate': 'enable',
- 'session_ttl': '70',
- 'spamfilter_profile': 'test_value_71',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_73',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_75',
- 'status': 'enable',
- 'tcp_mss_receiver': '77',
- 'tcp_mss_sender': '78',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_81',
- 'traffic_shaper_reverse': 'test_value_82',
- 'utm_status': 'enable',
- 'uuid': 'test_value_84',
- 'vlan_cos_fwd': '85',
- 'vlan_cos_rev': '86',
- 'vlan_filter': 'test_value_87',
- 'voip_profile': 'test_value_88',
- 'vpntunnel': 'test_value_89',
- 'waf_profile': 'test_value_90',
- 'wanopt': 'enable',
- 'wanopt_detection': 'active',
- 'wanopt_passive_opt': 'default',
- 'wanopt_peer': 'test_value_94',
- 'wanopt_profile': 'test_value_95',
- 'wccp': 'enable',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_99',
- 'wsso': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'auth-cert': 'test_value_5',
- 'auth-path': 'enable',
- 'auth-redirect-addr': 'test_value_7',
- 'av-profile': 'test_value_8',
- 'block-notification': 'enable',
- 'captive-portal-exempt': 'enable',
- 'capture-packet': 'enable',
- 'comments': 'test_value_12',
- 'delay-tcp-npu-session': 'enable',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_16',
- 'diffservcode-rev': 'test_value_17',
- 'disclaimer': 'enable',
- 'dlp-sensor': 'test_value_19',
- 'dnsfilter-profile': 'test_value_20',
- 'dscp-match': 'enable',
- 'dscp-negate': 'enable',
- 'dscp-value': 'test_value_23',
- 'dsri': 'enable',
- 'dstaddr-negate': 'enable',
- 'firewall-session-dirty': 'check-all',
- 'fixedport': 'enable',
- 'fsso': 'enable',
- 'fsso-agent-for-ntlm': 'test_value_29',
- 'global-label': 'test_value_30',
- 'icap-profile': 'test_value_31',
- 'identity-based-route': 'test_value_32',
- 'inbound': 'enable',
- 'internet-service': 'enable',
- 'internet-service-negate': 'enable',
- 'internet-service-src': 'enable',
- 'internet-service-src-negate': 'enable',
- 'ippool': 'enable',
- 'ips-sensor': 'test_value_39',
- 'label': 'test_value_40',
- 'learning-mode': 'enable',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'match-vip': 'enable',
- 'name': 'default_name_45',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natip': 'test_value_48',
- 'natoutbound': 'enable',
- 'ntlm': 'enable',
- 'ntlm-guest': 'enable',
- 'outbound': 'enable',
- 'per-ip-shaper': 'test_value_53',
- 'permit-any-host': 'enable',
- 'permit-stun-host': 'enable',
- 'policyid': '56',
- 'profile-group': 'test_value_57',
- 'profile-protocol-options': 'test_value_58',
- 'profile-type': 'single',
- 'radius-mac-auth-bypass': 'enable',
- 'redirect-url': 'test_value_61',
- 'replacemsg-override-group': 'test_value_62',
- 'rsso': 'enable',
- 'rtp-nat': 'disable',
- 'scan-botnet-connections': 'disable',
- 'schedule': 'test_value_66',
- 'schedule-timeout': 'enable',
- 'send-deny-packet': 'disable',
- 'service-negate': 'enable',
- 'session-ttl': '70',
- 'spamfilter-profile': 'test_value_71',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_73',
- 'ssl-mirror': 'enable',
- 'ssl-ssh-profile': 'test_value_75',
- 'status': 'enable',
- 'tcp-mss-receiver': '77',
- 'tcp-mss-sender': '78',
- 'tcp-session-without-syn': 'all',
- 'timeout-send-rst': 'enable',
- 'traffic-shaper': 'test_value_81',
- 'traffic-shaper-reverse': 'test_value_82',
- 'utm-status': 'enable',
- 'uuid': 'test_value_84',
- 'vlan-cos-fwd': '85',
- 'vlan-cos-rev': '86',
- 'vlan-filter': 'test_value_87',
- 'voip-profile': 'test_value_88',
- 'vpntunnel': 'test_value_89',
- 'waf-profile': 'test_value_90',
- 'wanopt': 'enable',
- 'wanopt-detection': 'active',
- 'wanopt-passive-opt': 'default',
- 'wanopt-peer': 'test_value_94',
- 'wanopt-profile': 'test_value_95',
- 'wccp': 'enable',
- 'webcache': 'enable',
- 'webcache-https': 'disable',
- 'webfilter-profile': 'test_value_99',
- 'wsso': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_policy': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'auth_cert': 'test_value_5',
- 'auth_path': 'enable',
- 'auth_redirect_addr': 'test_value_7',
- 'av_profile': 'test_value_8',
- 'block_notification': 'enable',
- 'captive_portal_exempt': 'enable',
- 'capture_packet': 'enable',
- 'comments': 'test_value_12',
- 'delay_tcp_npu_session': 'enable',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_16',
- 'diffservcode_rev': 'test_value_17',
- 'disclaimer': 'enable',
- 'dlp_sensor': 'test_value_19',
- 'dnsfilter_profile': 'test_value_20',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_23',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'fsso': 'enable',
- 'fsso_agent_for_ntlm': 'test_value_29',
- 'global_label': 'test_value_30',
- 'icap_profile': 'test_value_31',
- 'identity_based_route': 'test_value_32',
- 'inbound': 'enable',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'internet_service_src': 'enable',
- 'internet_service_src_negate': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_39',
- 'label': 'test_value_40',
- 'learning_mode': 'enable',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'match_vip': 'enable',
- 'name': 'default_name_45',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natip': 'test_value_48',
- 'natoutbound': 'enable',
- 'ntlm': 'enable',
- 'ntlm_guest': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_53',
- 'permit_any_host': 'enable',
- 'permit_stun_host': 'enable',
- 'policyid': '56',
- 'profile_group': 'test_value_57',
- 'profile_protocol_options': 'test_value_58',
- 'profile_type': 'single',
- 'radius_mac_auth_bypass': 'enable',
- 'redirect_url': 'test_value_61',
- 'replacemsg_override_group': 'test_value_62',
- 'rsso': 'enable',
- 'rtp_nat': 'disable',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_66',
- 'schedule_timeout': 'enable',
- 'send_deny_packet': 'disable',
- 'service_negate': 'enable',
- 'session_ttl': '70',
- 'spamfilter_profile': 'test_value_71',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_73',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_75',
- 'status': 'enable',
- 'tcp_mss_receiver': '77',
- 'tcp_mss_sender': '78',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_81',
- 'traffic_shaper_reverse': 'test_value_82',
- 'utm_status': 'enable',
- 'uuid': 'test_value_84',
- 'vlan_cos_fwd': '85',
- 'vlan_cos_rev': '86',
- 'vlan_filter': 'test_value_87',
- 'voip_profile': 'test_value_88',
- 'vpntunnel': 'test_value_89',
- 'waf_profile': 'test_value_90',
- 'wanopt': 'enable',
- 'wanopt_detection': 'active',
- 'wanopt_passive_opt': 'default',
- 'wanopt_peer': 'test_value_94',
- 'wanopt_profile': 'test_value_95',
- 'wccp': 'enable',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_99',
- 'wsso': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_policy': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'auth_cert': 'test_value_5',
- 'auth_path': 'enable',
- 'auth_redirect_addr': 'test_value_7',
- 'av_profile': 'test_value_8',
- 'block_notification': 'enable',
- 'captive_portal_exempt': 'enable',
- 'capture_packet': 'enable',
- 'comments': 'test_value_12',
- 'delay_tcp_npu_session': 'enable',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_16',
- 'diffservcode_rev': 'test_value_17',
- 'disclaimer': 'enable',
- 'dlp_sensor': 'test_value_19',
- 'dnsfilter_profile': 'test_value_20',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_23',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'fsso': 'enable',
- 'fsso_agent_for_ntlm': 'test_value_29',
- 'global_label': 'test_value_30',
- 'icap_profile': 'test_value_31',
- 'identity_based_route': 'test_value_32',
- 'inbound': 'enable',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'internet_service_src': 'enable',
- 'internet_service_src_negate': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_39',
- 'label': 'test_value_40',
- 'learning_mode': 'enable',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'match_vip': 'enable',
- 'name': 'default_name_45',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natip': 'test_value_48',
- 'natoutbound': 'enable',
- 'ntlm': 'enable',
- 'ntlm_guest': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_53',
- 'permit_any_host': 'enable',
- 'permit_stun_host': 'enable',
- 'policyid': '56',
- 'profile_group': 'test_value_57',
- 'profile_protocol_options': 'test_value_58',
- 'profile_type': 'single',
- 'radius_mac_auth_bypass': 'enable',
- 'redirect_url': 'test_value_61',
- 'replacemsg_override_group': 'test_value_62',
- 'rsso': 'enable',
- 'rtp_nat': 'disable',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_66',
- 'schedule_timeout': 'enable',
- 'send_deny_packet': 'disable',
- 'service_negate': 'enable',
- 'session_ttl': '70',
- 'spamfilter_profile': 'test_value_71',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_73',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_75',
- 'status': 'enable',
- 'tcp_mss_receiver': '77',
- 'tcp_mss_sender': '78',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_81',
- 'traffic_shaper_reverse': 'test_value_82',
- 'utm_status': 'enable',
- 'uuid': 'test_value_84',
- 'vlan_cos_fwd': '85',
- 'vlan_cos_rev': '86',
- 'vlan_filter': 'test_value_87',
- 'voip_profile': 'test_value_88',
- 'vpntunnel': 'test_value_89',
- 'waf_profile': 'test_value_90',
- 'wanopt': 'enable',
- 'wanopt_detection': 'active',
- 'wanopt_passive_opt': 'default',
- 'wanopt_peer': 'test_value_94',
- 'wanopt_profile': 'test_value_95',
- 'wccp': 'enable',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_99',
- 'wsso': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'auth_cert': 'test_value_5',
- 'auth_path': 'enable',
- 'auth_redirect_addr': 'test_value_7',
- 'av_profile': 'test_value_8',
- 'block_notification': 'enable',
- 'captive_portal_exempt': 'enable',
- 'capture_packet': 'enable',
- 'comments': 'test_value_12',
- 'delay_tcp_npu_session': 'enable',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_16',
- 'diffservcode_rev': 'test_value_17',
- 'disclaimer': 'enable',
- 'dlp_sensor': 'test_value_19',
- 'dnsfilter_profile': 'test_value_20',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_23',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'fsso': 'enable',
- 'fsso_agent_for_ntlm': 'test_value_29',
- 'global_label': 'test_value_30',
- 'icap_profile': 'test_value_31',
- 'identity_based_route': 'test_value_32',
- 'inbound': 'enable',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'internet_service_src': 'enable',
- 'internet_service_src_negate': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_39',
- 'label': 'test_value_40',
- 'learning_mode': 'enable',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'match_vip': 'enable',
- 'name': 'default_name_45',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natip': 'test_value_48',
- 'natoutbound': 'enable',
- 'ntlm': 'enable',
- 'ntlm_guest': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_53',
- 'permit_any_host': 'enable',
- 'permit_stun_host': 'enable',
- 'policyid': '56',
- 'profile_group': 'test_value_57',
- 'profile_protocol_options': 'test_value_58',
- 'profile_type': 'single',
- 'radius_mac_auth_bypass': 'enable',
- 'redirect_url': 'test_value_61',
- 'replacemsg_override_group': 'test_value_62',
- 'rsso': 'enable',
- 'rtp_nat': 'disable',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_66',
- 'schedule_timeout': 'enable',
- 'send_deny_packet': 'disable',
- 'service_negate': 'enable',
- 'session_ttl': '70',
- 'spamfilter_profile': 'test_value_71',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_73',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_75',
- 'status': 'enable',
- 'tcp_mss_receiver': '77',
- 'tcp_mss_sender': '78',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_81',
- 'traffic_shaper_reverse': 'test_value_82',
- 'utm_status': 'enable',
- 'uuid': 'test_value_84',
- 'vlan_cos_fwd': '85',
- 'vlan_cos_rev': '86',
- 'vlan_filter': 'test_value_87',
- 'voip_profile': 'test_value_88',
- 'vpntunnel': 'test_value_89',
- 'waf_profile': 'test_value_90',
- 'wanopt': 'enable',
- 'wanopt_detection': 'active',
- 'wanopt_passive_opt': 'default',
- 'wanopt_peer': 'test_value_94',
- 'wanopt_profile': 'test_value_95',
- 'wccp': 'enable',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_99',
- 'wsso': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'auth-cert': 'test_value_5',
- 'auth-path': 'enable',
- 'auth-redirect-addr': 'test_value_7',
- 'av-profile': 'test_value_8',
- 'block-notification': 'enable',
- 'captive-portal-exempt': 'enable',
- 'capture-packet': 'enable',
- 'comments': 'test_value_12',
- 'delay-tcp-npu-session': 'enable',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_16',
- 'diffservcode-rev': 'test_value_17',
- 'disclaimer': 'enable',
- 'dlp-sensor': 'test_value_19',
- 'dnsfilter-profile': 'test_value_20',
- 'dscp-match': 'enable',
- 'dscp-negate': 'enable',
- 'dscp-value': 'test_value_23',
- 'dsri': 'enable',
- 'dstaddr-negate': 'enable',
- 'firewall-session-dirty': 'check-all',
- 'fixedport': 'enable',
- 'fsso': 'enable',
- 'fsso-agent-for-ntlm': 'test_value_29',
- 'global-label': 'test_value_30',
- 'icap-profile': 'test_value_31',
- 'identity-based-route': 'test_value_32',
- 'inbound': 'enable',
- 'internet-service': 'enable',
- 'internet-service-negate': 'enable',
- 'internet-service-src': 'enable',
- 'internet-service-src-negate': 'enable',
- 'ippool': 'enable',
- 'ips-sensor': 'test_value_39',
- 'label': 'test_value_40',
- 'learning-mode': 'enable',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'match-vip': 'enable',
- 'name': 'default_name_45',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natip': 'test_value_48',
- 'natoutbound': 'enable',
- 'ntlm': 'enable',
- 'ntlm-guest': 'enable',
- 'outbound': 'enable',
- 'per-ip-shaper': 'test_value_53',
- 'permit-any-host': 'enable',
- 'permit-stun-host': 'enable',
- 'policyid': '56',
- 'profile-group': 'test_value_57',
- 'profile-protocol-options': 'test_value_58',
- 'profile-type': 'single',
- 'radius-mac-auth-bypass': 'enable',
- 'redirect-url': 'test_value_61',
- 'replacemsg-override-group': 'test_value_62',
- 'rsso': 'enable',
- 'rtp-nat': 'disable',
- 'scan-botnet-connections': 'disable',
- 'schedule': 'test_value_66',
- 'schedule-timeout': 'enable',
- 'send-deny-packet': 'disable',
- 'service-negate': 'enable',
- 'session-ttl': '70',
- 'spamfilter-profile': 'test_value_71',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_73',
- 'ssl-mirror': 'enable',
- 'ssl-ssh-profile': 'test_value_75',
- 'status': 'enable',
- 'tcp-mss-receiver': '77',
- 'tcp-mss-sender': '78',
- 'tcp-session-without-syn': 'all',
- 'timeout-send-rst': 'enable',
- 'traffic-shaper': 'test_value_81',
- 'traffic-shaper-reverse': 'test_value_82',
- 'utm-status': 'enable',
- 'uuid': 'test_value_84',
- 'vlan-cos-fwd': '85',
- 'vlan-cos-rev': '86',
- 'vlan-filter': 'test_value_87',
- 'voip-profile': 'test_value_88',
- 'vpntunnel': 'test_value_89',
- 'waf-profile': 'test_value_90',
- 'wanopt': 'enable',
- 'wanopt-detection': 'active',
- 'wanopt-passive-opt': 'default',
- 'wanopt-peer': 'test_value_94',
- 'wanopt-profile': 'test_value_95',
- 'wccp': 'enable',
- 'webcache': 'enable',
- 'webcache-https': 'disable',
- 'webfilter-profile': 'test_value_99',
- 'wsso': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'auth_cert': 'test_value_5',
- 'auth_path': 'enable',
- 'auth_redirect_addr': 'test_value_7',
- 'av_profile': 'test_value_8',
- 'block_notification': 'enable',
- 'captive_portal_exempt': 'enable',
- 'capture_packet': 'enable',
- 'comments': 'test_value_12',
- 'delay_tcp_npu_session': 'enable',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_16',
- 'diffservcode_rev': 'test_value_17',
- 'disclaimer': 'enable',
- 'dlp_sensor': 'test_value_19',
- 'dnsfilter_profile': 'test_value_20',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_23',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'fsso': 'enable',
- 'fsso_agent_for_ntlm': 'test_value_29',
- 'global_label': 'test_value_30',
- 'icap_profile': 'test_value_31',
- 'identity_based_route': 'test_value_32',
- 'inbound': 'enable',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'internet_service_src': 'enable',
- 'internet_service_src_negate': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_39',
- 'label': 'test_value_40',
- 'learning_mode': 'enable',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'match_vip': 'enable',
- 'name': 'default_name_45',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natip': 'test_value_48',
- 'natoutbound': 'enable',
- 'ntlm': 'enable',
- 'ntlm_guest': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_53',
- 'permit_any_host': 'enable',
- 'permit_stun_host': 'enable',
- 'policyid': '56',
- 'profile_group': 'test_value_57',
- 'profile_protocol_options': 'test_value_58',
- 'profile_type': 'single',
- 'radius_mac_auth_bypass': 'enable',
- 'redirect_url': 'test_value_61',
- 'replacemsg_override_group': 'test_value_62',
- 'rsso': 'enable',
- 'rtp_nat': 'disable',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_66',
- 'schedule_timeout': 'enable',
- 'send_deny_packet': 'disable',
- 'service_negate': 'enable',
- 'session_ttl': '70',
- 'spamfilter_profile': 'test_value_71',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_73',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_75',
- 'status': 'enable',
- 'tcp_mss_receiver': '77',
- 'tcp_mss_sender': '78',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_81',
- 'traffic_shaper_reverse': 'test_value_82',
- 'utm_status': 'enable',
- 'uuid': 'test_value_84',
- 'vlan_cos_fwd': '85',
- 'vlan_cos_rev': '86',
- 'vlan_filter': 'test_value_87',
- 'voip_profile': 'test_value_88',
- 'vpntunnel': 'test_value_89',
- 'waf_profile': 'test_value_90',
- 'wanopt': 'enable',
- 'wanopt_detection': 'active',
- 'wanopt_passive_opt': 'default',
- 'wanopt_peer': 'test_value_94',
- 'wanopt_profile': 'test_value_95',
- 'wccp': 'enable',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_99',
- 'wsso': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'auth-cert': 'test_value_5',
- 'auth-path': 'enable',
- 'auth-redirect-addr': 'test_value_7',
- 'av-profile': 'test_value_8',
- 'block-notification': 'enable',
- 'captive-portal-exempt': 'enable',
- 'capture-packet': 'enable',
- 'comments': 'test_value_12',
- 'delay-tcp-npu-session': 'enable',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_16',
- 'diffservcode-rev': 'test_value_17',
- 'disclaimer': 'enable',
- 'dlp-sensor': 'test_value_19',
- 'dnsfilter-profile': 'test_value_20',
- 'dscp-match': 'enable',
- 'dscp-negate': 'enable',
- 'dscp-value': 'test_value_23',
- 'dsri': 'enable',
- 'dstaddr-negate': 'enable',
- 'firewall-session-dirty': 'check-all',
- 'fixedport': 'enable',
- 'fsso': 'enable',
- 'fsso-agent-for-ntlm': 'test_value_29',
- 'global-label': 'test_value_30',
- 'icap-profile': 'test_value_31',
- 'identity-based-route': 'test_value_32',
- 'inbound': 'enable',
- 'internet-service': 'enable',
- 'internet-service-negate': 'enable',
- 'internet-service-src': 'enable',
- 'internet-service-src-negate': 'enable',
- 'ippool': 'enable',
- 'ips-sensor': 'test_value_39',
- 'label': 'test_value_40',
- 'learning-mode': 'enable',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'match-vip': 'enable',
- 'name': 'default_name_45',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natip': 'test_value_48',
- 'natoutbound': 'enable',
- 'ntlm': 'enable',
- 'ntlm-guest': 'enable',
- 'outbound': 'enable',
- 'per-ip-shaper': 'test_value_53',
- 'permit-any-host': 'enable',
- 'permit-stun-host': 'enable',
- 'policyid': '56',
- 'profile-group': 'test_value_57',
- 'profile-protocol-options': 'test_value_58',
- 'profile-type': 'single',
- 'radius-mac-auth-bypass': 'enable',
- 'redirect-url': 'test_value_61',
- 'replacemsg-override-group': 'test_value_62',
- 'rsso': 'enable',
- 'rtp-nat': 'disable',
- 'scan-botnet-connections': 'disable',
- 'schedule': 'test_value_66',
- 'schedule-timeout': 'enable',
- 'send-deny-packet': 'disable',
- 'service-negate': 'enable',
- 'session-ttl': '70',
- 'spamfilter-profile': 'test_value_71',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_73',
- 'ssl-mirror': 'enable',
- 'ssl-ssh-profile': 'test_value_75',
- 'status': 'enable',
- 'tcp-mss-receiver': '77',
- 'tcp-mss-sender': '78',
- 'tcp-session-without-syn': 'all',
- 'timeout-send-rst': 'enable',
- 'traffic-shaper': 'test_value_81',
- 'traffic-shaper-reverse': 'test_value_82',
- 'utm-status': 'enable',
- 'uuid': 'test_value_84',
- 'vlan-cos-fwd': '85',
- 'vlan-cos-rev': '86',
- 'vlan-filter': 'test_value_87',
- 'voip-profile': 'test_value_88',
- 'vpntunnel': 'test_value_89',
- 'waf-profile': 'test_value_90',
- 'wanopt': 'enable',
- 'wanopt-detection': 'active',
- 'wanopt-passive-opt': 'default',
- 'wanopt-peer': 'test_value_94',
- 'wanopt-profile': 'test_value_95',
- 'wccp': 'enable',
- 'webcache': 'enable',
- 'webcache-https': 'disable',
- 'webfilter-profile': 'test_value_99',
- 'wsso': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_policy46.py b/test/units/modules/network/fortios/test_fortios_firewall_policy46.py
deleted file mode 100644
index 41604f0f7a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_policy46.py
+++ /dev/null
@@ -1,359 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_policy46
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_policy46.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_policy46_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy46': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per-ip-shaper': 'test_value_9',
- 'permit-any-host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp-mss-receiver': '15',
- 'tcp-mss-sender': '16',
- 'traffic-shaper': 'test_value_17',
- 'traffic-shaper-reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_policy46_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy46': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per-ip-shaper': 'test_value_9',
- 'permit-any-host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp-mss-receiver': '15',
- 'tcp-mss-sender': '16',
- 'traffic-shaper': 'test_value_17',
- 'traffic-shaper-reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_policy46_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_policy46': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy46.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'policy46', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_policy46_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_policy46': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy46.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'policy46', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_policy46_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy46': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per-ip-shaper': 'test_value_9',
- 'permit-any-host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp-mss-receiver': '15',
- 'tcp-mss-sender': '16',
- 'traffic-shaper': 'test_value_17',
- 'traffic-shaper-reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_policy46_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy46': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per-ip-shaper': 'test_value_9',
- 'permit-any-host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp-mss-receiver': '15',
- 'tcp-mss-sender': '16',
- 'traffic-shaper': 'test_value_17',
- 'traffic-shaper-reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_policy6.py b/test/units/modules/network/fortios/test_fortios_firewall_policy6.py
deleted file mode 100644
index 5016f00742..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_policy6.py
+++ /dev/null
@@ -1,789 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_policy6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_policy6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_policy6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy6': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_9',
- 'diffservcode_rev': 'test_value_10',
- 'dlp_sensor': 'test_value_11',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_14',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'global_label': 'test_value_19',
- 'icap_profile': 'test_value_20',
- 'inbound': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_23',
- 'label': 'test_value_24',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'name': 'default_name_27',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natoutbound': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_32',
- 'policyid': '33',
- 'profile_group': 'test_value_34',
- 'profile_protocol_options': 'test_value_35',
- 'profile_type': 'single',
- 'replacemsg_override_group': 'test_value_37',
- 'rsso': 'enable',
- 'schedule': 'test_value_39',
- 'send_deny_packet': 'enable',
- 'service_negate': 'enable',
- 'session_ttl': '42',
- 'spamfilter_profile': 'test_value_43',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_45',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_47',
- 'status': 'enable',
- 'tcp_mss_receiver': '49',
- 'tcp_mss_sender': '50',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_53',
- 'traffic_shaper_reverse': 'test_value_54',
- 'utm_status': 'enable',
- 'uuid': 'test_value_56',
- 'vlan_cos_fwd': '57',
- 'vlan_cos_rev': '58',
- 'vlan_filter': 'test_value_59',
- 'voip_profile': 'test_value_60',
- 'vpntunnel': 'test_value_61',
- 'webfilter_profile': 'test_value_62'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'av-profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_9',
- 'diffservcode-rev': 'test_value_10',
- 'dlp-sensor': 'test_value_11',
- 'dscp-match': 'enable',
- 'dscp-negate': 'enable',
- 'dscp-value': 'test_value_14',
- 'dsri': 'enable',
- 'dstaddr-negate': 'enable',
- 'firewall-session-dirty': 'check-all',
- 'fixedport': 'enable',
- 'global-label': 'test_value_19',
- 'icap-profile': 'test_value_20',
- 'inbound': 'enable',
- 'ippool': 'enable',
- 'ips-sensor': 'test_value_23',
- 'label': 'test_value_24',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'name': 'default_name_27',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natoutbound': 'enable',
- 'outbound': 'enable',
- 'per-ip-shaper': 'test_value_32',
- 'policyid': '33',
- 'profile-group': 'test_value_34',
- 'profile-protocol-options': 'test_value_35',
- 'profile-type': 'single',
- 'replacemsg-override-group': 'test_value_37',
- 'rsso': 'enable',
- 'schedule': 'test_value_39',
- 'send-deny-packet': 'enable',
- 'service-negate': 'enable',
- 'session-ttl': '42',
- 'spamfilter-profile': 'test_value_43',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_45',
- 'ssl-mirror': 'enable',
- 'ssl-ssh-profile': 'test_value_47',
- 'status': 'enable',
- 'tcp-mss-receiver': '49',
- 'tcp-mss-sender': '50',
- 'tcp-session-without-syn': 'all',
- 'timeout-send-rst': 'enable',
- 'traffic-shaper': 'test_value_53',
- 'traffic-shaper-reverse': 'test_value_54',
- 'utm-status': 'enable',
- 'uuid': 'test_value_56',
- 'vlan-cos-fwd': '57',
- 'vlan-cos-rev': '58',
- 'vlan-filter': 'test_value_59',
- 'voip-profile': 'test_value_60',
- 'vpntunnel': 'test_value_61',
- 'webfilter-profile': 'test_value_62'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_policy6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy6': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_9',
- 'diffservcode_rev': 'test_value_10',
- 'dlp_sensor': 'test_value_11',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_14',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'global_label': 'test_value_19',
- 'icap_profile': 'test_value_20',
- 'inbound': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_23',
- 'label': 'test_value_24',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'name': 'default_name_27',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natoutbound': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_32',
- 'policyid': '33',
- 'profile_group': 'test_value_34',
- 'profile_protocol_options': 'test_value_35',
- 'profile_type': 'single',
- 'replacemsg_override_group': 'test_value_37',
- 'rsso': 'enable',
- 'schedule': 'test_value_39',
- 'send_deny_packet': 'enable',
- 'service_negate': 'enable',
- 'session_ttl': '42',
- 'spamfilter_profile': 'test_value_43',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_45',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_47',
- 'status': 'enable',
- 'tcp_mss_receiver': '49',
- 'tcp_mss_sender': '50',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_53',
- 'traffic_shaper_reverse': 'test_value_54',
- 'utm_status': 'enable',
- 'uuid': 'test_value_56',
- 'vlan_cos_fwd': '57',
- 'vlan_cos_rev': '58',
- 'vlan_filter': 'test_value_59',
- 'voip_profile': 'test_value_60',
- 'vpntunnel': 'test_value_61',
- 'webfilter_profile': 'test_value_62'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'av-profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_9',
- 'diffservcode-rev': 'test_value_10',
- 'dlp-sensor': 'test_value_11',
- 'dscp-match': 'enable',
- 'dscp-negate': 'enable',
- 'dscp-value': 'test_value_14',
- 'dsri': 'enable',
- 'dstaddr-negate': 'enable',
- 'firewall-session-dirty': 'check-all',
- 'fixedport': 'enable',
- 'global-label': 'test_value_19',
- 'icap-profile': 'test_value_20',
- 'inbound': 'enable',
- 'ippool': 'enable',
- 'ips-sensor': 'test_value_23',
- 'label': 'test_value_24',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'name': 'default_name_27',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natoutbound': 'enable',
- 'outbound': 'enable',
- 'per-ip-shaper': 'test_value_32',
- 'policyid': '33',
- 'profile-group': 'test_value_34',
- 'profile-protocol-options': 'test_value_35',
- 'profile-type': 'single',
- 'replacemsg-override-group': 'test_value_37',
- 'rsso': 'enable',
- 'schedule': 'test_value_39',
- 'send-deny-packet': 'enable',
- 'service-negate': 'enable',
- 'session-ttl': '42',
- 'spamfilter-profile': 'test_value_43',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_45',
- 'ssl-mirror': 'enable',
- 'ssl-ssh-profile': 'test_value_47',
- 'status': 'enable',
- 'tcp-mss-receiver': '49',
- 'tcp-mss-sender': '50',
- 'tcp-session-without-syn': 'all',
- 'timeout-send-rst': 'enable',
- 'traffic-shaper': 'test_value_53',
- 'traffic-shaper-reverse': 'test_value_54',
- 'utm-status': 'enable',
- 'uuid': 'test_value_56',
- 'vlan-cos-fwd': '57',
- 'vlan-cos-rev': '58',
- 'vlan-filter': 'test_value_59',
- 'voip-profile': 'test_value_60',
- 'vpntunnel': 'test_value_61',
- 'webfilter-profile': 'test_value_62'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_policy6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_policy6': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_9',
- 'diffservcode_rev': 'test_value_10',
- 'dlp_sensor': 'test_value_11',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_14',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'global_label': 'test_value_19',
- 'icap_profile': 'test_value_20',
- 'inbound': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_23',
- 'label': 'test_value_24',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'name': 'default_name_27',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natoutbound': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_32',
- 'policyid': '33',
- 'profile_group': 'test_value_34',
- 'profile_protocol_options': 'test_value_35',
- 'profile_type': 'single',
- 'replacemsg_override_group': 'test_value_37',
- 'rsso': 'enable',
- 'schedule': 'test_value_39',
- 'send_deny_packet': 'enable',
- 'service_negate': 'enable',
- 'session_ttl': '42',
- 'spamfilter_profile': 'test_value_43',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_45',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_47',
- 'status': 'enable',
- 'tcp_mss_receiver': '49',
- 'tcp_mss_sender': '50',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_53',
- 'traffic_shaper_reverse': 'test_value_54',
- 'utm_status': 'enable',
- 'uuid': 'test_value_56',
- 'vlan_cos_fwd': '57',
- 'vlan_cos_rev': '58',
- 'vlan_filter': 'test_value_59',
- 'voip_profile': 'test_value_60',
- 'vpntunnel': 'test_value_61',
- 'webfilter_profile': 'test_value_62'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_policy6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_policy6': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_9',
- 'diffservcode_rev': 'test_value_10',
- 'dlp_sensor': 'test_value_11',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_14',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'global_label': 'test_value_19',
- 'icap_profile': 'test_value_20',
- 'inbound': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_23',
- 'label': 'test_value_24',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'name': 'default_name_27',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natoutbound': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_32',
- 'policyid': '33',
- 'profile_group': 'test_value_34',
- 'profile_protocol_options': 'test_value_35',
- 'profile_type': 'single',
- 'replacemsg_override_group': 'test_value_37',
- 'rsso': 'enable',
- 'schedule': 'test_value_39',
- 'send_deny_packet': 'enable',
- 'service_negate': 'enable',
- 'session_ttl': '42',
- 'spamfilter_profile': 'test_value_43',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_45',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_47',
- 'status': 'enable',
- 'tcp_mss_receiver': '49',
- 'tcp_mss_sender': '50',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_53',
- 'traffic_shaper_reverse': 'test_value_54',
- 'utm_status': 'enable',
- 'uuid': 'test_value_56',
- 'vlan_cos_fwd': '57',
- 'vlan_cos_rev': '58',
- 'vlan_filter': 'test_value_59',
- 'voip_profile': 'test_value_60',
- 'vpntunnel': 'test_value_61',
- 'webfilter_profile': 'test_value_62'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_policy6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy6': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_9',
- 'diffservcode_rev': 'test_value_10',
- 'dlp_sensor': 'test_value_11',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_14',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'global_label': 'test_value_19',
- 'icap_profile': 'test_value_20',
- 'inbound': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_23',
- 'label': 'test_value_24',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'name': 'default_name_27',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natoutbound': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_32',
- 'policyid': '33',
- 'profile_group': 'test_value_34',
- 'profile_protocol_options': 'test_value_35',
- 'profile_type': 'single',
- 'replacemsg_override_group': 'test_value_37',
- 'rsso': 'enable',
- 'schedule': 'test_value_39',
- 'send_deny_packet': 'enable',
- 'service_negate': 'enable',
- 'session_ttl': '42',
- 'spamfilter_profile': 'test_value_43',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_45',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_47',
- 'status': 'enable',
- 'tcp_mss_receiver': '49',
- 'tcp_mss_sender': '50',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_53',
- 'traffic_shaper_reverse': 'test_value_54',
- 'utm_status': 'enable',
- 'uuid': 'test_value_56',
- 'vlan_cos_fwd': '57',
- 'vlan_cos_rev': '58',
- 'vlan_filter': 'test_value_59',
- 'voip_profile': 'test_value_60',
- 'vpntunnel': 'test_value_61',
- 'webfilter_profile': 'test_value_62'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'av-profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_9',
- 'diffservcode-rev': 'test_value_10',
- 'dlp-sensor': 'test_value_11',
- 'dscp-match': 'enable',
- 'dscp-negate': 'enable',
- 'dscp-value': 'test_value_14',
- 'dsri': 'enable',
- 'dstaddr-negate': 'enable',
- 'firewall-session-dirty': 'check-all',
- 'fixedport': 'enable',
- 'global-label': 'test_value_19',
- 'icap-profile': 'test_value_20',
- 'inbound': 'enable',
- 'ippool': 'enable',
- 'ips-sensor': 'test_value_23',
- 'label': 'test_value_24',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'name': 'default_name_27',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natoutbound': 'enable',
- 'outbound': 'enable',
- 'per-ip-shaper': 'test_value_32',
- 'policyid': '33',
- 'profile-group': 'test_value_34',
- 'profile-protocol-options': 'test_value_35',
- 'profile-type': 'single',
- 'replacemsg-override-group': 'test_value_37',
- 'rsso': 'enable',
- 'schedule': 'test_value_39',
- 'send-deny-packet': 'enable',
- 'service-negate': 'enable',
- 'session-ttl': '42',
- 'spamfilter-profile': 'test_value_43',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_45',
- 'ssl-mirror': 'enable',
- 'ssl-ssh-profile': 'test_value_47',
- 'status': 'enable',
- 'tcp-mss-receiver': '49',
- 'tcp-mss-sender': '50',
- 'tcp-session-without-syn': 'all',
- 'timeout-send-rst': 'enable',
- 'traffic-shaper': 'test_value_53',
- 'traffic-shaper-reverse': 'test_value_54',
- 'utm-status': 'enable',
- 'uuid': 'test_value_56',
- 'vlan-cos-fwd': '57',
- 'vlan-cos-rev': '58',
- 'vlan-filter': 'test_value_59',
- 'voip-profile': 'test_value_60',
- 'vpntunnel': 'test_value_61',
- 'webfilter-profile': 'test_value_62'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_policy6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy6': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_9',
- 'diffservcode_rev': 'test_value_10',
- 'dlp_sensor': 'test_value_11',
- 'dscp_match': 'enable',
- 'dscp_negate': 'enable',
- 'dscp_value': 'test_value_14',
- 'dsri': 'enable',
- 'dstaddr_negate': 'enable',
- 'firewall_session_dirty': 'check-all',
- 'fixedport': 'enable',
- 'global_label': 'test_value_19',
- 'icap_profile': 'test_value_20',
- 'inbound': 'enable',
- 'ippool': 'enable',
- 'ips_sensor': 'test_value_23',
- 'label': 'test_value_24',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'name': 'default_name_27',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natoutbound': 'enable',
- 'outbound': 'enable',
- 'per_ip_shaper': 'test_value_32',
- 'policyid': '33',
- 'profile_group': 'test_value_34',
- 'profile_protocol_options': 'test_value_35',
- 'profile_type': 'single',
- 'replacemsg_override_group': 'test_value_37',
- 'rsso': 'enable',
- 'schedule': 'test_value_39',
- 'send_deny_packet': 'enable',
- 'service_negate': 'enable',
- 'session_ttl': '42',
- 'spamfilter_profile': 'test_value_43',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_45',
- 'ssl_mirror': 'enable',
- 'ssl_ssh_profile': 'test_value_47',
- 'status': 'enable',
- 'tcp_mss_receiver': '49',
- 'tcp_mss_sender': '50',
- 'tcp_session_without_syn': 'all',
- 'timeout_send_rst': 'enable',
- 'traffic_shaper': 'test_value_53',
- 'traffic_shaper_reverse': 'test_value_54',
- 'utm_status': 'enable',
- 'uuid': 'test_value_56',
- 'vlan_cos_fwd': '57',
- 'vlan_cos_rev': '58',
- 'vlan_filter': 'test_value_59',
- 'voip_profile': 'test_value_60',
- 'vpntunnel': 'test_value_61',
- 'webfilter_profile': 'test_value_62'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'av-profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_9',
- 'diffservcode-rev': 'test_value_10',
- 'dlp-sensor': 'test_value_11',
- 'dscp-match': 'enable',
- 'dscp-negate': 'enable',
- 'dscp-value': 'test_value_14',
- 'dsri': 'enable',
- 'dstaddr-negate': 'enable',
- 'firewall-session-dirty': 'check-all',
- 'fixedport': 'enable',
- 'global-label': 'test_value_19',
- 'icap-profile': 'test_value_20',
- 'inbound': 'enable',
- 'ippool': 'enable',
- 'ips-sensor': 'test_value_23',
- 'label': 'test_value_24',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'name': 'default_name_27',
- 'nat': 'enable',
- 'natinbound': 'enable',
- 'natoutbound': 'enable',
- 'outbound': 'enable',
- 'per-ip-shaper': 'test_value_32',
- 'policyid': '33',
- 'profile-group': 'test_value_34',
- 'profile-protocol-options': 'test_value_35',
- 'profile-type': 'single',
- 'replacemsg-override-group': 'test_value_37',
- 'rsso': 'enable',
- 'schedule': 'test_value_39',
- 'send-deny-packet': 'enable',
- 'service-negate': 'enable',
- 'session-ttl': '42',
- 'spamfilter-profile': 'test_value_43',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_45',
- 'ssl-mirror': 'enable',
- 'ssl-ssh-profile': 'test_value_47',
- 'status': 'enable',
- 'tcp-mss-receiver': '49',
- 'tcp-mss-sender': '50',
- 'tcp-session-without-syn': 'all',
- 'timeout-send-rst': 'enable',
- 'traffic-shaper': 'test_value_53',
- 'traffic-shaper-reverse': 'test_value_54',
- 'utm-status': 'enable',
- 'uuid': 'test_value_56',
- 'vlan-cos-fwd': '57',
- 'vlan-cos-rev': '58',
- 'vlan-filter': 'test_value_59',
- 'voip-profile': 'test_value_60',
- 'vpntunnel': 'test_value_61',
- 'webfilter-profile': 'test_value_62'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_policy64.py b/test/units/modules/network/fortios/test_fortios_firewall_policy64.py
deleted file mode 100644
index a479b61b9e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_policy64.py
+++ /dev/null
@@ -1,359 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_policy64
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_policy64.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_policy64_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy64': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per-ip-shaper': 'test_value_9',
- 'permit-any-host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp-mss-receiver': '15',
- 'tcp-mss-sender': '16',
- 'traffic-shaper': 'test_value_17',
- 'traffic-shaper-reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_policy64_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy64': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per-ip-shaper': 'test_value_9',
- 'permit-any-host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp-mss-receiver': '15',
- 'tcp-mss-sender': '16',
- 'traffic-shaper': 'test_value_17',
- 'traffic-shaper-reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_policy64_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_policy64': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy64.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'policy64', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_policy64_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_policy64': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy64.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'policy64', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_policy64_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy64': {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per-ip-shaper': 'test_value_9',
- 'permit-any-host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp-mss-receiver': '15',
- 'tcp-mss-sender': '16',
- 'traffic-shaper': 'test_value_17',
- 'traffic-shaper-reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_policy64_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_policy64': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per_ip_shaper': 'test_value_9',
- 'permit_any_host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp_mss_receiver': '15',
- 'tcp_mss_sender': '16',
- 'traffic_shaper': 'test_value_17',
- 'traffic_shaper_reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_policy64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'comments': 'test_value_4',
- 'dstintf': 'test_value_5',
- 'fixedport': 'enable',
- 'ippool': 'enable',
- 'logtraffic': 'enable',
- 'per-ip-shaper': 'test_value_9',
- 'permit-any-host': 'enable',
- 'policyid': '11',
- 'schedule': 'test_value_12',
- 'srcintf': 'test_value_13',
- 'status': 'enable',
- 'tcp-mss-receiver': '15',
- 'tcp-mss-sender': '16',
- 'traffic-shaper': 'test_value_17',
- 'traffic-shaper-reverse': 'test_value_18',
- 'uuid': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('firewall', 'policy64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_profile_group.py b/test/units/modules/network/fortios/test_fortios_firewall_profile_group.py
deleted file mode 100644
index fc13e888b1..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_profile_group.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_profile_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_profile_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_profile_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_profile_group': {
- 'application_list': 'test_value_3',
- 'av_profile': 'test_value_4',
- 'dlp_sensor': 'test_value_5',
- 'dnsfilter_profile': 'test_value_6',
- 'icap_profile': 'test_value_7',
- 'ips_sensor': 'test_value_8',
- 'name': 'default_name_9',
- 'profile_protocol_options': 'test_value_10',
- 'spamfilter_profile': 'test_value_11',
- 'ssh_filter_profile': 'test_value_12',
- 'ssl_ssh_profile': 'test_value_13',
- 'voip_profile': 'test_value_14',
- 'waf_profile': 'test_value_15',
- 'webfilter_profile': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_group.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'application-list': 'test_value_3',
- 'av-profile': 'test_value_4',
- 'dlp-sensor': 'test_value_5',
- 'dnsfilter-profile': 'test_value_6',
- 'icap-profile': 'test_value_7',
- 'ips-sensor': 'test_value_8',
- 'name': 'default_name_9',
- 'profile-protocol-options': 'test_value_10',
- 'spamfilter-profile': 'test_value_11',
- 'ssh-filter-profile': 'test_value_12',
- 'ssl-ssh-profile': 'test_value_13',
- 'voip-profile': 'test_value_14',
- 'waf-profile': 'test_value_15',
- 'webfilter-profile': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('firewall', 'profile-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_profile_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_profile_group': {
- 'application_list': 'test_value_3',
- 'av_profile': 'test_value_4',
- 'dlp_sensor': 'test_value_5',
- 'dnsfilter_profile': 'test_value_6',
- 'icap_profile': 'test_value_7',
- 'ips_sensor': 'test_value_8',
- 'name': 'default_name_9',
- 'profile_protocol_options': 'test_value_10',
- 'spamfilter_profile': 'test_value_11',
- 'ssh_filter_profile': 'test_value_12',
- 'ssl_ssh_profile': 'test_value_13',
- 'voip_profile': 'test_value_14',
- 'waf_profile': 'test_value_15',
- 'webfilter_profile': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_group.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'application-list': 'test_value_3',
- 'av-profile': 'test_value_4',
- 'dlp-sensor': 'test_value_5',
- 'dnsfilter-profile': 'test_value_6',
- 'icap-profile': 'test_value_7',
- 'ips-sensor': 'test_value_8',
- 'name': 'default_name_9',
- 'profile-protocol-options': 'test_value_10',
- 'spamfilter-profile': 'test_value_11',
- 'ssh-filter-profile': 'test_value_12',
- 'ssl-ssh-profile': 'test_value_13',
- 'voip-profile': 'test_value_14',
- 'waf-profile': 'test_value_15',
- 'webfilter-profile': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('firewall', 'profile-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_profile_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_profile_group': {
- 'application_list': 'test_value_3',
- 'av_profile': 'test_value_4',
- 'dlp_sensor': 'test_value_5',
- 'dnsfilter_profile': 'test_value_6',
- 'icap_profile': 'test_value_7',
- 'ips_sensor': 'test_value_8',
- 'name': 'default_name_9',
- 'profile_protocol_options': 'test_value_10',
- 'spamfilter_profile': 'test_value_11',
- 'ssh_filter_profile': 'test_value_12',
- 'ssl_ssh_profile': 'test_value_13',
- 'voip_profile': 'test_value_14',
- 'waf_profile': 'test_value_15',
- 'webfilter_profile': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_group.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'profile-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_profile_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_profile_group': {
- 'application_list': 'test_value_3',
- 'av_profile': 'test_value_4',
- 'dlp_sensor': 'test_value_5',
- 'dnsfilter_profile': 'test_value_6',
- 'icap_profile': 'test_value_7',
- 'ips_sensor': 'test_value_8',
- 'name': 'default_name_9',
- 'profile_protocol_options': 'test_value_10',
- 'spamfilter_profile': 'test_value_11',
- 'ssh_filter_profile': 'test_value_12',
- 'ssl_ssh_profile': 'test_value_13',
- 'voip_profile': 'test_value_14',
- 'waf_profile': 'test_value_15',
- 'webfilter_profile': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_group.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'profile-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_profile_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_profile_group': {
- 'application_list': 'test_value_3',
- 'av_profile': 'test_value_4',
- 'dlp_sensor': 'test_value_5',
- 'dnsfilter_profile': 'test_value_6',
- 'icap_profile': 'test_value_7',
- 'ips_sensor': 'test_value_8',
- 'name': 'default_name_9',
- 'profile_protocol_options': 'test_value_10',
- 'spamfilter_profile': 'test_value_11',
- 'ssh_filter_profile': 'test_value_12',
- 'ssl_ssh_profile': 'test_value_13',
- 'voip_profile': 'test_value_14',
- 'waf_profile': 'test_value_15',
- 'webfilter_profile': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_group.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'application-list': 'test_value_3',
- 'av-profile': 'test_value_4',
- 'dlp-sensor': 'test_value_5',
- 'dnsfilter-profile': 'test_value_6',
- 'icap-profile': 'test_value_7',
- 'ips-sensor': 'test_value_8',
- 'name': 'default_name_9',
- 'profile-protocol-options': 'test_value_10',
- 'spamfilter-profile': 'test_value_11',
- 'ssh-filter-profile': 'test_value_12',
- 'ssl-ssh-profile': 'test_value_13',
- 'voip-profile': 'test_value_14',
- 'waf-profile': 'test_value_15',
- 'webfilter-profile': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('firewall', 'profile-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_profile_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_profile_group': {
- 'random_attribute_not_valid': 'tag',
- 'application_list': 'test_value_3',
- 'av_profile': 'test_value_4',
- 'dlp_sensor': 'test_value_5',
- 'dnsfilter_profile': 'test_value_6',
- 'icap_profile': 'test_value_7',
- 'ips_sensor': 'test_value_8',
- 'name': 'default_name_9',
- 'profile_protocol_options': 'test_value_10',
- 'spamfilter_profile': 'test_value_11',
- 'ssh_filter_profile': 'test_value_12',
- 'ssl_ssh_profile': 'test_value_13',
- 'voip_profile': 'test_value_14',
- 'waf_profile': 'test_value_15',
- 'webfilter_profile': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_group.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'application-list': 'test_value_3',
- 'av-profile': 'test_value_4',
- 'dlp-sensor': 'test_value_5',
- 'dnsfilter-profile': 'test_value_6',
- 'icap-profile': 'test_value_7',
- 'ips-sensor': 'test_value_8',
- 'name': 'default_name_9',
- 'profile-protocol-options': 'test_value_10',
- 'spamfilter-profile': 'test_value_11',
- 'ssh-filter-profile': 'test_value_12',
- 'ssl-ssh-profile': 'test_value_13',
- 'voip-profile': 'test_value_14',
- 'waf-profile': 'test_value_15',
- 'webfilter-profile': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('firewall', 'profile-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_profile_protocol_options.py b/test/units/modules/network/fortios/test_fortios_firewall_profile_protocol_options.py
deleted file mode 100644
index a2749061dc..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_profile_protocol_options.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_profile_protocol_options
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_profile_protocol_options.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_profile_protocol_options_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_profile_protocol_options': {
- 'comment': 'Optional comments.',
- 'name': 'default_name_4',
- 'oversize_log': 'disable',
- 'replacemsg_group': 'test_value_6',
- 'rpc_over_http': 'enable',
- 'switching_protocols_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_protocol_options.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'name': 'default_name_4',
- 'oversize-log': 'disable',
- 'replacemsg-group': 'test_value_6',
- 'rpc-over-http': 'enable',
- 'switching-protocols-log': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'profile-protocol-options', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_profile_protocol_options_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_profile_protocol_options': {
- 'comment': 'Optional comments.',
- 'name': 'default_name_4',
- 'oversize_log': 'disable',
- 'replacemsg_group': 'test_value_6',
- 'rpc_over_http': 'enable',
- 'switching_protocols_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_protocol_options.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'name': 'default_name_4',
- 'oversize-log': 'disable',
- 'replacemsg-group': 'test_value_6',
- 'rpc-over-http': 'enable',
- 'switching-protocols-log': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'profile-protocol-options', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_profile_protocol_options_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_profile_protocol_options': {
- 'comment': 'Optional comments.',
- 'name': 'default_name_4',
- 'oversize_log': 'disable',
- 'replacemsg_group': 'test_value_6',
- 'rpc_over_http': 'enable',
- 'switching_protocols_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_protocol_options.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'profile-protocol-options', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_profile_protocol_options_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_profile_protocol_options': {
- 'comment': 'Optional comments.',
- 'name': 'default_name_4',
- 'oversize_log': 'disable',
- 'replacemsg_group': 'test_value_6',
- 'rpc_over_http': 'enable',
- 'switching_protocols_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_protocol_options.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'profile-protocol-options', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_profile_protocol_options_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_profile_protocol_options': {
- 'comment': 'Optional comments.',
- 'name': 'default_name_4',
- 'oversize_log': 'disable',
- 'replacemsg_group': 'test_value_6',
- 'rpc_over_http': 'enable',
- 'switching_protocols_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_protocol_options.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'name': 'default_name_4',
- 'oversize-log': 'disable',
- 'replacemsg-group': 'test_value_6',
- 'rpc-over-http': 'enable',
- 'switching-protocols-log': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'profile-protocol-options', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_profile_protocol_options_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_profile_protocol_options': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'name': 'default_name_4',
- 'oversize_log': 'disable',
- 'replacemsg_group': 'test_value_6',
- 'rpc_over_http': 'enable',
- 'switching_protocols_log': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_profile_protocol_options.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'name': 'default_name_4',
- 'oversize-log': 'disable',
- 'replacemsg-group': 'test_value_6',
- 'rpc-over-http': 'enable',
- 'switching-protocols-log': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'profile-protocol-options', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_proxy_address.py b/test/units/modules/network/fortios/test_fortios_firewall_proxy_address.py
deleted file mode 100644
index c0e77cbb8d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_proxy_address.py
+++ /dev/null
@@ -1,349 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_proxy_address
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_proxy_address.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_proxy_address_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_address': {
- 'case_sensitivity': 'disable',
- 'color': '4',
- 'comment': 'Optional comments.',
- 'header': 'test_value_6',
- 'header_name': 'test_value_7',
- 'host': 'myhostname8',
- 'host_regex': 'myhostname9',
- 'method': 'get',
- 'name': 'default_name_11',
- 'path': 'test_value_12',
- 'query': 'test_value_13',
- 'referrer': 'enable',
- 'type': 'host-regex',
- 'ua': 'chrome',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'case-sensitivity': 'disable',
- 'color': '4',
- 'comment': 'Optional comments.',
- 'header': 'test_value_6',
- 'header-name': 'test_value_7',
- 'host': 'myhostname8',
- 'host-regex': 'myhostname9',
- 'method': 'get',
- 'name': 'default_name_11',
- 'path': 'test_value_12',
- 'query': 'test_value_13',
- 'referrer': 'enable',
- 'type': 'host-regex',
- 'ua': 'chrome',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_proxy_address_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_address': {
- 'case_sensitivity': 'disable',
- 'color': '4',
- 'comment': 'Optional comments.',
- 'header': 'test_value_6',
- 'header_name': 'test_value_7',
- 'host': 'myhostname8',
- 'host_regex': 'myhostname9',
- 'method': 'get',
- 'name': 'default_name_11',
- 'path': 'test_value_12',
- 'query': 'test_value_13',
- 'referrer': 'enable',
- 'type': 'host-regex',
- 'ua': 'chrome',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'case-sensitivity': 'disable',
- 'color': '4',
- 'comment': 'Optional comments.',
- 'header': 'test_value_6',
- 'header-name': 'test_value_7',
- 'host': 'myhostname8',
- 'host-regex': 'myhostname9',
- 'method': 'get',
- 'name': 'default_name_11',
- 'path': 'test_value_12',
- 'query': 'test_value_13',
- 'referrer': 'enable',
- 'type': 'host-regex',
- 'ua': 'chrome',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_proxy_address_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_proxy_address': {
- 'case_sensitivity': 'disable',
- 'color': '4',
- 'comment': 'Optional comments.',
- 'header': 'test_value_6',
- 'header_name': 'test_value_7',
- 'host': 'myhostname8',
- 'host_regex': 'myhostname9',
- 'method': 'get',
- 'name': 'default_name_11',
- 'path': 'test_value_12',
- 'query': 'test_value_13',
- 'referrer': 'enable',
- 'type': 'host-regex',
- 'ua': 'chrome',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_address.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'proxy-address', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_proxy_address_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_proxy_address': {
- 'case_sensitivity': 'disable',
- 'color': '4',
- 'comment': 'Optional comments.',
- 'header': 'test_value_6',
- 'header_name': 'test_value_7',
- 'host': 'myhostname8',
- 'host_regex': 'myhostname9',
- 'method': 'get',
- 'name': 'default_name_11',
- 'path': 'test_value_12',
- 'query': 'test_value_13',
- 'referrer': 'enable',
- 'type': 'host-regex',
- 'ua': 'chrome',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_address.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'proxy-address', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_proxy_address_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_address': {
- 'case_sensitivity': 'disable',
- 'color': '4',
- 'comment': 'Optional comments.',
- 'header': 'test_value_6',
- 'header_name': 'test_value_7',
- 'host': 'myhostname8',
- 'host_regex': 'myhostname9',
- 'method': 'get',
- 'name': 'default_name_11',
- 'path': 'test_value_12',
- 'query': 'test_value_13',
- 'referrer': 'enable',
- 'type': 'host-regex',
- 'ua': 'chrome',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'case-sensitivity': 'disable',
- 'color': '4',
- 'comment': 'Optional comments.',
- 'header': 'test_value_6',
- 'header-name': 'test_value_7',
- 'host': 'myhostname8',
- 'host-regex': 'myhostname9',
- 'method': 'get',
- 'name': 'default_name_11',
- 'path': 'test_value_12',
- 'query': 'test_value_13',
- 'referrer': 'enable',
- 'type': 'host-regex',
- 'ua': 'chrome',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_proxy_address_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_address': {
- 'random_attribute_not_valid': 'tag',
- 'case_sensitivity': 'disable',
- 'color': '4',
- 'comment': 'Optional comments.',
- 'header': 'test_value_6',
- 'header_name': 'test_value_7',
- 'host': 'myhostname8',
- 'host_regex': 'myhostname9',
- 'method': 'get',
- 'name': 'default_name_11',
- 'path': 'test_value_12',
- 'query': 'test_value_13',
- 'referrer': 'enable',
- 'type': 'host-regex',
- 'ua': 'chrome',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_address.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'case-sensitivity': 'disable',
- 'color': '4',
- 'comment': 'Optional comments.',
- 'header': 'test_value_6',
- 'header-name': 'test_value_7',
- 'host': 'myhostname8',
- 'host-regex': 'myhostname9',
- 'method': 'get',
- 'name': 'default_name_11',
- 'path': 'test_value_12',
- 'query': 'test_value_13',
- 'referrer': 'enable',
- 'type': 'host-regex',
- 'ua': 'chrome',
- 'uuid': 'test_value_17',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-address', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_proxy_addrgrp.py b/test/units/modules/network/fortios/test_fortios_firewall_proxy_addrgrp.py
deleted file mode 100644
index 7bc4477485..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_proxy_addrgrp.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_proxy_addrgrp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_proxy_addrgrp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_proxy_addrgrp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_addrgrp': {
- 'color': '3',
- 'comment': 'Optional comments.',
- 'name': 'default_name_5',
- 'type': 'src',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_addrgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Optional comments.',
- 'name': 'default_name_5',
- 'type': 'src',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-addrgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_proxy_addrgrp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_addrgrp': {
- 'color': '3',
- 'comment': 'Optional comments.',
- 'name': 'default_name_5',
- 'type': 'src',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_addrgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Optional comments.',
- 'name': 'default_name_5',
- 'type': 'src',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-addrgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_proxy_addrgrp_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_proxy_addrgrp': {
- 'color': '3',
- 'comment': 'Optional comments.',
- 'name': 'default_name_5',
- 'type': 'src',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_addrgrp.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'proxy-addrgrp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_proxy_addrgrp_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_proxy_addrgrp': {
- 'color': '3',
- 'comment': 'Optional comments.',
- 'name': 'default_name_5',
- 'type': 'src',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_addrgrp.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'proxy-addrgrp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_proxy_addrgrp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_addrgrp': {
- 'color': '3',
- 'comment': 'Optional comments.',
- 'name': 'default_name_5',
- 'type': 'src',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_addrgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Optional comments.',
- 'name': 'default_name_5',
- 'type': 'src',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-addrgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_proxy_addrgrp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_addrgrp': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'comment': 'Optional comments.',
- 'name': 'default_name_5',
- 'type': 'src',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_addrgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Optional comments.',
- 'name': 'default_name_5',
- 'type': 'src',
- 'uuid': 'test_value_7',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-addrgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_proxy_policy.py b/test/units/modules/network/fortios/test_fortios_firewall_proxy_policy.py
deleted file mode 100644
index 72609465ef..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_proxy_policy.py
+++ /dev/null
@@ -1,599 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_proxy_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_proxy_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_proxy_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_policy': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'disclaimer': 'disable',
- 'dlp_sensor': 'test_value_8',
- 'dstaddr_negate': 'enable',
- 'global_label': 'test_value_10',
- 'http_tunnel_auth': 'enable',
- 'icap_profile': 'test_value_12',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'ips_sensor': 'test_value_15',
- 'label': 'test_value_16',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'policyid': '19',
- 'profile_group': 'test_value_20',
- 'profile_protocol_options': 'test_value_21',
- 'profile_type': 'single',
- 'proxy': 'explicit-web',
- 'redirect_url': 'test_value_24',
- 'replacemsg_override_group': 'test_value_25',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_27',
- 'service_negate': 'enable',
- 'session_ttl': '29',
- 'spamfilter_profile': 'test_value_30',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_32',
- 'ssl_ssh_profile': 'test_value_33',
- 'status': 'enable',
- 'transparent': 'enable',
- 'utm_status': 'enable',
- 'uuid': 'test_value_37',
- 'waf_profile': 'test_value_38',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_41',
- 'webproxy_forward_server': 'test_value_42',
- 'webproxy_profile': 'test_value_43'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'av-profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'disclaimer': 'disable',
- 'dlp-sensor': 'test_value_8',
- 'dstaddr-negate': 'enable',
- 'global-label': 'test_value_10',
- 'http-tunnel-auth': 'enable',
- 'icap-profile': 'test_value_12',
- 'internet-service': 'enable',
- 'internet-service-negate': 'enable',
- 'ips-sensor': 'test_value_15',
- 'label': 'test_value_16',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'policyid': '19',
- 'profile-group': 'test_value_20',
- 'profile-protocol-options': 'test_value_21',
- 'profile-type': 'single',
- 'proxy': 'explicit-web',
- 'redirect-url': 'test_value_24',
- 'replacemsg-override-group': 'test_value_25',
- 'scan-botnet-connections': 'disable',
- 'schedule': 'test_value_27',
- 'service-negate': 'enable',
- 'session-ttl': '29',
- 'spamfilter-profile': 'test_value_30',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_32',
- 'ssl-ssh-profile': 'test_value_33',
- 'status': 'enable',
- 'transparent': 'enable',
- 'utm-status': 'enable',
- 'uuid': 'test_value_37',
- 'waf-profile': 'test_value_38',
- 'webcache': 'enable',
- 'webcache-https': 'disable',
- 'webfilter-profile': 'test_value_41',
- 'webproxy-forward-server': 'test_value_42',
- 'webproxy-profile': 'test_value_43'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_proxy_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_policy': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'disclaimer': 'disable',
- 'dlp_sensor': 'test_value_8',
- 'dstaddr_negate': 'enable',
- 'global_label': 'test_value_10',
- 'http_tunnel_auth': 'enable',
- 'icap_profile': 'test_value_12',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'ips_sensor': 'test_value_15',
- 'label': 'test_value_16',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'policyid': '19',
- 'profile_group': 'test_value_20',
- 'profile_protocol_options': 'test_value_21',
- 'profile_type': 'single',
- 'proxy': 'explicit-web',
- 'redirect_url': 'test_value_24',
- 'replacemsg_override_group': 'test_value_25',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_27',
- 'service_negate': 'enable',
- 'session_ttl': '29',
- 'spamfilter_profile': 'test_value_30',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_32',
- 'ssl_ssh_profile': 'test_value_33',
- 'status': 'enable',
- 'transparent': 'enable',
- 'utm_status': 'enable',
- 'uuid': 'test_value_37',
- 'waf_profile': 'test_value_38',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_41',
- 'webproxy_forward_server': 'test_value_42',
- 'webproxy_profile': 'test_value_43'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'av-profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'disclaimer': 'disable',
- 'dlp-sensor': 'test_value_8',
- 'dstaddr-negate': 'enable',
- 'global-label': 'test_value_10',
- 'http-tunnel-auth': 'enable',
- 'icap-profile': 'test_value_12',
- 'internet-service': 'enable',
- 'internet-service-negate': 'enable',
- 'ips-sensor': 'test_value_15',
- 'label': 'test_value_16',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'policyid': '19',
- 'profile-group': 'test_value_20',
- 'profile-protocol-options': 'test_value_21',
- 'profile-type': 'single',
- 'proxy': 'explicit-web',
- 'redirect-url': 'test_value_24',
- 'replacemsg-override-group': 'test_value_25',
- 'scan-botnet-connections': 'disable',
- 'schedule': 'test_value_27',
- 'service-negate': 'enable',
- 'session-ttl': '29',
- 'spamfilter-profile': 'test_value_30',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_32',
- 'ssl-ssh-profile': 'test_value_33',
- 'status': 'enable',
- 'transparent': 'enable',
- 'utm-status': 'enable',
- 'uuid': 'test_value_37',
- 'waf-profile': 'test_value_38',
- 'webcache': 'enable',
- 'webcache-https': 'disable',
- 'webfilter-profile': 'test_value_41',
- 'webproxy-forward-server': 'test_value_42',
- 'webproxy-profile': 'test_value_43'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_proxy_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_proxy_policy': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'disclaimer': 'disable',
- 'dlp_sensor': 'test_value_8',
- 'dstaddr_negate': 'enable',
- 'global_label': 'test_value_10',
- 'http_tunnel_auth': 'enable',
- 'icap_profile': 'test_value_12',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'ips_sensor': 'test_value_15',
- 'label': 'test_value_16',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'policyid': '19',
- 'profile_group': 'test_value_20',
- 'profile_protocol_options': 'test_value_21',
- 'profile_type': 'single',
- 'proxy': 'explicit-web',
- 'redirect_url': 'test_value_24',
- 'replacemsg_override_group': 'test_value_25',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_27',
- 'service_negate': 'enable',
- 'session_ttl': '29',
- 'spamfilter_profile': 'test_value_30',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_32',
- 'ssl_ssh_profile': 'test_value_33',
- 'status': 'enable',
- 'transparent': 'enable',
- 'utm_status': 'enable',
- 'uuid': 'test_value_37',
- 'waf_profile': 'test_value_38',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_41',
- 'webproxy_forward_server': 'test_value_42',
- 'webproxy_profile': 'test_value_43'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'proxy-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_proxy_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_proxy_policy': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'disclaimer': 'disable',
- 'dlp_sensor': 'test_value_8',
- 'dstaddr_negate': 'enable',
- 'global_label': 'test_value_10',
- 'http_tunnel_auth': 'enable',
- 'icap_profile': 'test_value_12',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'ips_sensor': 'test_value_15',
- 'label': 'test_value_16',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'policyid': '19',
- 'profile_group': 'test_value_20',
- 'profile_protocol_options': 'test_value_21',
- 'profile_type': 'single',
- 'proxy': 'explicit-web',
- 'redirect_url': 'test_value_24',
- 'replacemsg_override_group': 'test_value_25',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_27',
- 'service_negate': 'enable',
- 'session_ttl': '29',
- 'spamfilter_profile': 'test_value_30',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_32',
- 'ssl_ssh_profile': 'test_value_33',
- 'status': 'enable',
- 'transparent': 'enable',
- 'utm_status': 'enable',
- 'uuid': 'test_value_37',
- 'waf_profile': 'test_value_38',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_41',
- 'webproxy_forward_server': 'test_value_42',
- 'webproxy_profile': 'test_value_43'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'proxy-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_proxy_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_policy': {
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'disclaimer': 'disable',
- 'dlp_sensor': 'test_value_8',
- 'dstaddr_negate': 'enable',
- 'global_label': 'test_value_10',
- 'http_tunnel_auth': 'enable',
- 'icap_profile': 'test_value_12',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'ips_sensor': 'test_value_15',
- 'label': 'test_value_16',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'policyid': '19',
- 'profile_group': 'test_value_20',
- 'profile_protocol_options': 'test_value_21',
- 'profile_type': 'single',
- 'proxy': 'explicit-web',
- 'redirect_url': 'test_value_24',
- 'replacemsg_override_group': 'test_value_25',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_27',
- 'service_negate': 'enable',
- 'session_ttl': '29',
- 'spamfilter_profile': 'test_value_30',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_32',
- 'ssl_ssh_profile': 'test_value_33',
- 'status': 'enable',
- 'transparent': 'enable',
- 'utm_status': 'enable',
- 'uuid': 'test_value_37',
- 'waf_profile': 'test_value_38',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_41',
- 'webproxy_forward_server': 'test_value_42',
- 'webproxy_profile': 'test_value_43'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'av-profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'disclaimer': 'disable',
- 'dlp-sensor': 'test_value_8',
- 'dstaddr-negate': 'enable',
- 'global-label': 'test_value_10',
- 'http-tunnel-auth': 'enable',
- 'icap-profile': 'test_value_12',
- 'internet-service': 'enable',
- 'internet-service-negate': 'enable',
- 'ips-sensor': 'test_value_15',
- 'label': 'test_value_16',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'policyid': '19',
- 'profile-group': 'test_value_20',
- 'profile-protocol-options': 'test_value_21',
- 'profile-type': 'single',
- 'proxy': 'explicit-web',
- 'redirect-url': 'test_value_24',
- 'replacemsg-override-group': 'test_value_25',
- 'scan-botnet-connections': 'disable',
- 'schedule': 'test_value_27',
- 'service-negate': 'enable',
- 'session-ttl': '29',
- 'spamfilter-profile': 'test_value_30',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_32',
- 'ssl-ssh-profile': 'test_value_33',
- 'status': 'enable',
- 'transparent': 'enable',
- 'utm-status': 'enable',
- 'uuid': 'test_value_37',
- 'waf-profile': 'test_value_38',
- 'webcache': 'enable',
- 'webcache-https': 'disable',
- 'webfilter-profile': 'test_value_41',
- 'webproxy-forward-server': 'test_value_42',
- 'webproxy-profile': 'test_value_43'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_proxy_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_proxy_policy': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'accept',
- 'application_list': 'test_value_4',
- 'av_profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'disclaimer': 'disable',
- 'dlp_sensor': 'test_value_8',
- 'dstaddr_negate': 'enable',
- 'global_label': 'test_value_10',
- 'http_tunnel_auth': 'enable',
- 'icap_profile': 'test_value_12',
- 'internet_service': 'enable',
- 'internet_service_negate': 'enable',
- 'ips_sensor': 'test_value_15',
- 'label': 'test_value_16',
- 'logtraffic': 'all',
- 'logtraffic_start': 'enable',
- 'policyid': '19',
- 'profile_group': 'test_value_20',
- 'profile_protocol_options': 'test_value_21',
- 'profile_type': 'single',
- 'proxy': 'explicit-web',
- 'redirect_url': 'test_value_24',
- 'replacemsg_override_group': 'test_value_25',
- 'scan_botnet_connections': 'disable',
- 'schedule': 'test_value_27',
- 'service_negate': 'enable',
- 'session_ttl': '29',
- 'spamfilter_profile': 'test_value_30',
- 'srcaddr_negate': 'enable',
- 'ssh_filter_profile': 'test_value_32',
- 'ssl_ssh_profile': 'test_value_33',
- 'status': 'enable',
- 'transparent': 'enable',
- 'utm_status': 'enable',
- 'uuid': 'test_value_37',
- 'waf_profile': 'test_value_38',
- 'webcache': 'enable',
- 'webcache_https': 'disable',
- 'webfilter_profile': 'test_value_41',
- 'webproxy_forward_server': 'test_value_42',
- 'webproxy_profile': 'test_value_43'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_proxy_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'application-list': 'test_value_4',
- 'av-profile': 'test_value_5',
- 'comments': 'test_value_6',
- 'disclaimer': 'disable',
- 'dlp-sensor': 'test_value_8',
- 'dstaddr-negate': 'enable',
- 'global-label': 'test_value_10',
- 'http-tunnel-auth': 'enable',
- 'icap-profile': 'test_value_12',
- 'internet-service': 'enable',
- 'internet-service-negate': 'enable',
- 'ips-sensor': 'test_value_15',
- 'label': 'test_value_16',
- 'logtraffic': 'all',
- 'logtraffic-start': 'enable',
- 'policyid': '19',
- 'profile-group': 'test_value_20',
- 'profile-protocol-options': 'test_value_21',
- 'profile-type': 'single',
- 'proxy': 'explicit-web',
- 'redirect-url': 'test_value_24',
- 'replacemsg-override-group': 'test_value_25',
- 'scan-botnet-connections': 'disable',
- 'schedule': 'test_value_27',
- 'service-negate': 'enable',
- 'session-ttl': '29',
- 'spamfilter-profile': 'test_value_30',
- 'srcaddr-negate': 'enable',
- 'ssh-filter-profile': 'test_value_32',
- 'ssl-ssh-profile': 'test_value_33',
- 'status': 'enable',
- 'transparent': 'enable',
- 'utm-status': 'enable',
- 'uuid': 'test_value_37',
- 'waf-profile': 'test_value_38',
- 'webcache': 'enable',
- 'webcache-https': 'disable',
- 'webfilter-profile': 'test_value_41',
- 'webproxy-forward-server': 'test_value_42',
- 'webproxy-profile': 'test_value_43'
- }
-
- set_method_mock.assert_called_with('firewall', 'proxy-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_schedule_group.py b/test/units/modules/network/fortios/test_fortios_firewall_schedule_group.py
deleted file mode 100644
index 5d0ffac12b..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_schedule_group.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_schedule_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_schedule_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_schedule_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_group': {
- 'color': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_group.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_schedule_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_group': {
- 'color': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_group.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_schedule_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_schedule_group': {
- 'color': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_group.fortios_firewall_schedule(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.schedule', 'group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_schedule_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_schedule_group': {
- 'color': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_group.fortios_firewall_schedule(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.schedule', 'group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_schedule_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_group': {
- 'color': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_group.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_schedule_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_group': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_group.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_schedule_onetime.py b/test/units/modules/network/fortios/test_fortios_firewall_schedule_onetime.py
deleted file mode 100644
index ff6f09434a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_schedule_onetime.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_schedule_onetime
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_schedule_onetime.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_schedule_onetime_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_onetime': {
- 'color': '3',
- 'end': 'test_value_4',
- 'expiration_days': '5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_onetime.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'end': 'test_value_4',
- 'expiration-days': '5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'onetime', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_schedule_onetime_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_onetime': {
- 'color': '3',
- 'end': 'test_value_4',
- 'expiration_days': '5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_onetime.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'end': 'test_value_4',
- 'expiration-days': '5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'onetime', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_schedule_onetime_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_schedule_onetime': {
- 'color': '3',
- 'end': 'test_value_4',
- 'expiration_days': '5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_onetime.fortios_firewall_schedule(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.schedule', 'onetime', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_schedule_onetime_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_schedule_onetime': {
- 'color': '3',
- 'end': 'test_value_4',
- 'expiration_days': '5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_onetime.fortios_firewall_schedule(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.schedule', 'onetime', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_schedule_onetime_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_onetime': {
- 'color': '3',
- 'end': 'test_value_4',
- 'expiration_days': '5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_onetime.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'end': 'test_value_4',
- 'expiration-days': '5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'onetime', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_schedule_onetime_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_onetime': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'end': 'test_value_4',
- 'expiration_days': '5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_onetime.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'end': 'test_value_4',
- 'expiration-days': '5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'onetime', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_schedule_recurring.py b/test/units/modules/network/fortios/test_fortios_firewall_schedule_recurring.py
deleted file mode 100644
index 8a1463a683..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_schedule_recurring.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_schedule_recurring
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_schedule_recurring.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_schedule_recurring_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_recurring': {
- 'color': '3',
- 'day': 'sunday',
- 'end': 'test_value_5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_recurring.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'day': 'sunday',
- 'end': 'test_value_5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'recurring', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_schedule_recurring_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_recurring': {
- 'color': '3',
- 'day': 'sunday',
- 'end': 'test_value_5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_recurring.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'day': 'sunday',
- 'end': 'test_value_5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'recurring', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_schedule_recurring_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_schedule_recurring': {
- 'color': '3',
- 'day': 'sunday',
- 'end': 'test_value_5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_recurring.fortios_firewall_schedule(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.schedule', 'recurring', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_schedule_recurring_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_schedule_recurring': {
- 'color': '3',
- 'day': 'sunday',
- 'end': 'test_value_5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_recurring.fortios_firewall_schedule(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.schedule', 'recurring', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_schedule_recurring_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_recurring': {
- 'color': '3',
- 'day': 'sunday',
- 'end': 'test_value_5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_recurring.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'day': 'sunday',
- 'end': 'test_value_5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'recurring', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_schedule_recurring_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_schedule_recurring': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'day': 'sunday',
- 'end': 'test_value_5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_schedule_recurring.fortios_firewall_schedule(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'day': 'sunday',
- 'end': 'test_value_5',
- 'name': 'default_name_6',
- 'start': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall.schedule', 'recurring', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_service_category.py b/test/units/modules/network/fortios/test_fortios_firewall_service_category.py
deleted file mode 100644
index 2c896c3c4a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_service_category.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_service_category
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_service_category.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_service_category_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_category': {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_category.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'category', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_service_category_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_category': {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_category.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'category', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_service_category_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_service_category': {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_category.fortios_firewall_service(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.service', 'category', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_service_category_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_service_category': {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_category.fortios_firewall_service(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.service', 'category', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_service_category_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_category': {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_category.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'category', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_service_category_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_category': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_category.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'category', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_service_custom.py b/test/units/modules/network/fortios/test_fortios_firewall_service_custom.py
deleted file mode 100644
index 15eae37fdb..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_service_custom.py
+++ /dev/null
@@ -1,409 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_service_custom
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_service_custom.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_service_custom_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_custom': {'app_service_type': 'disable',
- 'category': 'test_value_4',
- 'check_reset_range': 'disable',
- 'color': '6',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_8',
- 'helper': 'auto',
- 'icmpcode': '10',
- 'icmptype': '11',
- 'iprange': 'test_value_12',
- 'name': 'default_name_13',
- 'protocol': 'TCP/UDP/SCTP',
- 'protocol_number': '15',
- 'proxy': 'enable',
- 'sctp_portrange': 'test_value_17',
- 'session_ttl': '18',
- 'tcp_halfclose_timer': '19',
- 'tcp_halfopen_timer': '20',
- 'tcp_portrange': 'test_value_21',
- 'tcp_timewait_timer': '22',
- 'udp_idle_timer': '23',
- 'udp_portrange': 'test_value_24',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_custom.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {'app-service-type': 'disable',
- 'category': 'test_value_4',
- 'check-reset-range': 'disable',
- 'color': '6',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_8',
- 'helper': 'auto',
- 'icmpcode': '10',
- 'icmptype': '11',
- 'iprange': 'test_value_12',
- 'name': 'default_name_13',
- 'protocol': 'TCP/UDP/SCTP',
- 'protocol-number': '15',
- 'proxy': 'enable',
- 'sctp-portrange': 'test_value_17',
- 'session-ttl': '18',
- 'tcp-halfclose-timer': '19',
- 'tcp-halfopen-timer': '20',
- 'tcp-portrange': 'test_value_21',
- 'tcp-timewait-timer': '22',
- 'udp-idle-timer': '23',
- 'udp-portrange': 'test_value_24',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_service_custom_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_custom': {'app_service_type': 'disable',
- 'category': 'test_value_4',
- 'check_reset_range': 'disable',
- 'color': '6',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_8',
- 'helper': 'auto',
- 'icmpcode': '10',
- 'icmptype': '11',
- 'iprange': 'test_value_12',
- 'name': 'default_name_13',
- 'protocol': 'TCP/UDP/SCTP',
- 'protocol_number': '15',
- 'proxy': 'enable',
- 'sctp_portrange': 'test_value_17',
- 'session_ttl': '18',
- 'tcp_halfclose_timer': '19',
- 'tcp_halfopen_timer': '20',
- 'tcp_portrange': 'test_value_21',
- 'tcp_timewait_timer': '22',
- 'udp_idle_timer': '23',
- 'udp_portrange': 'test_value_24',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_custom.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {'app-service-type': 'disable',
- 'category': 'test_value_4',
- 'check-reset-range': 'disable',
- 'color': '6',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_8',
- 'helper': 'auto',
- 'icmpcode': '10',
- 'icmptype': '11',
- 'iprange': 'test_value_12',
- 'name': 'default_name_13',
- 'protocol': 'TCP/UDP/SCTP',
- 'protocol-number': '15',
- 'proxy': 'enable',
- 'sctp-portrange': 'test_value_17',
- 'session-ttl': '18',
- 'tcp-halfclose-timer': '19',
- 'tcp-halfopen-timer': '20',
- 'tcp-portrange': 'test_value_21',
- 'tcp-timewait-timer': '22',
- 'udp-idle-timer': '23',
- 'udp-portrange': 'test_value_24',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_service_custom_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_service_custom': {'app_service_type': 'disable',
- 'category': 'test_value_4',
- 'check_reset_range': 'disable',
- 'color': '6',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_8',
- 'helper': 'auto',
- 'icmpcode': '10',
- 'icmptype': '11',
- 'iprange': 'test_value_12',
- 'name': 'default_name_13',
- 'protocol': 'TCP/UDP/SCTP',
- 'protocol_number': '15',
- 'proxy': 'enable',
- 'sctp_portrange': 'test_value_17',
- 'session_ttl': '18',
- 'tcp_halfclose_timer': '19',
- 'tcp_halfopen_timer': '20',
- 'tcp_portrange': 'test_value_21',
- 'tcp_timewait_timer': '22',
- 'udp_idle_timer': '23',
- 'udp_portrange': 'test_value_24',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_custom.fortios_firewall_service(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.service', 'custom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_service_custom_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_service_custom': {'app_service_type': 'disable',
- 'category': 'test_value_4',
- 'check_reset_range': 'disable',
- 'color': '6',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_8',
- 'helper': 'auto',
- 'icmpcode': '10',
- 'icmptype': '11',
- 'iprange': 'test_value_12',
- 'name': 'default_name_13',
- 'protocol': 'TCP/UDP/SCTP',
- 'protocol_number': '15',
- 'proxy': 'enable',
- 'sctp_portrange': 'test_value_17',
- 'session_ttl': '18',
- 'tcp_halfclose_timer': '19',
- 'tcp_halfopen_timer': '20',
- 'tcp_portrange': 'test_value_21',
- 'tcp_timewait_timer': '22',
- 'udp_idle_timer': '23',
- 'udp_portrange': 'test_value_24',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_custom.fortios_firewall_service(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.service', 'custom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_service_custom_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_custom': {'app_service_type': 'disable',
- 'category': 'test_value_4',
- 'check_reset_range': 'disable',
- 'color': '6',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_8',
- 'helper': 'auto',
- 'icmpcode': '10',
- 'icmptype': '11',
- 'iprange': 'test_value_12',
- 'name': 'default_name_13',
- 'protocol': 'TCP/UDP/SCTP',
- 'protocol_number': '15',
- 'proxy': 'enable',
- 'sctp_portrange': 'test_value_17',
- 'session_ttl': '18',
- 'tcp_halfclose_timer': '19',
- 'tcp_halfopen_timer': '20',
- 'tcp_portrange': 'test_value_21',
- 'tcp_timewait_timer': '22',
- 'udp_idle_timer': '23',
- 'udp_portrange': 'test_value_24',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_custom.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {'app-service-type': 'disable',
- 'category': 'test_value_4',
- 'check-reset-range': 'disable',
- 'color': '6',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_8',
- 'helper': 'auto',
- 'icmpcode': '10',
- 'icmptype': '11',
- 'iprange': 'test_value_12',
- 'name': 'default_name_13',
- 'protocol': 'TCP/UDP/SCTP',
- 'protocol-number': '15',
- 'proxy': 'enable',
- 'sctp-portrange': 'test_value_17',
- 'session-ttl': '18',
- 'tcp-halfclose-timer': '19',
- 'tcp-halfopen-timer': '20',
- 'tcp-portrange': 'test_value_21',
- 'tcp-timewait-timer': '22',
- 'udp-idle-timer': '23',
- 'udp-portrange': 'test_value_24',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_service_custom_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_custom': {
- 'random_attribute_not_valid': 'tag', 'app_service_type': 'disable',
- 'category': 'test_value_4',
- 'check_reset_range': 'disable',
- 'color': '6',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_8',
- 'helper': 'auto',
- 'icmpcode': '10',
- 'icmptype': '11',
- 'iprange': 'test_value_12',
- 'name': 'default_name_13',
- 'protocol': 'TCP/UDP/SCTP',
- 'protocol_number': '15',
- 'proxy': 'enable',
- 'sctp_portrange': 'test_value_17',
- 'session_ttl': '18',
- 'tcp_halfclose_timer': '19',
- 'tcp_halfopen_timer': '20',
- 'tcp_portrange': 'test_value_21',
- 'tcp_timewait_timer': '22',
- 'udp_idle_timer': '23',
- 'udp_portrange': 'test_value_24',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_custom.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {'app-service-type': 'disable',
- 'category': 'test_value_4',
- 'check-reset-range': 'disable',
- 'color': '6',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_8',
- 'helper': 'auto',
- 'icmpcode': '10',
- 'icmptype': '11',
- 'iprange': 'test_value_12',
- 'name': 'default_name_13',
- 'protocol': 'TCP/UDP/SCTP',
- 'protocol-number': '15',
- 'proxy': 'enable',
- 'sctp-portrange': 'test_value_17',
- 'session-ttl': '18',
- 'tcp-halfclose-timer': '19',
- 'tcp-halfopen-timer': '20',
- 'tcp-portrange': 'test_value_21',
- 'tcp-timewait-timer': '22',
- 'udp-idle-timer': '23',
- 'udp-portrange': 'test_value_24',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_service_group.py b/test/units/modules/network/fortios/test_fortios_firewall_service_group.py
deleted file mode 100644
index 51b36bdba5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_service_group.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_service_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_service_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_service_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_group': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'proxy': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_group.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'proxy': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_service_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_group': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'proxy': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_group.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'proxy': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_service_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_service_group': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'proxy': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_group.fortios_firewall_service(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.service', 'group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_service_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_service_group': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'proxy': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_group.fortios_firewall_service(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.service', 'group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_service_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_group': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'proxy': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_group.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'proxy': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_service_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_service_group': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'proxy': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_service_group.fortios_firewall_service(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'proxy': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.service', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_shaper_per_ip_shaper.py b/test/units/modules/network/fortios/test_fortios_firewall_shaper_per_ip_shaper.py
deleted file mode 100644
index 54fc4a3513..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_shaper_per_ip_shaper.py
+++ /dev/null
@@ -1,269 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_shaper_per_ip_shaper
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_shaper_per_ip_shaper.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_shaper_per_ip_shaper_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaper_per_ip_shaper': {
- 'bandwidth_unit': 'kbps',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_6',
- 'diffservcode_rev': 'test_value_7',
- 'max_bandwidth': '8',
- 'max_concurrent_session': '9',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_per_ip_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-unit': 'kbps',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_6',
- 'diffservcode-rev': 'test_value_7',
- 'max-bandwidth': '8',
- 'max-concurrent-session': '9',
- 'name': 'default_name_10'
- }
-
- set_method_mock.assert_called_with('firewall.shaper', 'per-ip-shaper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_shaper_per_ip_shaper_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaper_per_ip_shaper': {
- 'bandwidth_unit': 'kbps',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_6',
- 'diffservcode_rev': 'test_value_7',
- 'max_bandwidth': '8',
- 'max_concurrent_session': '9',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_per_ip_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-unit': 'kbps',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_6',
- 'diffservcode-rev': 'test_value_7',
- 'max-bandwidth': '8',
- 'max-concurrent-session': '9',
- 'name': 'default_name_10'
- }
-
- set_method_mock.assert_called_with('firewall.shaper', 'per-ip-shaper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_shaper_per_ip_shaper_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_shaper_per_ip_shaper': {
- 'bandwidth_unit': 'kbps',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_6',
- 'diffservcode_rev': 'test_value_7',
- 'max_bandwidth': '8',
- 'max_concurrent_session': '9',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_per_ip_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.shaper', 'per-ip-shaper', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_shaper_per_ip_shaper_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_shaper_per_ip_shaper': {
- 'bandwidth_unit': 'kbps',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_6',
- 'diffservcode_rev': 'test_value_7',
- 'max_bandwidth': '8',
- 'max_concurrent_session': '9',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_per_ip_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.shaper', 'per-ip-shaper', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_shaper_per_ip_shaper_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaper_per_ip_shaper': {
- 'bandwidth_unit': 'kbps',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_6',
- 'diffservcode_rev': 'test_value_7',
- 'max_bandwidth': '8',
- 'max_concurrent_session': '9',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_per_ip_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-unit': 'kbps',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_6',
- 'diffservcode-rev': 'test_value_7',
- 'max-bandwidth': '8',
- 'max-concurrent-session': '9',
- 'name': 'default_name_10'
- }
-
- set_method_mock.assert_called_with('firewall.shaper', 'per-ip-shaper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_shaper_per_ip_shaper_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaper_per_ip_shaper': {
- 'random_attribute_not_valid': 'tag',
- 'bandwidth_unit': 'kbps',
- 'diffserv_forward': 'enable',
- 'diffserv_reverse': 'enable',
- 'diffservcode_forward': 'test_value_6',
- 'diffservcode_rev': 'test_value_7',
- 'max_bandwidth': '8',
- 'max_concurrent_session': '9',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_per_ip_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-unit': 'kbps',
- 'diffserv-forward': 'enable',
- 'diffserv-reverse': 'enable',
- 'diffservcode-forward': 'test_value_6',
- 'diffservcode-rev': 'test_value_7',
- 'max-bandwidth': '8',
- 'max-concurrent-session': '9',
- 'name': 'default_name_10'
- }
-
- set_method_mock.assert_called_with('firewall.shaper', 'per-ip-shaper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_shaper_traffic_shaper.py b/test/units/modules/network/fortios/test_fortios_firewall_shaper_traffic_shaper.py
deleted file mode 100644
index fb62200ae8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_shaper_traffic_shaper.py
+++ /dev/null
@@ -1,269 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_shaper_traffic_shaper
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_shaper_traffic_shaper.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_shaper_traffic_shaper_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaper_traffic_shaper': {
- 'bandwidth_unit': 'kbps',
- 'diffserv': 'enable',
- 'diffservcode': 'test_value_5',
- 'guaranteed_bandwidth': '6',
- 'maximum_bandwidth': '7',
- 'name': 'default_name_8',
- 'per_policy': 'disable',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_traffic_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-unit': 'kbps',
- 'diffserv': 'enable',
- 'diffservcode': 'test_value_5',
- 'guaranteed-bandwidth': '6',
- 'maximum-bandwidth': '7',
- 'name': 'default_name_8',
- 'per-policy': 'disable',
- 'priority': 'low'
- }
-
- set_method_mock.assert_called_with('firewall.shaper', 'traffic-shaper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_shaper_traffic_shaper_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaper_traffic_shaper': {
- 'bandwidth_unit': 'kbps',
- 'diffserv': 'enable',
- 'diffservcode': 'test_value_5',
- 'guaranteed_bandwidth': '6',
- 'maximum_bandwidth': '7',
- 'name': 'default_name_8',
- 'per_policy': 'disable',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_traffic_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-unit': 'kbps',
- 'diffserv': 'enable',
- 'diffservcode': 'test_value_5',
- 'guaranteed-bandwidth': '6',
- 'maximum-bandwidth': '7',
- 'name': 'default_name_8',
- 'per-policy': 'disable',
- 'priority': 'low'
- }
-
- set_method_mock.assert_called_with('firewall.shaper', 'traffic-shaper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_shaper_traffic_shaper_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_shaper_traffic_shaper': {
- 'bandwidth_unit': 'kbps',
- 'diffserv': 'enable',
- 'diffservcode': 'test_value_5',
- 'guaranteed_bandwidth': '6',
- 'maximum_bandwidth': '7',
- 'name': 'default_name_8',
- 'per_policy': 'disable',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_traffic_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.shaper', 'traffic-shaper', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_shaper_traffic_shaper_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_shaper_traffic_shaper': {
- 'bandwidth_unit': 'kbps',
- 'diffserv': 'enable',
- 'diffservcode': 'test_value_5',
- 'guaranteed_bandwidth': '6',
- 'maximum_bandwidth': '7',
- 'name': 'default_name_8',
- 'per_policy': 'disable',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_traffic_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.shaper', 'traffic-shaper', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_shaper_traffic_shaper_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaper_traffic_shaper': {
- 'bandwidth_unit': 'kbps',
- 'diffserv': 'enable',
- 'diffservcode': 'test_value_5',
- 'guaranteed_bandwidth': '6',
- 'maximum_bandwidth': '7',
- 'name': 'default_name_8',
- 'per_policy': 'disable',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_traffic_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-unit': 'kbps',
- 'diffserv': 'enable',
- 'diffservcode': 'test_value_5',
- 'guaranteed-bandwidth': '6',
- 'maximum-bandwidth': '7',
- 'name': 'default_name_8',
- 'per-policy': 'disable',
- 'priority': 'low'
- }
-
- set_method_mock.assert_called_with('firewall.shaper', 'traffic-shaper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_shaper_traffic_shaper_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaper_traffic_shaper': {
- 'random_attribute_not_valid': 'tag',
- 'bandwidth_unit': 'kbps',
- 'diffserv': 'enable',
- 'diffservcode': 'test_value_5',
- 'guaranteed_bandwidth': '6',
- 'maximum_bandwidth': '7',
- 'name': 'default_name_8',
- 'per_policy': 'disable',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaper_traffic_shaper.fortios_firewall_shaper(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-unit': 'kbps',
- 'diffserv': 'enable',
- 'diffservcode': 'test_value_5',
- 'guaranteed-bandwidth': '6',
- 'maximum-bandwidth': '7',
- 'name': 'default_name_8',
- 'per-policy': 'disable',
- 'priority': 'low'
- }
-
- set_method_mock.assert_called_with('firewall.shaper', 'traffic-shaper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_shaping_policy.py b/test/units/modules/network/fortios/test_fortios_firewall_shaping_policy.py
deleted file mode 100644
index d8812a76e5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_shaping_policy.py
+++ /dev/null
@@ -1,299 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_shaping_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_shaping_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_shaping_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaping_policy': {'class_id': '3',
- 'comment': 'Comments.',
- 'id': '5',
- 'internet_service': 'enable',
- 'internet_service_src': 'enable',
- 'ip_version': '4',
- 'per_ip_shaper': 'test_value_9',
- 'schedule': 'test_value_10',
- 'status': 'enable',
- 'traffic_shaper': 'test_value_12',
- 'traffic_shaper_reverse': 'test_value_13',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'class-id': '3',
- 'comment': 'Comments.',
- 'id': '5',
- 'internet-service': 'enable',
- 'internet-service-src': 'enable',
- 'ip-version': '4',
- 'per-ip-shaper': 'test_value_9',
- 'schedule': 'test_value_10',
- 'status': 'enable',
- 'traffic-shaper': 'test_value_12',
- 'traffic-shaper-reverse': 'test_value_13',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'shaping-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_shaping_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaping_policy': {'class_id': '3',
- 'comment': 'Comments.',
- 'id': '5',
- 'internet_service': 'enable',
- 'internet_service_src': 'enable',
- 'ip_version': '4',
- 'per_ip_shaper': 'test_value_9',
- 'schedule': 'test_value_10',
- 'status': 'enable',
- 'traffic_shaper': 'test_value_12',
- 'traffic_shaper_reverse': 'test_value_13',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'class-id': '3',
- 'comment': 'Comments.',
- 'id': '5',
- 'internet-service': 'enable',
- 'internet-service-src': 'enable',
- 'ip-version': '4',
- 'per-ip-shaper': 'test_value_9',
- 'schedule': 'test_value_10',
- 'status': 'enable',
- 'traffic-shaper': 'test_value_12',
- 'traffic-shaper-reverse': 'test_value_13',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'shaping-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_shaping_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_shaping_policy': {'class_id': '3',
- 'comment': 'Comments.',
- 'id': '5',
- 'internet_service': 'enable',
- 'internet_service_src': 'enable',
- 'ip_version': '4',
- 'per_ip_shaper': 'test_value_9',
- 'schedule': 'test_value_10',
- 'status': 'enable',
- 'traffic_shaper': 'test_value_12',
- 'traffic_shaper_reverse': 'test_value_13',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'shaping-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_shaping_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_shaping_policy': {'class_id': '3',
- 'comment': 'Comments.',
- 'id': '5',
- 'internet_service': 'enable',
- 'internet_service_src': 'enable',
- 'ip_version': '4',
- 'per_ip_shaper': 'test_value_9',
- 'schedule': 'test_value_10',
- 'status': 'enable',
- 'traffic_shaper': 'test_value_12',
- 'traffic_shaper_reverse': 'test_value_13',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'shaping-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_shaping_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaping_policy': {'class_id': '3',
- 'comment': 'Comments.',
- 'id': '5',
- 'internet_service': 'enable',
- 'internet_service_src': 'enable',
- 'ip_version': '4',
- 'per_ip_shaper': 'test_value_9',
- 'schedule': 'test_value_10',
- 'status': 'enable',
- 'traffic_shaper': 'test_value_12',
- 'traffic_shaper_reverse': 'test_value_13',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'class-id': '3',
- 'comment': 'Comments.',
- 'id': '5',
- 'internet-service': 'enable',
- 'internet-service-src': 'enable',
- 'ip-version': '4',
- 'per-ip-shaper': 'test_value_9',
- 'schedule': 'test_value_10',
- 'status': 'enable',
- 'traffic-shaper': 'test_value_12',
- 'traffic-shaper-reverse': 'test_value_13',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'shaping-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_shaping_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaping_policy': {
- 'random_attribute_not_valid': 'tag', 'class_id': '3',
- 'comment': 'Comments.',
- 'id': '5',
- 'internet_service': 'enable',
- 'internet_service_src': 'enable',
- 'ip_version': '4',
- 'per_ip_shaper': 'test_value_9',
- 'schedule': 'test_value_10',
- 'status': 'enable',
- 'traffic_shaper': 'test_value_12',
- 'traffic_shaper_reverse': 'test_value_13',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'class-id': '3',
- 'comment': 'Comments.',
- 'id': '5',
- 'internet-service': 'enable',
- 'internet-service-src': 'enable',
- 'ip-version': '4',
- 'per-ip-shaper': 'test_value_9',
- 'schedule': 'test_value_10',
- 'status': 'enable',
- 'traffic-shaper': 'test_value_12',
- 'traffic-shaper-reverse': 'test_value_13',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'shaping-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_shaping_profile.py b/test/units/modules/network/fortios/test_fortios_firewall_shaping_profile.py
deleted file mode 100644
index d9522bc7b0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_shaping_profile.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_shaping_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_shaping_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_shaping_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaping_profile': {
- 'comment': 'Comment.',
- 'default_class_id': '4',
- 'profile_name': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_profile.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'default-class-id': '4',
- 'profile-name': 'test_value_5',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'shaping-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_shaping_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaping_profile': {
- 'comment': 'Comment.',
- 'default_class_id': '4',
- 'profile_name': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_profile.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'default-class-id': '4',
- 'profile-name': 'test_value_5',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'shaping-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_shaping_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_shaping_profile': {
- 'comment': 'Comment.',
- 'default_class_id': '4',
- 'profile_name': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_profile.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'shaping-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_shaping_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_shaping_profile': {
- 'comment': 'Comment.',
- 'default_class_id': '4',
- 'profile_name': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_profile.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'shaping-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_shaping_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaping_profile': {
- 'comment': 'Comment.',
- 'default_class_id': '4',
- 'profile_name': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_profile.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'default-class-id': '4',
- 'profile-name': 'test_value_5',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'shaping-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_shaping_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_shaping_profile': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'default_class_id': '4',
- 'profile_name': 'test_value_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_shaping_profile.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'default-class-id': '4',
- 'profile-name': 'test_value_5',
-
- }
-
- set_method_mock.assert_called_with('firewall', 'shaping-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_sniffer.py b/test/units/modules/network/fortios/test_fortios_firewall_sniffer.py
deleted file mode 100644
index b69e26785c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_sniffer.py
+++ /dev/null
@@ -1,439 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_sniffer
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_sniffer.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_sniffer_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_sniffer': {'application_list': 'test_value_3',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_5',
- 'av_profile_status': 'enable',
- 'dlp_sensor': 'test_value_7',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'host': 'myhostname10',
- 'id': '11',
- 'interface': 'test_value_12',
- 'ips_dos_status': 'enable',
- 'ips_sensor': 'test_value_14',
- 'ips_sensor_status': 'enable',
- 'ipv6': 'enable',
- 'logtraffic': 'all',
- 'max_packet_count': '18',
- 'non_ip': 'enable',
- 'port': 'test_value_20',
- 'protocol': 'test_value_21',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_23',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'vlan': 'test_value_26',
- 'webfilter_profile': 'test_value_27',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_sniffer.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'application-list': 'test_value_3',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_5',
- 'av-profile-status': 'enable',
- 'dlp-sensor': 'test_value_7',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'host': 'myhostname10',
- 'id': '11',
- 'interface': 'test_value_12',
- 'ips-dos-status': 'enable',
- 'ips-sensor': 'test_value_14',
- 'ips-sensor-status': 'enable',
- 'ipv6': 'enable',
- 'logtraffic': 'all',
- 'max-packet-count': '18',
- 'non-ip': 'enable',
- 'port': 'test_value_20',
- 'protocol': 'test_value_21',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_23',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'vlan': 'test_value_26',
- 'webfilter-profile': 'test_value_27',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'sniffer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_sniffer_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_sniffer': {'application_list': 'test_value_3',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_5',
- 'av_profile_status': 'enable',
- 'dlp_sensor': 'test_value_7',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'host': 'myhostname10',
- 'id': '11',
- 'interface': 'test_value_12',
- 'ips_dos_status': 'enable',
- 'ips_sensor': 'test_value_14',
- 'ips_sensor_status': 'enable',
- 'ipv6': 'enable',
- 'logtraffic': 'all',
- 'max_packet_count': '18',
- 'non_ip': 'enable',
- 'port': 'test_value_20',
- 'protocol': 'test_value_21',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_23',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'vlan': 'test_value_26',
- 'webfilter_profile': 'test_value_27',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_sniffer.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'application-list': 'test_value_3',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_5',
- 'av-profile-status': 'enable',
- 'dlp-sensor': 'test_value_7',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'host': 'myhostname10',
- 'id': '11',
- 'interface': 'test_value_12',
- 'ips-dos-status': 'enable',
- 'ips-sensor': 'test_value_14',
- 'ips-sensor-status': 'enable',
- 'ipv6': 'enable',
- 'logtraffic': 'all',
- 'max-packet-count': '18',
- 'non-ip': 'enable',
- 'port': 'test_value_20',
- 'protocol': 'test_value_21',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_23',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'vlan': 'test_value_26',
- 'webfilter-profile': 'test_value_27',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'sniffer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_sniffer_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_sniffer': {'application_list': 'test_value_3',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_5',
- 'av_profile_status': 'enable',
- 'dlp_sensor': 'test_value_7',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'host': 'myhostname10',
- 'id': '11',
- 'interface': 'test_value_12',
- 'ips_dos_status': 'enable',
- 'ips_sensor': 'test_value_14',
- 'ips_sensor_status': 'enable',
- 'ipv6': 'enable',
- 'logtraffic': 'all',
- 'max_packet_count': '18',
- 'non_ip': 'enable',
- 'port': 'test_value_20',
- 'protocol': 'test_value_21',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_23',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'vlan': 'test_value_26',
- 'webfilter_profile': 'test_value_27',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_sniffer.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'sniffer', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_sniffer_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_sniffer': {'application_list': 'test_value_3',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_5',
- 'av_profile_status': 'enable',
- 'dlp_sensor': 'test_value_7',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'host': 'myhostname10',
- 'id': '11',
- 'interface': 'test_value_12',
- 'ips_dos_status': 'enable',
- 'ips_sensor': 'test_value_14',
- 'ips_sensor_status': 'enable',
- 'ipv6': 'enable',
- 'logtraffic': 'all',
- 'max_packet_count': '18',
- 'non_ip': 'enable',
- 'port': 'test_value_20',
- 'protocol': 'test_value_21',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_23',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'vlan': 'test_value_26',
- 'webfilter_profile': 'test_value_27',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_sniffer.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'sniffer', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_sniffer_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_sniffer': {'application_list': 'test_value_3',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_5',
- 'av_profile_status': 'enable',
- 'dlp_sensor': 'test_value_7',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'host': 'myhostname10',
- 'id': '11',
- 'interface': 'test_value_12',
- 'ips_dos_status': 'enable',
- 'ips_sensor': 'test_value_14',
- 'ips_sensor_status': 'enable',
- 'ipv6': 'enable',
- 'logtraffic': 'all',
- 'max_packet_count': '18',
- 'non_ip': 'enable',
- 'port': 'test_value_20',
- 'protocol': 'test_value_21',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_23',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'vlan': 'test_value_26',
- 'webfilter_profile': 'test_value_27',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_sniffer.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'application-list': 'test_value_3',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_5',
- 'av-profile-status': 'enable',
- 'dlp-sensor': 'test_value_7',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'host': 'myhostname10',
- 'id': '11',
- 'interface': 'test_value_12',
- 'ips-dos-status': 'enable',
- 'ips-sensor': 'test_value_14',
- 'ips-sensor-status': 'enable',
- 'ipv6': 'enable',
- 'logtraffic': 'all',
- 'max-packet-count': '18',
- 'non-ip': 'enable',
- 'port': 'test_value_20',
- 'protocol': 'test_value_21',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_23',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'vlan': 'test_value_26',
- 'webfilter-profile': 'test_value_27',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'sniffer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_sniffer_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_sniffer': {
- 'random_attribute_not_valid': 'tag', 'application_list': 'test_value_3',
- 'application_list_status': 'enable',
- 'av_profile': 'test_value_5',
- 'av_profile_status': 'enable',
- 'dlp_sensor': 'test_value_7',
- 'dlp_sensor_status': 'enable',
- 'dsri': 'enable',
- 'host': 'myhostname10',
- 'id': '11',
- 'interface': 'test_value_12',
- 'ips_dos_status': 'enable',
- 'ips_sensor': 'test_value_14',
- 'ips_sensor_status': 'enable',
- 'ipv6': 'enable',
- 'logtraffic': 'all',
- 'max_packet_count': '18',
- 'non_ip': 'enable',
- 'port': 'test_value_20',
- 'protocol': 'test_value_21',
- 'scan_botnet_connections': 'disable',
- 'spamfilter_profile': 'test_value_23',
- 'spamfilter_profile_status': 'enable',
- 'status': 'enable',
- 'vlan': 'test_value_26',
- 'webfilter_profile': 'test_value_27',
- 'webfilter_profile_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_sniffer.fortios_firewall(input_data, fos_instance)
-
- expected_data = {'application-list': 'test_value_3',
- 'application-list-status': 'enable',
- 'av-profile': 'test_value_5',
- 'av-profile-status': 'enable',
- 'dlp-sensor': 'test_value_7',
- 'dlp-sensor-status': 'enable',
- 'dsri': 'enable',
- 'host': 'myhostname10',
- 'id': '11',
- 'interface': 'test_value_12',
- 'ips-dos-status': 'enable',
- 'ips-sensor': 'test_value_14',
- 'ips-sensor-status': 'enable',
- 'ipv6': 'enable',
- 'logtraffic': 'all',
- 'max-packet-count': '18',
- 'non-ip': 'enable',
- 'port': 'test_value_20',
- 'protocol': 'test_value_21',
- 'scan-botnet-connections': 'disable',
- 'spamfilter-profile': 'test_value_23',
- 'spamfilter-profile-status': 'enable',
- 'status': 'enable',
- 'vlan': 'test_value_26',
- 'webfilter-profile': 'test_value_27',
- 'webfilter-profile-status': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'sniffer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ssh_host_key.py b/test/units/modules/network/fortios/test_fortios_firewall_ssh_host_key.py
deleted file mode 100644
index f403cd8a96..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ssh_host_key.py
+++ /dev/null
@@ -1,269 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ssh_host_key
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ssh_host_key.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ssh_host_key_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_host_key': {
- 'hostname': 'myhostname3',
- 'ip': 'test_value_4',
- 'name': 'default_name_5',
- 'nid': '256',
- 'port': '7',
- 'public_key': 'test_value_8',
- 'status': 'trusted',
- 'type': 'RSA'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_host_key.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'hostname': 'myhostname3',
- 'ip': 'test_value_4',
- 'name': 'default_name_5',
- 'nid': '256',
- 'port': '7',
- 'public-key': 'test_value_8',
- 'status': 'trusted',
- 'type': 'RSA'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'host-key', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssh_host_key_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_host_key': {
- 'hostname': 'myhostname3',
- 'ip': 'test_value_4',
- 'name': 'default_name_5',
- 'nid': '256',
- 'port': '7',
- 'public_key': 'test_value_8',
- 'status': 'trusted',
- 'type': 'RSA'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_host_key.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'hostname': 'myhostname3',
- 'ip': 'test_value_4',
- 'name': 'default_name_5',
- 'nid': '256',
- 'port': '7',
- 'public-key': 'test_value_8',
- 'status': 'trusted',
- 'type': 'RSA'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'host-key', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssh_host_key_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ssh_host_key': {
- 'hostname': 'myhostname3',
- 'ip': 'test_value_4',
- 'name': 'default_name_5',
- 'nid': '256',
- 'port': '7',
- 'public_key': 'test_value_8',
- 'status': 'trusted',
- 'type': 'RSA'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_host_key.fortios_firewall_ssh(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.ssh', 'host-key', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssh_host_key_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ssh_host_key': {
- 'hostname': 'myhostname3',
- 'ip': 'test_value_4',
- 'name': 'default_name_5',
- 'nid': '256',
- 'port': '7',
- 'public_key': 'test_value_8',
- 'status': 'trusted',
- 'type': 'RSA'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_host_key.fortios_firewall_ssh(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.ssh', 'host-key', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssh_host_key_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_host_key': {
- 'hostname': 'myhostname3',
- 'ip': 'test_value_4',
- 'name': 'default_name_5',
- 'nid': '256',
- 'port': '7',
- 'public_key': 'test_value_8',
- 'status': 'trusted',
- 'type': 'RSA'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_host_key.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'hostname': 'myhostname3',
- 'ip': 'test_value_4',
- 'name': 'default_name_5',
- 'nid': '256',
- 'port': '7',
- 'public-key': 'test_value_8',
- 'status': 'trusted',
- 'type': 'RSA'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'host-key', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ssh_host_key_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_host_key': {
- 'random_attribute_not_valid': 'tag',
- 'hostname': 'myhostname3',
- 'ip': 'test_value_4',
- 'name': 'default_name_5',
- 'nid': '256',
- 'port': '7',
- 'public_key': 'test_value_8',
- 'status': 'trusted',
- 'type': 'RSA'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_host_key.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'hostname': 'myhostname3',
- 'ip': 'test_value_4',
- 'name': 'default_name_5',
- 'nid': '256',
- 'port': '7',
- 'public-key': 'test_value_8',
- 'status': 'trusted',
- 'type': 'RSA'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'host-key', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ssh_local_ca.py b/test/units/modules/network/fortios/test_fortios_firewall_ssh_local_ca.py
deleted file mode 100644
index 8105cf0031..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ssh_local_ca.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ssh_local_ca
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ssh_local_ca.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ssh_local_ca_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_local_ca': {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_ca.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private-key': 'test_value_5',
- 'public-key': 'test_value_6',
- 'source': 'built-in'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'local-ca', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssh_local_ca_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_local_ca': {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_ca.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private-key': 'test_value_5',
- 'public-key': 'test_value_6',
- 'source': 'built-in'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'local-ca', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssh_local_ca_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ssh_local_ca': {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_ca.fortios_firewall_ssh(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.ssh', 'local-ca', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssh_local_ca_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ssh_local_ca': {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_ca.fortios_firewall_ssh(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.ssh', 'local-ca', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssh_local_ca_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_local_ca': {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_ca.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private-key': 'test_value_5',
- 'public-key': 'test_value_6',
- 'source': 'built-in'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'local-ca', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ssh_local_ca_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_local_ca': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_ca.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private-key': 'test_value_5',
- 'public-key': 'test_value_6',
- 'source': 'built-in'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'local-ca', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ssh_local_key.py b/test/units/modules/network/fortios/test_fortios_firewall_ssh_local_key.py
deleted file mode 100644
index 6b7d03e477..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ssh_local_key.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ssh_local_key
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ssh_local_key.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ssh_local_key_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_local_key': {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_key.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private-key': 'test_value_5',
- 'public-key': 'test_value_6',
- 'source': 'built-in'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'local-key', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssh_local_key_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_local_key': {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_key.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private-key': 'test_value_5',
- 'public-key': 'test_value_6',
- 'source': 'built-in'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'local-key', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssh_local_key_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ssh_local_key': {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_key.fortios_firewall_ssh(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.ssh', 'local-key', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssh_local_key_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ssh_local_key': {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_key.fortios_firewall_ssh(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.ssh', 'local-key', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssh_local_key_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_local_key': {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_key.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private-key': 'test_value_5',
- 'public-key': 'test_value_6',
- 'source': 'built-in'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'local-key', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ssh_local_key_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_local_key': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private_key': 'test_value_5',
- 'public_key': 'test_value_6',
- 'source': 'built-in'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_local_key.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'password': 'test_value_4',
- 'private-key': 'test_value_5',
- 'public-key': 'test_value_6',
- 'source': 'built-in'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'local-key', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ssh_setting.py b/test/units/modules/network/fortios/test_fortios_firewall_ssh_setting.py
deleted file mode 100644
index e4b55f1c52..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ssh_setting.py
+++ /dev/null
@@ -1,215 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ssh_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ssh_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ssh_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_setting': {
- 'caname': 'test_value_3',
- 'host_trusted_checking': 'enable',
- 'hostkey_dsa1024': 'myhostname5',
- 'hostkey_ecdsa256': 'myhostname6',
- 'hostkey_ecdsa384': 'myhostname7',
- 'hostkey_ecdsa521': 'myhostname8',
- 'hostkey_ed25519': 'myhostname9',
- 'hostkey_rsa2048': 'myhostname10',
- 'untrusted_caname': 'test_value_11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_setting.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'caname': 'test_value_3',
- 'host-trusted-checking': 'enable',
- 'hostkey-dsa1024': 'myhostname5',
- 'hostkey-ecdsa256': 'myhostname6',
- 'hostkey-ecdsa384': 'myhostname7',
- 'hostkey-ecdsa521': 'myhostname8',
- 'hostkey-ed25519': 'myhostname9',
- 'hostkey-rsa2048': 'myhostname10',
- 'untrusted-caname': 'test_value_11'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssh_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_setting': {
- 'caname': 'test_value_3',
- 'host_trusted_checking': 'enable',
- 'hostkey_dsa1024': 'myhostname5',
- 'hostkey_ecdsa256': 'myhostname6',
- 'hostkey_ecdsa384': 'myhostname7',
- 'hostkey_ecdsa521': 'myhostname8',
- 'hostkey_ed25519': 'myhostname9',
- 'hostkey_rsa2048': 'myhostname10',
- 'untrusted_caname': 'test_value_11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_setting.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'caname': 'test_value_3',
- 'host-trusted-checking': 'enable',
- 'hostkey-dsa1024': 'myhostname5',
- 'hostkey-ecdsa256': 'myhostname6',
- 'hostkey-ecdsa384': 'myhostname7',
- 'hostkey-ecdsa521': 'myhostname8',
- 'hostkey-ed25519': 'myhostname9',
- 'hostkey-rsa2048': 'myhostname10',
- 'untrusted-caname': 'test_value_11'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssh_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_setting': {
- 'caname': 'test_value_3',
- 'host_trusted_checking': 'enable',
- 'hostkey_dsa1024': 'myhostname5',
- 'hostkey_ecdsa256': 'myhostname6',
- 'hostkey_ecdsa384': 'myhostname7',
- 'hostkey_ecdsa521': 'myhostname8',
- 'hostkey_ed25519': 'myhostname9',
- 'hostkey_rsa2048': 'myhostname10',
- 'untrusted_caname': 'test_value_11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_setting.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'caname': 'test_value_3',
- 'host-trusted-checking': 'enable',
- 'hostkey-dsa1024': 'myhostname5',
- 'hostkey-ecdsa256': 'myhostname6',
- 'hostkey-ecdsa384': 'myhostname7',
- 'hostkey-ecdsa521': 'myhostname8',
- 'hostkey-ed25519': 'myhostname9',
- 'hostkey-rsa2048': 'myhostname10',
- 'untrusted-caname': 'test_value_11'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ssh_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssh_setting': {
- 'random_attribute_not_valid': 'tag',
- 'caname': 'test_value_3',
- 'host_trusted_checking': 'enable',
- 'hostkey_dsa1024': 'myhostname5',
- 'hostkey_ecdsa256': 'myhostname6',
- 'hostkey_ecdsa384': 'myhostname7',
- 'hostkey_ecdsa521': 'myhostname8',
- 'hostkey_ed25519': 'myhostname9',
- 'hostkey_rsa2048': 'myhostname10',
- 'untrusted_caname': 'test_value_11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssh_setting.fortios_firewall_ssh(input_data, fos_instance)
-
- expected_data = {
- 'caname': 'test_value_3',
- 'host-trusted-checking': 'enable',
- 'hostkey-dsa1024': 'myhostname5',
- 'hostkey-ecdsa256': 'myhostname6',
- 'hostkey-ecdsa384': 'myhostname7',
- 'hostkey-ecdsa521': 'myhostname8',
- 'hostkey-ed25519': 'myhostname9',
- 'hostkey-rsa2048': 'myhostname10',
- 'untrusted-caname': 'test_value_11'
- }
-
- set_method_mock.assert_called_with('firewall.ssh', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ssl_server.py b/test/units/modules/network/fortios/test_fortios_firewall_ssl_server.py
deleted file mode 100644
index 6e6625e177..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ssl_server.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ssl_server
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ssl_server.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ssl_server_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_server': {
- 'add_header_x_forwarded_proto': 'enable',
- 'ip': 'test_value_4',
- 'mapped_port': '5',
- 'name': 'default_name_6',
- 'port': '7',
- 'ssl_algorithm': 'high',
- 'ssl_cert': 'test_value_9',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_dh_bits': '768',
- 'ssl_max_version': 'tls-1.0',
- 'ssl_min_version': 'tls-1.0',
- 'ssl_mode': 'half',
- 'ssl_send_empty_frags': 'enable',
- 'url_rewrite': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_server.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'add-header-x-forwarded-proto': 'enable',
- 'ip': 'test_value_4',
- 'mapped-port': '5',
- 'name': 'default_name_6',
- 'port': '7',
- 'ssl-algorithm': 'high',
- 'ssl-cert': 'test_value_9',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-dh-bits': '768',
- 'ssl-max-version': 'tls-1.0',
- 'ssl-min-version': 'tls-1.0',
- 'ssl-mode': 'half',
- 'ssl-send-empty-frags': 'enable',
- 'url-rewrite': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'ssl-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssl_server_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_server': {
- 'add_header_x_forwarded_proto': 'enable',
- 'ip': 'test_value_4',
- 'mapped_port': '5',
- 'name': 'default_name_6',
- 'port': '7',
- 'ssl_algorithm': 'high',
- 'ssl_cert': 'test_value_9',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_dh_bits': '768',
- 'ssl_max_version': 'tls-1.0',
- 'ssl_min_version': 'tls-1.0',
- 'ssl_mode': 'half',
- 'ssl_send_empty_frags': 'enable',
- 'url_rewrite': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_server.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'add-header-x-forwarded-proto': 'enable',
- 'ip': 'test_value_4',
- 'mapped-port': '5',
- 'name': 'default_name_6',
- 'port': '7',
- 'ssl-algorithm': 'high',
- 'ssl-cert': 'test_value_9',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-dh-bits': '768',
- 'ssl-max-version': 'tls-1.0',
- 'ssl-min-version': 'tls-1.0',
- 'ssl-mode': 'half',
- 'ssl-send-empty-frags': 'enable',
- 'url-rewrite': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'ssl-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssl_server_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ssl_server': {
- 'add_header_x_forwarded_proto': 'enable',
- 'ip': 'test_value_4',
- 'mapped_port': '5',
- 'name': 'default_name_6',
- 'port': '7',
- 'ssl_algorithm': 'high',
- 'ssl_cert': 'test_value_9',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_dh_bits': '768',
- 'ssl_max_version': 'tls-1.0',
- 'ssl_min_version': 'tls-1.0',
- 'ssl_mode': 'half',
- 'ssl_send_empty_frags': 'enable',
- 'url_rewrite': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_server.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ssl-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssl_server_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ssl_server': {
- 'add_header_x_forwarded_proto': 'enable',
- 'ip': 'test_value_4',
- 'mapped_port': '5',
- 'name': 'default_name_6',
- 'port': '7',
- 'ssl_algorithm': 'high',
- 'ssl_cert': 'test_value_9',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_dh_bits': '768',
- 'ssl_max_version': 'tls-1.0',
- 'ssl_min_version': 'tls-1.0',
- 'ssl_mode': 'half',
- 'ssl_send_empty_frags': 'enable',
- 'url_rewrite': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_server.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ssl-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssl_server_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_server': {
- 'add_header_x_forwarded_proto': 'enable',
- 'ip': 'test_value_4',
- 'mapped_port': '5',
- 'name': 'default_name_6',
- 'port': '7',
- 'ssl_algorithm': 'high',
- 'ssl_cert': 'test_value_9',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_dh_bits': '768',
- 'ssl_max_version': 'tls-1.0',
- 'ssl_min_version': 'tls-1.0',
- 'ssl_mode': 'half',
- 'ssl_send_empty_frags': 'enable',
- 'url_rewrite': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_server.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'add-header-x-forwarded-proto': 'enable',
- 'ip': 'test_value_4',
- 'mapped-port': '5',
- 'name': 'default_name_6',
- 'port': '7',
- 'ssl-algorithm': 'high',
- 'ssl-cert': 'test_value_9',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-dh-bits': '768',
- 'ssl-max-version': 'tls-1.0',
- 'ssl-min-version': 'tls-1.0',
- 'ssl-mode': 'half',
- 'ssl-send-empty-frags': 'enable',
- 'url-rewrite': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'ssl-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ssl_server_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_server': {
- 'random_attribute_not_valid': 'tag',
- 'add_header_x_forwarded_proto': 'enable',
- 'ip': 'test_value_4',
- 'mapped_port': '5',
- 'name': 'default_name_6',
- 'port': '7',
- 'ssl_algorithm': 'high',
- 'ssl_cert': 'test_value_9',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_dh_bits': '768',
- 'ssl_max_version': 'tls-1.0',
- 'ssl_min_version': 'tls-1.0',
- 'ssl_mode': 'half',
- 'ssl_send_empty_frags': 'enable',
- 'url_rewrite': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_server.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'add-header-x-forwarded-proto': 'enable',
- 'ip': 'test_value_4',
- 'mapped-port': '5',
- 'name': 'default_name_6',
- 'port': '7',
- 'ssl-algorithm': 'high',
- 'ssl-cert': 'test_value_9',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-dh-bits': '768',
- 'ssl-max-version': 'tls-1.0',
- 'ssl-min-version': 'tls-1.0',
- 'ssl-mode': 'half',
- 'ssl-send-empty-frags': 'enable',
- 'url-rewrite': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'ssl-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ssl_setting.py b/test/units/modules/network/fortios/test_fortios_firewall_ssl_setting.py
deleted file mode 100644
index 363d47768c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ssl_setting.py
+++ /dev/null
@@ -1,231 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ssl_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ssl_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ssl_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_setting': {
- 'abbreviate_handshake': 'enable',
- 'cert_cache_capacity': '4',
- 'cert_cache_timeout': '5',
- 'kxp_queue_threshold': '6',
- 'no_matching_cipher_action': 'bypass',
- 'proxy_connect_timeout': '8',
- 'session_cache_capacity': '9',
- 'session_cache_timeout': '10',
- 'ssl_dh_bits': '768',
- 'ssl_queue_threshold': '12',
- 'ssl_send_empty_frags': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_setting.fortios_firewall_ssl(input_data, fos_instance)
-
- expected_data = {
- 'abbreviate-handshake': 'enable',
- 'cert-cache-capacity': '4',
- 'cert-cache-timeout': '5',
- 'kxp-queue-threshold': '6',
- 'no-matching-cipher-action': 'bypass',
- 'proxy-connect-timeout': '8',
- 'session-cache-capacity': '9',
- 'session-cache-timeout': '10',
- 'ssl-dh-bits': '768',
- 'ssl-queue-threshold': '12',
- 'ssl-send-empty-frags': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.ssl', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssl_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_setting': {
- 'abbreviate_handshake': 'enable',
- 'cert_cache_capacity': '4',
- 'cert_cache_timeout': '5',
- 'kxp_queue_threshold': '6',
- 'no_matching_cipher_action': 'bypass',
- 'proxy_connect_timeout': '8',
- 'session_cache_capacity': '9',
- 'session_cache_timeout': '10',
- 'ssl_dh_bits': '768',
- 'ssl_queue_threshold': '12',
- 'ssl_send_empty_frags': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_setting.fortios_firewall_ssl(input_data, fos_instance)
-
- expected_data = {
- 'abbreviate-handshake': 'enable',
- 'cert-cache-capacity': '4',
- 'cert-cache-timeout': '5',
- 'kxp-queue-threshold': '6',
- 'no-matching-cipher-action': 'bypass',
- 'proxy-connect-timeout': '8',
- 'session-cache-capacity': '9',
- 'session-cache-timeout': '10',
- 'ssl-dh-bits': '768',
- 'ssl-queue-threshold': '12',
- 'ssl-send-empty-frags': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.ssl', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssl_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_setting': {
- 'abbreviate_handshake': 'enable',
- 'cert_cache_capacity': '4',
- 'cert_cache_timeout': '5',
- 'kxp_queue_threshold': '6',
- 'no_matching_cipher_action': 'bypass',
- 'proxy_connect_timeout': '8',
- 'session_cache_capacity': '9',
- 'session_cache_timeout': '10',
- 'ssl_dh_bits': '768',
- 'ssl_queue_threshold': '12',
- 'ssl_send_empty_frags': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_setting.fortios_firewall_ssl(input_data, fos_instance)
-
- expected_data = {
- 'abbreviate-handshake': 'enable',
- 'cert-cache-capacity': '4',
- 'cert-cache-timeout': '5',
- 'kxp-queue-threshold': '6',
- 'no-matching-cipher-action': 'bypass',
- 'proxy-connect-timeout': '8',
- 'session-cache-capacity': '9',
- 'session-cache-timeout': '10',
- 'ssl-dh-bits': '768',
- 'ssl-queue-threshold': '12',
- 'ssl-send-empty-frags': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.ssl', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ssl_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_setting': {
- 'random_attribute_not_valid': 'tag',
- 'abbreviate_handshake': 'enable',
- 'cert_cache_capacity': '4',
- 'cert_cache_timeout': '5',
- 'kxp_queue_threshold': '6',
- 'no_matching_cipher_action': 'bypass',
- 'proxy_connect_timeout': '8',
- 'session_cache_capacity': '9',
- 'session_cache_timeout': '10',
- 'ssl_dh_bits': '768',
- 'ssl_queue_threshold': '12',
- 'ssl_send_empty_frags': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_setting.fortios_firewall_ssl(input_data, fos_instance)
-
- expected_data = {
- 'abbreviate-handshake': 'enable',
- 'cert-cache-capacity': '4',
- 'cert-cache-timeout': '5',
- 'kxp-queue-threshold': '6',
- 'no-matching-cipher-action': 'bypass',
- 'proxy-connect-timeout': '8',
- 'session-cache-capacity': '9',
- 'session-cache-timeout': '10',
- 'ssl-dh-bits': '768',
- 'ssl-queue-threshold': '12',
- 'ssl-send-empty-frags': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.ssl', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ssl_ssh_profile.py b/test/units/modules/network/fortios/test_fortios_firewall_ssl_ssh_profile.py
deleted file mode 100644
index 02a2b051ad..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ssl_ssh_profile.py
+++ /dev/null
@@ -1,309 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ssl_ssh_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ssl_ssh_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ssl_ssh_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_ssh_profile': {
- 'caname': 'test_value_3',
- 'comment': 'Optional comments.',
- 'mapi_over_https': 'enable',
- 'name': 'default_name_6',
- 'rpc_over_https': 'enable',
- 'server_cert': 'test_value_8',
- 'server_cert_mode': 're-sign',
- 'ssl_anomalies_log': 'disable',
- 'ssl_exemptions_log': 'disable',
- 'untrusted_caname': 'test_value_12',
- 'use_ssl_server': 'disable',
- 'whitelist': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_ssh_profile.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'caname': 'test_value_3',
- 'comment': 'Optional comments.',
- 'mapi-over-https': 'enable',
- 'name': 'default_name_6',
- 'rpc-over-https': 'enable',
- 'server-cert': 'test_value_8',
- 'server-cert-mode': 're-sign',
- 'ssl-anomalies-log': 'disable',
- 'ssl-exemptions-log': 'disable',
- 'untrusted-caname': 'test_value_12',
- 'use-ssl-server': 'disable',
- 'whitelist': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'ssl-ssh-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssl_ssh_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_ssh_profile': {
- 'caname': 'test_value_3',
- 'comment': 'Optional comments.',
- 'mapi_over_https': 'enable',
- 'name': 'default_name_6',
- 'rpc_over_https': 'enable',
- 'server_cert': 'test_value_8',
- 'server_cert_mode': 're-sign',
- 'ssl_anomalies_log': 'disable',
- 'ssl_exemptions_log': 'disable',
- 'untrusted_caname': 'test_value_12',
- 'use_ssl_server': 'disable',
- 'whitelist': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_ssh_profile.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'caname': 'test_value_3',
- 'comment': 'Optional comments.',
- 'mapi-over-https': 'enable',
- 'name': 'default_name_6',
- 'rpc-over-https': 'enable',
- 'server-cert': 'test_value_8',
- 'server-cert-mode': 're-sign',
- 'ssl-anomalies-log': 'disable',
- 'ssl-exemptions-log': 'disable',
- 'untrusted-caname': 'test_value_12',
- 'use-ssl-server': 'disable',
- 'whitelist': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'ssl-ssh-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssl_ssh_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ssl_ssh_profile': {
- 'caname': 'test_value_3',
- 'comment': 'Optional comments.',
- 'mapi_over_https': 'enable',
- 'name': 'default_name_6',
- 'rpc_over_https': 'enable',
- 'server_cert': 'test_value_8',
- 'server_cert_mode': 're-sign',
- 'ssl_anomalies_log': 'disable',
- 'ssl_exemptions_log': 'disable',
- 'untrusted_caname': 'test_value_12',
- 'use_ssl_server': 'disable',
- 'whitelist': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_ssh_profile.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ssl-ssh-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ssl_ssh_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ssl_ssh_profile': {
- 'caname': 'test_value_3',
- 'comment': 'Optional comments.',
- 'mapi_over_https': 'enable',
- 'name': 'default_name_6',
- 'rpc_over_https': 'enable',
- 'server_cert': 'test_value_8',
- 'server_cert_mode': 're-sign',
- 'ssl_anomalies_log': 'disable',
- 'ssl_exemptions_log': 'disable',
- 'untrusted_caname': 'test_value_12',
- 'use_ssl_server': 'disable',
- 'whitelist': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_ssh_profile.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ssl-ssh-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ssl_ssh_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_ssh_profile': {
- 'caname': 'test_value_3',
- 'comment': 'Optional comments.',
- 'mapi_over_https': 'enable',
- 'name': 'default_name_6',
- 'rpc_over_https': 'enable',
- 'server_cert': 'test_value_8',
- 'server_cert_mode': 're-sign',
- 'ssl_anomalies_log': 'disable',
- 'ssl_exemptions_log': 'disable',
- 'untrusted_caname': 'test_value_12',
- 'use_ssl_server': 'disable',
- 'whitelist': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_ssh_profile.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'caname': 'test_value_3',
- 'comment': 'Optional comments.',
- 'mapi-over-https': 'enable',
- 'name': 'default_name_6',
- 'rpc-over-https': 'enable',
- 'server-cert': 'test_value_8',
- 'server-cert-mode': 're-sign',
- 'ssl-anomalies-log': 'disable',
- 'ssl-exemptions-log': 'disable',
- 'untrusted-caname': 'test_value_12',
- 'use-ssl-server': 'disable',
- 'whitelist': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'ssl-ssh-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ssl_ssh_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ssl_ssh_profile': {
- 'random_attribute_not_valid': 'tag',
- 'caname': 'test_value_3',
- 'comment': 'Optional comments.',
- 'mapi_over_https': 'enable',
- 'name': 'default_name_6',
- 'rpc_over_https': 'enable',
- 'server_cert': 'test_value_8',
- 'server_cert_mode': 're-sign',
- 'ssl_anomalies_log': 'disable',
- 'ssl_exemptions_log': 'disable',
- 'untrusted_caname': 'test_value_12',
- 'use_ssl_server': 'disable',
- 'whitelist': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ssl_ssh_profile.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'caname': 'test_value_3',
- 'comment': 'Optional comments.',
- 'mapi-over-https': 'enable',
- 'name': 'default_name_6',
- 'rpc-over-https': 'enable',
- 'server-cert': 'test_value_8',
- 'server-cert-mode': 're-sign',
- 'ssl-anomalies-log': 'disable',
- 'ssl-exemptions-log': 'disable',
- 'untrusted-caname': 'test_value_12',
- 'use-ssl-server': 'disable',
- 'whitelist': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall', 'ssl-ssh-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_ttl_policy.py b/test/units/modules/network/fortios/test_fortios_firewall_ttl_policy.py
deleted file mode 100644
index 792fb75877..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_ttl_policy.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_ttl_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_ttl_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_ttl_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ttl_policy': {
- 'action': 'accept',
- 'id': '4',
- 'schedule': 'test_value_5',
- 'srcintf': 'test_value_6',
- 'status': 'enable',
- 'ttl': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ttl_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'id': '4',
- 'schedule': 'test_value_5',
- 'srcintf': 'test_value_6',
- 'status': 'enable',
- 'ttl': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('firewall', 'ttl-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ttl_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ttl_policy': {
- 'action': 'accept',
- 'id': '4',
- 'schedule': 'test_value_5',
- 'srcintf': 'test_value_6',
- 'status': 'enable',
- 'ttl': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ttl_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'id': '4',
- 'schedule': 'test_value_5',
- 'srcintf': 'test_value_6',
- 'status': 'enable',
- 'ttl': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('firewall', 'ttl-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ttl_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ttl_policy': {
- 'action': 'accept',
- 'id': '4',
- 'schedule': 'test_value_5',
- 'srcintf': 'test_value_6',
- 'status': 'enable',
- 'ttl': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ttl_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ttl-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_ttl_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_ttl_policy': {
- 'action': 'accept',
- 'id': '4',
- 'schedule': 'test_value_5',
- 'srcintf': 'test_value_6',
- 'status': 'enable',
- 'ttl': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ttl_policy.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'ttl-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_ttl_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ttl_policy': {
- 'action': 'accept',
- 'id': '4',
- 'schedule': 'test_value_5',
- 'srcintf': 'test_value_6',
- 'status': 'enable',
- 'ttl': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ttl_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'id': '4',
- 'schedule': 'test_value_5',
- 'srcintf': 'test_value_6',
- 'status': 'enable',
- 'ttl': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('firewall', 'ttl-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_ttl_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_ttl_policy': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'accept',
- 'id': '4',
- 'schedule': 'test_value_5',
- 'srcintf': 'test_value_6',
- 'status': 'enable',
- 'ttl': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_ttl_policy.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'action': 'accept',
- 'id': '4',
- 'schedule': 'test_value_5',
- 'srcintf': 'test_value_6',
- 'status': 'enable',
- 'ttl': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('firewall', 'ttl-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_vip.py b/test/units/modules/network/fortios/test_fortios_firewall_vip.py
deleted file mode 100644
index a24bdd6b8f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_vip.py
+++ /dev/null
@@ -1,839 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_vip
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_vip.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_vip_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'dns_mapping_ttl': '6',
- 'extintf': 'test_value_7',
- 'extip': 'test_value_8',
- 'extport': 'test_value_9',
- 'gratuitous_arp_interval': '10',
- 'http_cookie_age': '11',
- 'http_cookie_domain': 'test_value_12',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '14',
- 'http_cookie_path': 'test_value_15',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_18',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '21',
- 'ldb_method': 'static',
- 'mapped_addr': 'test_value_23',
- 'mappedport': 'test_value_24',
- 'max_embryonic_connections': '25',
- 'name': 'default_name_26',
- 'nat_source_vip': 'disable',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'portmapping_type': '1-to-1',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_35',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '38',
- 'ssl_client_session_state_timeout': '39',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '43',
- 'ssl_hpkp_backup': 'test_value_44',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_46',
- 'ssl_hpkp_report_uri': 'test_value_47',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '49',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '61',
- 'ssl_server_session_state_timeout': '62',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_65',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'dns-mapping-ttl': '6',
- 'extintf': 'test_value_7',
- 'extip': 'test_value_8',
- 'extport': 'test_value_9',
- 'gratuitous-arp-interval': '10',
- 'http-cookie-age': '11',
- 'http-cookie-domain': 'test_value_12',
- 'http-cookie-domain-from-host': 'disable',
- 'http-cookie-generation': '14',
- 'http-cookie-path': 'test_value_15',
- 'http-cookie-share': 'disable',
- 'http-ip-header': 'enable',
- 'http-ip-header-name': 'test_value_18',
- 'http-multiplex': 'enable',
- 'https-cookie-secure': 'disable',
- 'id': '21',
- 'ldb-method': 'static',
- 'mapped-addr': 'test_value_23',
- 'mappedport': 'test_value_24',
- 'max-embryonic-connections': '25',
- 'name': 'default_name_26',
- 'nat-source-vip': 'disable',
- 'outlook-web-access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'portmapping-type': '1-to-1',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'ssl-algorithm': 'high',
- 'ssl-certificate': 'test_value_35',
- 'ssl-client-fallback': 'disable',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-client-session-state-max': '38',
- 'ssl-client-session-state-timeout': '39',
- 'ssl-client-session-state-type': 'disable',
- 'ssl-dh-bits': '768',
- 'ssl-hpkp': 'disable',
- 'ssl-hpkp-age': '43',
- 'ssl-hpkp-backup': 'test_value_44',
- 'ssl-hpkp-include-subdomains': 'disable',
- 'ssl-hpkp-primary': 'test_value_46',
- 'ssl-hpkp-report-uri': 'test_value_47',
- 'ssl-hsts': 'disable',
- 'ssl-hsts-age': '49',
- 'ssl-hsts-include-subdomains': 'disable',
- 'ssl-http-location-conversion': 'enable',
- 'ssl-http-match-host': 'enable',
- 'ssl-max-version': 'ssl-3.0',
- 'ssl-min-version': 'ssl-3.0',
- 'ssl-mode': 'half',
- 'ssl-pfs': 'require',
- 'ssl-send-empty-frags': 'enable',
- 'ssl-server-algorithm': 'high',
- 'ssl-server-max-version': 'ssl-3.0',
- 'ssl-server-min-version': 'ssl-3.0',
- 'ssl-server-session-state-max': '61',
- 'ssl-server-session-state-timeout': '62',
- 'ssl-server-session-state-type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_65',
- 'weblogic-server': 'disable',
- 'websphere-server': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vip_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'dns_mapping_ttl': '6',
- 'extintf': 'test_value_7',
- 'extip': 'test_value_8',
- 'extport': 'test_value_9',
- 'gratuitous_arp_interval': '10',
- 'http_cookie_age': '11',
- 'http_cookie_domain': 'test_value_12',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '14',
- 'http_cookie_path': 'test_value_15',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_18',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '21',
- 'ldb_method': 'static',
- 'mapped_addr': 'test_value_23',
- 'mappedport': 'test_value_24',
- 'max_embryonic_connections': '25',
- 'name': 'default_name_26',
- 'nat_source_vip': 'disable',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'portmapping_type': '1-to-1',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_35',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '38',
- 'ssl_client_session_state_timeout': '39',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '43',
- 'ssl_hpkp_backup': 'test_value_44',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_46',
- 'ssl_hpkp_report_uri': 'test_value_47',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '49',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '61',
- 'ssl_server_session_state_timeout': '62',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_65',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'dns-mapping-ttl': '6',
- 'extintf': 'test_value_7',
- 'extip': 'test_value_8',
- 'extport': 'test_value_9',
- 'gratuitous-arp-interval': '10',
- 'http-cookie-age': '11',
- 'http-cookie-domain': 'test_value_12',
- 'http-cookie-domain-from-host': 'disable',
- 'http-cookie-generation': '14',
- 'http-cookie-path': 'test_value_15',
- 'http-cookie-share': 'disable',
- 'http-ip-header': 'enable',
- 'http-ip-header-name': 'test_value_18',
- 'http-multiplex': 'enable',
- 'https-cookie-secure': 'disable',
- 'id': '21',
- 'ldb-method': 'static',
- 'mapped-addr': 'test_value_23',
- 'mappedport': 'test_value_24',
- 'max-embryonic-connections': '25',
- 'name': 'default_name_26',
- 'nat-source-vip': 'disable',
- 'outlook-web-access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'portmapping-type': '1-to-1',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'ssl-algorithm': 'high',
- 'ssl-certificate': 'test_value_35',
- 'ssl-client-fallback': 'disable',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-client-session-state-max': '38',
- 'ssl-client-session-state-timeout': '39',
- 'ssl-client-session-state-type': 'disable',
- 'ssl-dh-bits': '768',
- 'ssl-hpkp': 'disable',
- 'ssl-hpkp-age': '43',
- 'ssl-hpkp-backup': 'test_value_44',
- 'ssl-hpkp-include-subdomains': 'disable',
- 'ssl-hpkp-primary': 'test_value_46',
- 'ssl-hpkp-report-uri': 'test_value_47',
- 'ssl-hsts': 'disable',
- 'ssl-hsts-age': '49',
- 'ssl-hsts-include-subdomains': 'disable',
- 'ssl-http-location-conversion': 'enable',
- 'ssl-http-match-host': 'enable',
- 'ssl-max-version': 'ssl-3.0',
- 'ssl-min-version': 'ssl-3.0',
- 'ssl-mode': 'half',
- 'ssl-pfs': 'require',
- 'ssl-send-empty-frags': 'enable',
- 'ssl-server-algorithm': 'high',
- 'ssl-server-max-version': 'ssl-3.0',
- 'ssl-server-min-version': 'ssl-3.0',
- 'ssl-server-session-state-max': '61',
- 'ssl-server-session-state-timeout': '62',
- 'ssl-server-session-state-type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_65',
- 'weblogic-server': 'disable',
- 'websphere-server': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vip_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vip': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'dns_mapping_ttl': '6',
- 'extintf': 'test_value_7',
- 'extip': 'test_value_8',
- 'extport': 'test_value_9',
- 'gratuitous_arp_interval': '10',
- 'http_cookie_age': '11',
- 'http_cookie_domain': 'test_value_12',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '14',
- 'http_cookie_path': 'test_value_15',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_18',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '21',
- 'ldb_method': 'static',
- 'mapped_addr': 'test_value_23',
- 'mappedport': 'test_value_24',
- 'max_embryonic_connections': '25',
- 'name': 'default_name_26',
- 'nat_source_vip': 'disable',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'portmapping_type': '1-to-1',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_35',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '38',
- 'ssl_client_session_state_timeout': '39',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '43',
- 'ssl_hpkp_backup': 'test_value_44',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_46',
- 'ssl_hpkp_report_uri': 'test_value_47',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '49',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '61',
- 'ssl_server_session_state_timeout': '62',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_65',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vip', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vip_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vip': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'dns_mapping_ttl': '6',
- 'extintf': 'test_value_7',
- 'extip': 'test_value_8',
- 'extport': 'test_value_9',
- 'gratuitous_arp_interval': '10',
- 'http_cookie_age': '11',
- 'http_cookie_domain': 'test_value_12',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '14',
- 'http_cookie_path': 'test_value_15',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_18',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '21',
- 'ldb_method': 'static',
- 'mapped_addr': 'test_value_23',
- 'mappedport': 'test_value_24',
- 'max_embryonic_connections': '25',
- 'name': 'default_name_26',
- 'nat_source_vip': 'disable',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'portmapping_type': '1-to-1',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_35',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '38',
- 'ssl_client_session_state_timeout': '39',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '43',
- 'ssl_hpkp_backup': 'test_value_44',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_46',
- 'ssl_hpkp_report_uri': 'test_value_47',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '49',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '61',
- 'ssl_server_session_state_timeout': '62',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_65',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vip', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vip_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'dns_mapping_ttl': '6',
- 'extintf': 'test_value_7',
- 'extip': 'test_value_8',
- 'extport': 'test_value_9',
- 'gratuitous_arp_interval': '10',
- 'http_cookie_age': '11',
- 'http_cookie_domain': 'test_value_12',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '14',
- 'http_cookie_path': 'test_value_15',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_18',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '21',
- 'ldb_method': 'static',
- 'mapped_addr': 'test_value_23',
- 'mappedport': 'test_value_24',
- 'max_embryonic_connections': '25',
- 'name': 'default_name_26',
- 'nat_source_vip': 'disable',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'portmapping_type': '1-to-1',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_35',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '38',
- 'ssl_client_session_state_timeout': '39',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '43',
- 'ssl_hpkp_backup': 'test_value_44',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_46',
- 'ssl_hpkp_report_uri': 'test_value_47',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '49',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '61',
- 'ssl_server_session_state_timeout': '62',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_65',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'dns-mapping-ttl': '6',
- 'extintf': 'test_value_7',
- 'extip': 'test_value_8',
- 'extport': 'test_value_9',
- 'gratuitous-arp-interval': '10',
- 'http-cookie-age': '11',
- 'http-cookie-domain': 'test_value_12',
- 'http-cookie-domain-from-host': 'disable',
- 'http-cookie-generation': '14',
- 'http-cookie-path': 'test_value_15',
- 'http-cookie-share': 'disable',
- 'http-ip-header': 'enable',
- 'http-ip-header-name': 'test_value_18',
- 'http-multiplex': 'enable',
- 'https-cookie-secure': 'disable',
- 'id': '21',
- 'ldb-method': 'static',
- 'mapped-addr': 'test_value_23',
- 'mappedport': 'test_value_24',
- 'max-embryonic-connections': '25',
- 'name': 'default_name_26',
- 'nat-source-vip': 'disable',
- 'outlook-web-access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'portmapping-type': '1-to-1',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'ssl-algorithm': 'high',
- 'ssl-certificate': 'test_value_35',
- 'ssl-client-fallback': 'disable',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-client-session-state-max': '38',
- 'ssl-client-session-state-timeout': '39',
- 'ssl-client-session-state-type': 'disable',
- 'ssl-dh-bits': '768',
- 'ssl-hpkp': 'disable',
- 'ssl-hpkp-age': '43',
- 'ssl-hpkp-backup': 'test_value_44',
- 'ssl-hpkp-include-subdomains': 'disable',
- 'ssl-hpkp-primary': 'test_value_46',
- 'ssl-hpkp-report-uri': 'test_value_47',
- 'ssl-hsts': 'disable',
- 'ssl-hsts-age': '49',
- 'ssl-hsts-include-subdomains': 'disable',
- 'ssl-http-location-conversion': 'enable',
- 'ssl-http-match-host': 'enable',
- 'ssl-max-version': 'ssl-3.0',
- 'ssl-min-version': 'ssl-3.0',
- 'ssl-mode': 'half',
- 'ssl-pfs': 'require',
- 'ssl-send-empty-frags': 'enable',
- 'ssl-server-algorithm': 'high',
- 'ssl-server-max-version': 'ssl-3.0',
- 'ssl-server-min-version': 'ssl-3.0',
- 'ssl-server-session-state-max': '61',
- 'ssl-server-session-state-timeout': '62',
- 'ssl-server-session-state-type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_65',
- 'weblogic-server': 'disable',
- 'websphere-server': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_vip_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip': {
- 'random_attribute_not_valid': 'tag',
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'dns_mapping_ttl': '6',
- 'extintf': 'test_value_7',
- 'extip': 'test_value_8',
- 'extport': 'test_value_9',
- 'gratuitous_arp_interval': '10',
- 'http_cookie_age': '11',
- 'http_cookie_domain': 'test_value_12',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '14',
- 'http_cookie_path': 'test_value_15',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_18',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '21',
- 'ldb_method': 'static',
- 'mapped_addr': 'test_value_23',
- 'mappedport': 'test_value_24',
- 'max_embryonic_connections': '25',
- 'name': 'default_name_26',
- 'nat_source_vip': 'disable',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'portmapping_type': '1-to-1',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_35',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '38',
- 'ssl_client_session_state_timeout': '39',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '43',
- 'ssl_hpkp_backup': 'test_value_44',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_46',
- 'ssl_hpkp_report_uri': 'test_value_47',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '49',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '61',
- 'ssl_server_session_state_timeout': '62',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_65',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'dns-mapping-ttl': '6',
- 'extintf': 'test_value_7',
- 'extip': 'test_value_8',
- 'extport': 'test_value_9',
- 'gratuitous-arp-interval': '10',
- 'http-cookie-age': '11',
- 'http-cookie-domain': 'test_value_12',
- 'http-cookie-domain-from-host': 'disable',
- 'http-cookie-generation': '14',
- 'http-cookie-path': 'test_value_15',
- 'http-cookie-share': 'disable',
- 'http-ip-header': 'enable',
- 'http-ip-header-name': 'test_value_18',
- 'http-multiplex': 'enable',
- 'https-cookie-secure': 'disable',
- 'id': '21',
- 'ldb-method': 'static',
- 'mapped-addr': 'test_value_23',
- 'mappedport': 'test_value_24',
- 'max-embryonic-connections': '25',
- 'name': 'default_name_26',
- 'nat-source-vip': 'disable',
- 'outlook-web-access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'portmapping-type': '1-to-1',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'ssl-algorithm': 'high',
- 'ssl-certificate': 'test_value_35',
- 'ssl-client-fallback': 'disable',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-client-session-state-max': '38',
- 'ssl-client-session-state-timeout': '39',
- 'ssl-client-session-state-type': 'disable',
- 'ssl-dh-bits': '768',
- 'ssl-hpkp': 'disable',
- 'ssl-hpkp-age': '43',
- 'ssl-hpkp-backup': 'test_value_44',
- 'ssl-hpkp-include-subdomains': 'disable',
- 'ssl-hpkp-primary': 'test_value_46',
- 'ssl-hpkp-report-uri': 'test_value_47',
- 'ssl-hsts': 'disable',
- 'ssl-hsts-age': '49',
- 'ssl-hsts-include-subdomains': 'disable',
- 'ssl-http-location-conversion': 'enable',
- 'ssl-http-match-host': 'enable',
- 'ssl-max-version': 'ssl-3.0',
- 'ssl-min-version': 'ssl-3.0',
- 'ssl-mode': 'half',
- 'ssl-pfs': 'require',
- 'ssl-send-empty-frags': 'enable',
- 'ssl-server-algorithm': 'high',
- 'ssl-server-max-version': 'ssl-3.0',
- 'ssl-server-min-version': 'ssl-3.0',
- 'ssl-server-session-state-max': '61',
- 'ssl-server-session-state-timeout': '62',
- 'ssl-server-session-state-type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_65',
- 'weblogic-server': 'disable',
- 'websphere-server': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_vip46.py b/test/units/modules/network/fortios/test_fortios_firewall_vip46.py
deleted file mode 100644
index dd8cacb67d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_vip46.py
+++ /dev/null
@@ -1,339 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_vip46
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_vip46.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_vip46_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip46': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vip46_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip46': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vip46_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vip46': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip46.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vip46', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vip46_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vip46': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip46.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vip46', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vip46_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip46': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_vip46_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip46': {
- 'random_attribute_not_valid': 'tag',
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_vip6.py b/test/units/modules/network/fortios/test_fortios_firewall_vip6.py
deleted file mode 100644
index 2d6aaf036c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_vip6.py
+++ /dev/null
@@ -1,789 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_vip6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_vip6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_vip6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip6': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'http_cookie_age': '8',
- 'http_cookie_domain': 'test_value_9',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '11',
- 'http_cookie_path': 'test_value_12',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_15',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '18',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_20',
- 'mappedport': 'test_value_21',
- 'max_embryonic_connections': '22',
- 'name': 'default_name_23',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_30',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '33',
- 'ssl_client_session_state_timeout': '34',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '38',
- 'ssl_hpkp_backup': 'test_value_39',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_41',
- 'ssl_hpkp_report_uri': 'test_value_42',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '44',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '56',
- 'ssl_server_session_state_timeout': '57',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_60',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'http-cookie-age': '8',
- 'http-cookie-domain': 'test_value_9',
- 'http-cookie-domain-from-host': 'disable',
- 'http-cookie-generation': '11',
- 'http-cookie-path': 'test_value_12',
- 'http-cookie-share': 'disable',
- 'http-ip-header': 'enable',
- 'http-ip-header-name': 'test_value_15',
- 'http-multiplex': 'enable',
- 'https-cookie-secure': 'disable',
- 'id': '18',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_20',
- 'mappedport': 'test_value_21',
- 'max-embryonic-connections': '22',
- 'name': 'default_name_23',
- 'outlook-web-access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'ssl-algorithm': 'high',
- 'ssl-certificate': 'test_value_30',
- 'ssl-client-fallback': 'disable',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-client-session-state-max': '33',
- 'ssl-client-session-state-timeout': '34',
- 'ssl-client-session-state-type': 'disable',
- 'ssl-dh-bits': '768',
- 'ssl-hpkp': 'disable',
- 'ssl-hpkp-age': '38',
- 'ssl-hpkp-backup': 'test_value_39',
- 'ssl-hpkp-include-subdomains': 'disable',
- 'ssl-hpkp-primary': 'test_value_41',
- 'ssl-hpkp-report-uri': 'test_value_42',
- 'ssl-hsts': 'disable',
- 'ssl-hsts-age': '44',
- 'ssl-hsts-include-subdomains': 'disable',
- 'ssl-http-location-conversion': 'enable',
- 'ssl-http-match-host': 'enable',
- 'ssl-max-version': 'ssl-3.0',
- 'ssl-min-version': 'ssl-3.0',
- 'ssl-mode': 'half',
- 'ssl-pfs': 'require',
- 'ssl-send-empty-frags': 'enable',
- 'ssl-server-algorithm': 'high',
- 'ssl-server-max-version': 'ssl-3.0',
- 'ssl-server-min-version': 'ssl-3.0',
- 'ssl-server-session-state-max': '56',
- 'ssl-server-session-state-timeout': '57',
- 'ssl-server-session-state-type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_60',
- 'weblogic-server': 'disable',
- 'websphere-server': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vip6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip6': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'http_cookie_age': '8',
- 'http_cookie_domain': 'test_value_9',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '11',
- 'http_cookie_path': 'test_value_12',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_15',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '18',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_20',
- 'mappedport': 'test_value_21',
- 'max_embryonic_connections': '22',
- 'name': 'default_name_23',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_30',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '33',
- 'ssl_client_session_state_timeout': '34',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '38',
- 'ssl_hpkp_backup': 'test_value_39',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_41',
- 'ssl_hpkp_report_uri': 'test_value_42',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '44',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '56',
- 'ssl_server_session_state_timeout': '57',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_60',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'http-cookie-age': '8',
- 'http-cookie-domain': 'test_value_9',
- 'http-cookie-domain-from-host': 'disable',
- 'http-cookie-generation': '11',
- 'http-cookie-path': 'test_value_12',
- 'http-cookie-share': 'disable',
- 'http-ip-header': 'enable',
- 'http-ip-header-name': 'test_value_15',
- 'http-multiplex': 'enable',
- 'https-cookie-secure': 'disable',
- 'id': '18',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_20',
- 'mappedport': 'test_value_21',
- 'max-embryonic-connections': '22',
- 'name': 'default_name_23',
- 'outlook-web-access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'ssl-algorithm': 'high',
- 'ssl-certificate': 'test_value_30',
- 'ssl-client-fallback': 'disable',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-client-session-state-max': '33',
- 'ssl-client-session-state-timeout': '34',
- 'ssl-client-session-state-type': 'disable',
- 'ssl-dh-bits': '768',
- 'ssl-hpkp': 'disable',
- 'ssl-hpkp-age': '38',
- 'ssl-hpkp-backup': 'test_value_39',
- 'ssl-hpkp-include-subdomains': 'disable',
- 'ssl-hpkp-primary': 'test_value_41',
- 'ssl-hpkp-report-uri': 'test_value_42',
- 'ssl-hsts': 'disable',
- 'ssl-hsts-age': '44',
- 'ssl-hsts-include-subdomains': 'disable',
- 'ssl-http-location-conversion': 'enable',
- 'ssl-http-match-host': 'enable',
- 'ssl-max-version': 'ssl-3.0',
- 'ssl-min-version': 'ssl-3.0',
- 'ssl-mode': 'half',
- 'ssl-pfs': 'require',
- 'ssl-send-empty-frags': 'enable',
- 'ssl-server-algorithm': 'high',
- 'ssl-server-max-version': 'ssl-3.0',
- 'ssl-server-min-version': 'ssl-3.0',
- 'ssl-server-session-state-max': '56',
- 'ssl-server-session-state-timeout': '57',
- 'ssl-server-session-state-type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_60',
- 'weblogic-server': 'disable',
- 'websphere-server': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vip6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vip6': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'http_cookie_age': '8',
- 'http_cookie_domain': 'test_value_9',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '11',
- 'http_cookie_path': 'test_value_12',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_15',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '18',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_20',
- 'mappedport': 'test_value_21',
- 'max_embryonic_connections': '22',
- 'name': 'default_name_23',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_30',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '33',
- 'ssl_client_session_state_timeout': '34',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '38',
- 'ssl_hpkp_backup': 'test_value_39',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_41',
- 'ssl_hpkp_report_uri': 'test_value_42',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '44',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '56',
- 'ssl_server_session_state_timeout': '57',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_60',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vip6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vip6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vip6': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'http_cookie_age': '8',
- 'http_cookie_domain': 'test_value_9',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '11',
- 'http_cookie_path': 'test_value_12',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_15',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '18',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_20',
- 'mappedport': 'test_value_21',
- 'max_embryonic_connections': '22',
- 'name': 'default_name_23',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_30',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '33',
- 'ssl_client_session_state_timeout': '34',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '38',
- 'ssl_hpkp_backup': 'test_value_39',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_41',
- 'ssl_hpkp_report_uri': 'test_value_42',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '44',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '56',
- 'ssl_server_session_state_timeout': '57',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_60',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vip6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vip6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip6': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'http_cookie_age': '8',
- 'http_cookie_domain': 'test_value_9',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '11',
- 'http_cookie_path': 'test_value_12',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_15',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '18',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_20',
- 'mappedport': 'test_value_21',
- 'max_embryonic_connections': '22',
- 'name': 'default_name_23',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_30',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '33',
- 'ssl_client_session_state_timeout': '34',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '38',
- 'ssl_hpkp_backup': 'test_value_39',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_41',
- 'ssl_hpkp_report_uri': 'test_value_42',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '44',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '56',
- 'ssl_server_session_state_timeout': '57',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_60',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'http-cookie-age': '8',
- 'http-cookie-domain': 'test_value_9',
- 'http-cookie-domain-from-host': 'disable',
- 'http-cookie-generation': '11',
- 'http-cookie-path': 'test_value_12',
- 'http-cookie-share': 'disable',
- 'http-ip-header': 'enable',
- 'http-ip-header-name': 'test_value_15',
- 'http-multiplex': 'enable',
- 'https-cookie-secure': 'disable',
- 'id': '18',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_20',
- 'mappedport': 'test_value_21',
- 'max-embryonic-connections': '22',
- 'name': 'default_name_23',
- 'outlook-web-access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'ssl-algorithm': 'high',
- 'ssl-certificate': 'test_value_30',
- 'ssl-client-fallback': 'disable',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-client-session-state-max': '33',
- 'ssl-client-session-state-timeout': '34',
- 'ssl-client-session-state-type': 'disable',
- 'ssl-dh-bits': '768',
- 'ssl-hpkp': 'disable',
- 'ssl-hpkp-age': '38',
- 'ssl-hpkp-backup': 'test_value_39',
- 'ssl-hpkp-include-subdomains': 'disable',
- 'ssl-hpkp-primary': 'test_value_41',
- 'ssl-hpkp-report-uri': 'test_value_42',
- 'ssl-hsts': 'disable',
- 'ssl-hsts-age': '44',
- 'ssl-hsts-include-subdomains': 'disable',
- 'ssl-http-location-conversion': 'enable',
- 'ssl-http-match-host': 'enable',
- 'ssl-max-version': 'ssl-3.0',
- 'ssl-min-version': 'ssl-3.0',
- 'ssl-mode': 'half',
- 'ssl-pfs': 'require',
- 'ssl-send-empty-frags': 'enable',
- 'ssl-server-algorithm': 'high',
- 'ssl-server-max-version': 'ssl-3.0',
- 'ssl-server-min-version': 'ssl-3.0',
- 'ssl-server-session-state-max': '56',
- 'ssl-server-session-state-timeout': '57',
- 'ssl-server-session-state-type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_60',
- 'weblogic-server': 'disable',
- 'websphere-server': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_vip6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip6': {
- 'random_attribute_not_valid': 'tag',
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'http_cookie_age': '8',
- 'http_cookie_domain': 'test_value_9',
- 'http_cookie_domain_from_host': 'disable',
- 'http_cookie_generation': '11',
- 'http_cookie_path': 'test_value_12',
- 'http_cookie_share': 'disable',
- 'http_ip_header': 'enable',
- 'http_ip_header_name': 'test_value_15',
- 'http_multiplex': 'enable',
- 'https_cookie_secure': 'disable',
- 'id': '18',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_20',
- 'mappedport': 'test_value_21',
- 'max_embryonic_connections': '22',
- 'name': 'default_name_23',
- 'outlook_web_access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'ssl_algorithm': 'high',
- 'ssl_certificate': 'test_value_30',
- 'ssl_client_fallback': 'disable',
- 'ssl_client_renegotiation': 'allow',
- 'ssl_client_session_state_max': '33',
- 'ssl_client_session_state_timeout': '34',
- 'ssl_client_session_state_type': 'disable',
- 'ssl_dh_bits': '768',
- 'ssl_hpkp': 'disable',
- 'ssl_hpkp_age': '38',
- 'ssl_hpkp_backup': 'test_value_39',
- 'ssl_hpkp_include_subdomains': 'disable',
- 'ssl_hpkp_primary': 'test_value_41',
- 'ssl_hpkp_report_uri': 'test_value_42',
- 'ssl_hsts': 'disable',
- 'ssl_hsts_age': '44',
- 'ssl_hsts_include_subdomains': 'disable',
- 'ssl_http_location_conversion': 'enable',
- 'ssl_http_match_host': 'enable',
- 'ssl_max_version': 'ssl-3.0',
- 'ssl_min_version': 'ssl-3.0',
- 'ssl_mode': 'half',
- 'ssl_pfs': 'require',
- 'ssl_send_empty_frags': 'enable',
- 'ssl_server_algorithm': 'high',
- 'ssl_server_max_version': 'ssl-3.0',
- 'ssl_server_min_version': 'ssl-3.0',
- 'ssl_server_session_state_max': '56',
- 'ssl_server_session_state_timeout': '57',
- 'ssl_server_session_state_type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_60',
- 'weblogic_server': 'disable',
- 'websphere_server': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'http-cookie-age': '8',
- 'http-cookie-domain': 'test_value_9',
- 'http-cookie-domain-from-host': 'disable',
- 'http-cookie-generation': '11',
- 'http-cookie-path': 'test_value_12',
- 'http-cookie-share': 'disable',
- 'http-ip-header': 'enable',
- 'http-ip-header-name': 'test_value_15',
- 'http-multiplex': 'enable',
- 'https-cookie-secure': 'disable',
- 'id': '18',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_20',
- 'mappedport': 'test_value_21',
- 'max-embryonic-connections': '22',
- 'name': 'default_name_23',
- 'outlook-web-access': 'disable',
- 'persistence': 'none',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'ssl-algorithm': 'high',
- 'ssl-certificate': 'test_value_30',
- 'ssl-client-fallback': 'disable',
- 'ssl-client-renegotiation': 'allow',
- 'ssl-client-session-state-max': '33',
- 'ssl-client-session-state-timeout': '34',
- 'ssl-client-session-state-type': 'disable',
- 'ssl-dh-bits': '768',
- 'ssl-hpkp': 'disable',
- 'ssl-hpkp-age': '38',
- 'ssl-hpkp-backup': 'test_value_39',
- 'ssl-hpkp-include-subdomains': 'disable',
- 'ssl-hpkp-primary': 'test_value_41',
- 'ssl-hpkp-report-uri': 'test_value_42',
- 'ssl-hsts': 'disable',
- 'ssl-hsts-age': '44',
- 'ssl-hsts-include-subdomains': 'disable',
- 'ssl-http-location-conversion': 'enable',
- 'ssl-http-match-host': 'enable',
- 'ssl-max-version': 'ssl-3.0',
- 'ssl-min-version': 'ssl-3.0',
- 'ssl-mode': 'half',
- 'ssl-pfs': 'require',
- 'ssl-send-empty-frags': 'enable',
- 'ssl-server-algorithm': 'high',
- 'ssl-server-max-version': 'ssl-3.0',
- 'ssl-server-min-version': 'ssl-3.0',
- 'ssl-server-session-state-max': '56',
- 'ssl-server-session-state-timeout': '57',
- 'ssl-server-session-state-type': 'disable',
- 'type': 'static-nat',
- 'uuid': 'test_value_60',
- 'weblogic-server': 'disable',
- 'websphere-server': 'disable'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_vip64.py b/test/units/modules/network/fortios/test_fortios_firewall_vip64.py
deleted file mode 100644
index b496be600b..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_vip64.py
+++ /dev/null
@@ -1,339 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_vip64
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_vip64.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_vip64_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip64': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vip64_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip64': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vip64_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vip64': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip64.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vip64', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vip64_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vip64': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip64.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vip64', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vip64_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip64': {
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_vip64_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vip64': {
- 'random_attribute_not_valid': 'tag',
- 'arp_reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb_method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server_type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vip64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'arp-reply': 'disable',
- 'color': '4',
- 'comment': 'Comment.',
- 'extip': 'test_value_6',
- 'extport': 'test_value_7',
- 'id': '8',
- 'ldb-method': 'static',
- 'mappedip': 'test_value_10',
- 'mappedport': 'test_value_11',
- 'name': 'default_name_12',
- 'portforward': 'disable',
- 'protocol': 'tcp',
- 'server-type': 'http',
- 'type': 'static-nat',
- 'uuid': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('firewall', 'vip64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_vipgrp.py b/test/units/modules/network/fortios/test_fortios_firewall_vipgrp.py
deleted file mode 100644
index b4b9432569..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_vipgrp.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_vipgrp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_vipgrp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_vipgrp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'interface': 'test_value_5',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'interface': 'test_value_5',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vipgrp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'interface': 'test_value_5',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'interface': 'test_value_5',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vipgrp_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vipgrp': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'interface': 'test_value_5',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vipgrp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vipgrp_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vipgrp': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'interface': 'test_value_5',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vipgrp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vipgrp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'interface': 'test_value_5',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'interface': 'test_value_5',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_vipgrp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'comments': 'test_value_4',
- 'interface': 'test_value_5',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'interface': 'test_value_5',
- 'name': 'default_name_6',
- 'uuid': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_vipgrp46.py b/test/units/modules/network/fortios/test_fortios_firewall_vipgrp46.py
deleted file mode 100644
index 9ab148df7d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_vipgrp46.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_vipgrp46
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_vipgrp46.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_vipgrp46_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp46': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vipgrp46_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp46': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vipgrp46_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vipgrp46': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp46.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vipgrp46', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vipgrp46_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vipgrp46': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp46.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vipgrp46', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vipgrp46_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp46': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_vipgrp46_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp46': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp46.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp46', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_vipgrp6.py b/test/units/modules/network/fortios/test_fortios_firewall_vipgrp6.py
deleted file mode 100644
index 808a9c26a3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_vipgrp6.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_vipgrp6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_vipgrp6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_vipgrp6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp6': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vipgrp6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp6': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vipgrp6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vipgrp6': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vipgrp6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vipgrp6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vipgrp6': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp6.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vipgrp6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vipgrp6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp6': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_vipgrp6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp6': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp6.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_vipgrp64.py b/test/units/modules/network/fortios/test_fortios_firewall_vipgrp64.py
deleted file mode 100644
index 41a48c9fa1..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_vipgrp64.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_vipgrp64
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_vipgrp64.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_vipgrp64_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp64': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vipgrp64_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp64': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vipgrp64_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vipgrp64': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp64.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vipgrp64', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_vipgrp64_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_vipgrp64': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp64.fortios_firewall(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall', 'vipgrp64', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_vipgrp64_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp64': {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_vipgrp64_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_vipgrp64': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_vipgrp64.fortios_firewall(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('firewall', 'vipgrp64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_wildcard_fqdn_custom.py b/test/units/modules/network/fortios/test_fortios_firewall_wildcard_fqdn_custom.py
deleted file mode 100644
index 55a91a3747..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_wildcard_fqdn_custom.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_wildcard_fqdn_custom
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_wildcard_fqdn_custom.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_wildcard_fqdn_custom_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_wildcard_fqdn_custom': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable',
- 'wildcard_fqdn': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_custom.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable',
- 'wildcard-fqdn': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('firewall.wildcard-fqdn', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_wildcard_fqdn_custom_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_wildcard_fqdn_custom': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable',
- 'wildcard_fqdn': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_custom.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable',
- 'wildcard-fqdn': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('firewall.wildcard-fqdn', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_wildcard_fqdn_custom_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_wildcard_fqdn_custom': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable',
- 'wildcard_fqdn': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_custom.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.wildcard-fqdn', 'custom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_wildcard_fqdn_custom_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_wildcard_fqdn_custom': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable',
- 'wildcard_fqdn': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_custom.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.wildcard-fqdn', 'custom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_wildcard_fqdn_custom_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_wildcard_fqdn_custom': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable',
- 'wildcard_fqdn': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_custom.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable',
- 'wildcard-fqdn': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('firewall.wildcard-fqdn', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_wildcard_fqdn_custom_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_wildcard_fqdn_custom': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable',
- 'wildcard_fqdn': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_custom.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable',
- 'wildcard-fqdn': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('firewall.wildcard-fqdn', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_firewall_wildcard_fqdn_group.py b/test/units/modules/network/fortios/test_fortios_firewall_wildcard_fqdn_group.py
deleted file mode 100644
index 59e86978b7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_firewall_wildcard_fqdn_group.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_firewall_wildcard_fqdn_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_firewall_wildcard_fqdn_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_firewall_wildcard_fqdn_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_wildcard_fqdn_group': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_group.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.wildcard-fqdn', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_wildcard_fqdn_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_wildcard_fqdn_group': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_group.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.wildcard-fqdn', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_wildcard_fqdn_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_wildcard_fqdn_group': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_group.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.wildcard-fqdn', 'group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_firewall_wildcard_fqdn_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'firewall_wildcard_fqdn_group': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_group.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('firewall.wildcard-fqdn', 'group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_firewall_wildcard_fqdn_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_wildcard_fqdn_group': {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_group.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.wildcard-fqdn', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_firewall_wildcard_fqdn_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'firewall_wildcard_fqdn_group': {
- 'random_attribute_not_valid': 'tag',
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_firewall_wildcard_fqdn_group.fortios_firewall_wildcard_fqdn(input_data, fos_instance)
-
- expected_data = {
- 'color': '3',
- 'comment': 'Comment.',
- 'name': 'default_name_5',
- 'uuid': 'test_value_6',
- 'visibility': 'enable'
- }
-
- set_method_mock.assert_called_with('firewall.wildcard-fqdn', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_ftp_proxy_explicit.py b/test/units/modules/network/fortios/test_fortios_ftp_proxy_explicit.py
deleted file mode 100644
index 3773eda0e8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_ftp_proxy_explicit.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_ftp_proxy_explicit
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_ftp_proxy_explicit.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_ftp_proxy_explicit_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ftp_proxy_explicit': {
- 'incoming_ip': 'test_value_3',
- 'incoming_port': 'test_value_4',
- 'outgoing_ip': 'test_value_5',
- 'sec_default_action': 'accept',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ftp_proxy_explicit.fortios_ftp_proxy(input_data, fos_instance)
-
- expected_data = {
- 'incoming-ip': 'test_value_3',
- 'incoming-port': 'test_value_4',
- 'outgoing-ip': 'test_value_5',
- 'sec-default-action': 'accept',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('ftp-proxy', 'explicit', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ftp_proxy_explicit_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ftp_proxy_explicit': {
- 'incoming_ip': 'test_value_3',
- 'incoming_port': 'test_value_4',
- 'outgoing_ip': 'test_value_5',
- 'sec_default_action': 'accept',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ftp_proxy_explicit.fortios_ftp_proxy(input_data, fos_instance)
-
- expected_data = {
- 'incoming-ip': 'test_value_3',
- 'incoming-port': 'test_value_4',
- 'outgoing-ip': 'test_value_5',
- 'sec-default-action': 'accept',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('ftp-proxy', 'explicit', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ftp_proxy_explicit_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ftp_proxy_explicit': {
- 'incoming_ip': 'test_value_3',
- 'incoming_port': 'test_value_4',
- 'outgoing_ip': 'test_value_5',
- 'sec_default_action': 'accept',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ftp_proxy_explicit.fortios_ftp_proxy(input_data, fos_instance)
-
- expected_data = {
- 'incoming-ip': 'test_value_3',
- 'incoming-port': 'test_value_4',
- 'outgoing-ip': 'test_value_5',
- 'sec-default-action': 'accept',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('ftp-proxy', 'explicit', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_ftp_proxy_explicit_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ftp_proxy_explicit': {
- 'random_attribute_not_valid': 'tag',
- 'incoming_ip': 'test_value_3',
- 'incoming_port': 'test_value_4',
- 'outgoing_ip': 'test_value_5',
- 'sec_default_action': 'accept',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ftp_proxy_explicit.fortios_ftp_proxy(input_data, fos_instance)
-
- expected_data = {
- 'incoming-ip': 'test_value_3',
- 'incoming-port': 'test_value_4',
- 'outgoing-ip': 'test_value_5',
- 'sec-default-action': 'accept',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('ftp-proxy', 'explicit', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_icap_profile.py b/test/units/modules/network/fortios/test_fortios_icap_profile.py
deleted file mode 100644
index 1e2640bcf1..0000000000
--- a/test/units/modules/network/fortios/test_fortios_icap_profile.py
+++ /dev/null
@@ -1,309 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_icap_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_icap_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_icap_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'icap_profile': {
- 'methods': 'delete',
- 'name': 'default_name_4',
- 'replacemsg_group': 'test_value_5',
- 'request': 'disable',
- 'request_failure': 'error',
- 'request_path': 'test_value_8',
- 'request_server': 'test_value_9',
- 'response': 'disable',
- 'response_failure': 'error',
- 'response_path': 'test_value_12',
- 'response_server': 'test_value_13',
- 'streaming_content_bypass': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_profile.fortios_icap(input_data, fos_instance)
-
- expected_data = {
- 'methods': 'delete',
- 'name': 'default_name_4',
- 'replacemsg-group': 'test_value_5',
- 'request': 'disable',
- 'request-failure': 'error',
- 'request-path': 'test_value_8',
- 'request-server': 'test_value_9',
- 'response': 'disable',
- 'response-failure': 'error',
- 'response-path': 'test_value_12',
- 'response-server': 'test_value_13',
- 'streaming-content-bypass': 'disable'
- }
-
- set_method_mock.assert_called_with('icap', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_icap_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'icap_profile': {
- 'methods': 'delete',
- 'name': 'default_name_4',
- 'replacemsg_group': 'test_value_5',
- 'request': 'disable',
- 'request_failure': 'error',
- 'request_path': 'test_value_8',
- 'request_server': 'test_value_9',
- 'response': 'disable',
- 'response_failure': 'error',
- 'response_path': 'test_value_12',
- 'response_server': 'test_value_13',
- 'streaming_content_bypass': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_profile.fortios_icap(input_data, fos_instance)
-
- expected_data = {
- 'methods': 'delete',
- 'name': 'default_name_4',
- 'replacemsg-group': 'test_value_5',
- 'request': 'disable',
- 'request-failure': 'error',
- 'request-path': 'test_value_8',
- 'request-server': 'test_value_9',
- 'response': 'disable',
- 'response-failure': 'error',
- 'response-path': 'test_value_12',
- 'response-server': 'test_value_13',
- 'streaming-content-bypass': 'disable'
- }
-
- set_method_mock.assert_called_with('icap', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_icap_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'icap_profile': {
- 'methods': 'delete',
- 'name': 'default_name_4',
- 'replacemsg_group': 'test_value_5',
- 'request': 'disable',
- 'request_failure': 'error',
- 'request_path': 'test_value_8',
- 'request_server': 'test_value_9',
- 'response': 'disable',
- 'response_failure': 'error',
- 'response_path': 'test_value_12',
- 'response_server': 'test_value_13',
- 'streaming_content_bypass': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_profile.fortios_icap(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('icap', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_icap_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'icap_profile': {
- 'methods': 'delete',
- 'name': 'default_name_4',
- 'replacemsg_group': 'test_value_5',
- 'request': 'disable',
- 'request_failure': 'error',
- 'request_path': 'test_value_8',
- 'request_server': 'test_value_9',
- 'response': 'disable',
- 'response_failure': 'error',
- 'response_path': 'test_value_12',
- 'response_server': 'test_value_13',
- 'streaming_content_bypass': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_profile.fortios_icap(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('icap', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_icap_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'icap_profile': {
- 'methods': 'delete',
- 'name': 'default_name_4',
- 'replacemsg_group': 'test_value_5',
- 'request': 'disable',
- 'request_failure': 'error',
- 'request_path': 'test_value_8',
- 'request_server': 'test_value_9',
- 'response': 'disable',
- 'response_failure': 'error',
- 'response_path': 'test_value_12',
- 'response_server': 'test_value_13',
- 'streaming_content_bypass': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_profile.fortios_icap(input_data, fos_instance)
-
- expected_data = {
- 'methods': 'delete',
- 'name': 'default_name_4',
- 'replacemsg-group': 'test_value_5',
- 'request': 'disable',
- 'request-failure': 'error',
- 'request-path': 'test_value_8',
- 'request-server': 'test_value_9',
- 'response': 'disable',
- 'response-failure': 'error',
- 'response-path': 'test_value_12',
- 'response-server': 'test_value_13',
- 'streaming-content-bypass': 'disable'
- }
-
- set_method_mock.assert_called_with('icap', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_icap_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'icap_profile': {
- 'random_attribute_not_valid': 'tag',
- 'methods': 'delete',
- 'name': 'default_name_4',
- 'replacemsg_group': 'test_value_5',
- 'request': 'disable',
- 'request_failure': 'error',
- 'request_path': 'test_value_8',
- 'request_server': 'test_value_9',
- 'response': 'disable',
- 'response_failure': 'error',
- 'response_path': 'test_value_12',
- 'response_server': 'test_value_13',
- 'streaming_content_bypass': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_profile.fortios_icap(input_data, fos_instance)
-
- expected_data = {
- 'methods': 'delete',
- 'name': 'default_name_4',
- 'replacemsg-group': 'test_value_5',
- 'request': 'disable',
- 'request-failure': 'error',
- 'request-path': 'test_value_8',
- 'request-server': 'test_value_9',
- 'response': 'disable',
- 'response-failure': 'error',
- 'response-path': 'test_value_12',
- 'response-server': 'test_value_13',
- 'streaming-content-bypass': 'disable'
- }
-
- set_method_mock.assert_called_with('icap', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_icap_server.py b/test/units/modules/network/fortios/test_fortios_icap_server.py
deleted file mode 100644
index f430c3a219..0000000000
--- a/test/units/modules/network/fortios/test_fortios_icap_server.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_icap_server
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_icap_server.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_icap_server_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'icap_server': {
- 'ip_address': 'test_value_3',
- 'ip_version': '4',
- 'ip6_address': 'test_value_5',
- 'max_connections': '6',
- 'name': 'default_name_7',
- 'port': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_server.fortios_icap(input_data, fos_instance)
-
- expected_data = {
- 'ip-address': 'test_value_3',
- 'ip-version': '4',
- 'ip6-address': 'test_value_5',
- 'max-connections': '6',
- 'name': 'default_name_7',
- 'port': '8'
- }
-
- set_method_mock.assert_called_with('icap', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_icap_server_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'icap_server': {
- 'ip_address': 'test_value_3',
- 'ip_version': '4',
- 'ip6_address': 'test_value_5',
- 'max_connections': '6',
- 'name': 'default_name_7',
- 'port': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_server.fortios_icap(input_data, fos_instance)
-
- expected_data = {
- 'ip-address': 'test_value_3',
- 'ip-version': '4',
- 'ip6-address': 'test_value_5',
- 'max-connections': '6',
- 'name': 'default_name_7',
- 'port': '8'
- }
-
- set_method_mock.assert_called_with('icap', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_icap_server_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'icap_server': {
- 'ip_address': 'test_value_3',
- 'ip_version': '4',
- 'ip6_address': 'test_value_5',
- 'max_connections': '6',
- 'name': 'default_name_7',
- 'port': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_server.fortios_icap(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('icap', 'server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_icap_server_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'icap_server': {
- 'ip_address': 'test_value_3',
- 'ip_version': '4',
- 'ip6_address': 'test_value_5',
- 'max_connections': '6',
- 'name': 'default_name_7',
- 'port': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_server.fortios_icap(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('icap', 'server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_icap_server_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'icap_server': {
- 'ip_address': 'test_value_3',
- 'ip_version': '4',
- 'ip6_address': 'test_value_5',
- 'max_connections': '6',
- 'name': 'default_name_7',
- 'port': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_server.fortios_icap(input_data, fos_instance)
-
- expected_data = {
- 'ip-address': 'test_value_3',
- 'ip-version': '4',
- 'ip6-address': 'test_value_5',
- 'max-connections': '6',
- 'name': 'default_name_7',
- 'port': '8'
- }
-
- set_method_mock.assert_called_with('icap', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_icap_server_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'icap_server': {
- 'random_attribute_not_valid': 'tag',
- 'ip_address': 'test_value_3',
- 'ip_version': '4',
- 'ip6_address': 'test_value_5',
- 'max_connections': '6',
- 'name': 'default_name_7',
- 'port': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_icap_server.fortios_icap(input_data, fos_instance)
-
- expected_data = {
- 'ip-address': 'test_value_3',
- 'ip-version': '4',
- 'ip6-address': 'test_value_5',
- 'max-connections': '6',
- 'name': 'default_name_7',
- 'port': '8'
- }
-
- set_method_mock.assert_called_with('icap', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_ips_custom.py b/test/units/modules/network/fortios/test_fortios_ips_custom.py
deleted file mode 100644
index 17b0599ec1..0000000000
--- a/test/units/modules/network/fortios/test_fortios_ips_custom.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_ips_custom
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_ips_custom.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_ips_custom_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_custom': {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'comment': 'Comment.',
- 'location': 'test_value_6',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'os': 'test_value_9',
- 'protocol': 'test_value_10',
- 'rule_id': '11',
- 'severity': 'test_value_12',
- 'sig_name': 'test_value_13',
- 'signature': 'test_value_14',
- 'status': 'disable',
- 'tag': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_custom.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'comment': 'Comment.',
- 'location': 'test_value_6',
- 'log': 'disable',
- 'log-packet': 'disable',
- 'os': 'test_value_9',
- 'protocol': 'test_value_10',
- 'rule-id': '11',
- 'severity': 'test_value_12',
- 'sig-name': 'test_value_13',
- 'signature': 'test_value_14',
- 'status': 'disable',
- 'tag': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('ips', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_custom_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_custom': {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'comment': 'Comment.',
- 'location': 'test_value_6',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'os': 'test_value_9',
- 'protocol': 'test_value_10',
- 'rule_id': '11',
- 'severity': 'test_value_12',
- 'sig_name': 'test_value_13',
- 'signature': 'test_value_14',
- 'status': 'disable',
- 'tag': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_custom.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'comment': 'Comment.',
- 'location': 'test_value_6',
- 'log': 'disable',
- 'log-packet': 'disable',
- 'os': 'test_value_9',
- 'protocol': 'test_value_10',
- 'rule-id': '11',
- 'severity': 'test_value_12',
- 'sig-name': 'test_value_13',
- 'signature': 'test_value_14',
- 'status': 'disable',
- 'tag': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('ips', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_custom_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ips_custom': {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'comment': 'Comment.',
- 'location': 'test_value_6',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'os': 'test_value_9',
- 'protocol': 'test_value_10',
- 'rule_id': '11',
- 'severity': 'test_value_12',
- 'sig_name': 'test_value_13',
- 'signature': 'test_value_14',
- 'status': 'disable',
- 'tag': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_custom.fortios_ips(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ips', 'custom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_custom_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ips_custom': {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'comment': 'Comment.',
- 'location': 'test_value_6',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'os': 'test_value_9',
- 'protocol': 'test_value_10',
- 'rule_id': '11',
- 'severity': 'test_value_12',
- 'sig_name': 'test_value_13',
- 'signature': 'test_value_14',
- 'status': 'disable',
- 'tag': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_custom.fortios_ips(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ips', 'custom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_custom_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_custom': {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'comment': 'Comment.',
- 'location': 'test_value_6',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'os': 'test_value_9',
- 'protocol': 'test_value_10',
- 'rule_id': '11',
- 'severity': 'test_value_12',
- 'sig_name': 'test_value_13',
- 'signature': 'test_value_14',
- 'status': 'disable',
- 'tag': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_custom.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'comment': 'Comment.',
- 'location': 'test_value_6',
- 'log': 'disable',
- 'log-packet': 'disable',
- 'os': 'test_value_9',
- 'protocol': 'test_value_10',
- 'rule-id': '11',
- 'severity': 'test_value_12',
- 'sig-name': 'test_value_13',
- 'signature': 'test_value_14',
- 'status': 'disable',
- 'tag': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('ips', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_ips_custom_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_custom': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'pass',
- 'application': 'test_value_4',
- 'comment': 'Comment.',
- 'location': 'test_value_6',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'os': 'test_value_9',
- 'protocol': 'test_value_10',
- 'rule_id': '11',
- 'severity': 'test_value_12',
- 'sig_name': 'test_value_13',
- 'signature': 'test_value_14',
- 'status': 'disable',
- 'tag': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_custom.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'comment': 'Comment.',
- 'location': 'test_value_6',
- 'log': 'disable',
- 'log-packet': 'disable',
- 'os': 'test_value_9',
- 'protocol': 'test_value_10',
- 'rule-id': '11',
- 'severity': 'test_value_12',
- 'sig-name': 'test_value_13',
- 'signature': 'test_value_14',
- 'status': 'disable',
- 'tag': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('ips', 'custom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_ips_decoder.py b/test/units/modules/network/fortios/test_fortios_ips_decoder.py
deleted file mode 100644
index 4b1ed12416..0000000000
--- a/test/units/modules/network/fortios/test_fortios_ips_decoder.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_ips_decoder
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_ips_decoder.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_ips_decoder_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_decoder': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_decoder.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('ips', 'decoder', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_decoder_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_decoder': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_decoder.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('ips', 'decoder', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_decoder_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ips_decoder': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_decoder.fortios_ips(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ips', 'decoder', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_decoder_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ips_decoder': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_decoder.fortios_ips(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ips', 'decoder', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_decoder_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_decoder': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_decoder.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('ips', 'decoder', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_ips_decoder_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_decoder': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_decoder.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('ips', 'decoder', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_ips_global.py b/test/units/modules/network/fortios/test_fortios_ips_global.py
deleted file mode 100644
index a0772ab7ec..0000000000
--- a/test/units/modules/network/fortios/test_fortios_ips_global.py
+++ /dev/null
@@ -1,247 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_ips_global
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_ips_global.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_ips_global_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_global': {
- 'anomaly_mode': 'periodical',
- 'database': 'regular',
- 'deep_app_insp_db_limit': '5',
- 'deep_app_insp_timeout': '6',
- 'engine_count': '7',
- 'exclude_signatures': 'none',
- 'fail_open': 'enable',
- 'intelligent_mode': 'enable',
- 'session_limit_mode': 'accurate',
- 'skype_client_public_ipaddr': 'test_value_12',
- 'socket_size': '13',
- 'sync_session_ttl': 'enable',
- 'traffic_submit': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_global.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'anomaly-mode': 'periodical',
- 'database': 'regular',
- 'deep-app-insp-db-limit': '5',
- 'deep-app-insp-timeout': '6',
- 'engine-count': '7',
- 'exclude-signatures': 'none',
- 'fail-open': 'enable',
- 'intelligent-mode': 'enable',
- 'session-limit-mode': 'accurate',
- 'skype-client-public-ipaddr': 'test_value_12',
- 'socket-size': '13',
- 'sync-session-ttl': 'enable',
- 'traffic-submit': 'enable'
- }
-
- set_method_mock.assert_called_with('ips', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_global_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_global': {
- 'anomaly_mode': 'periodical',
- 'database': 'regular',
- 'deep_app_insp_db_limit': '5',
- 'deep_app_insp_timeout': '6',
- 'engine_count': '7',
- 'exclude_signatures': 'none',
- 'fail_open': 'enable',
- 'intelligent_mode': 'enable',
- 'session_limit_mode': 'accurate',
- 'skype_client_public_ipaddr': 'test_value_12',
- 'socket_size': '13',
- 'sync_session_ttl': 'enable',
- 'traffic_submit': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_global.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'anomaly-mode': 'periodical',
- 'database': 'regular',
- 'deep-app-insp-db-limit': '5',
- 'deep-app-insp-timeout': '6',
- 'engine-count': '7',
- 'exclude-signatures': 'none',
- 'fail-open': 'enable',
- 'intelligent-mode': 'enable',
- 'session-limit-mode': 'accurate',
- 'skype-client-public-ipaddr': 'test_value_12',
- 'socket-size': '13',
- 'sync-session-ttl': 'enable',
- 'traffic-submit': 'enable'
- }
-
- set_method_mock.assert_called_with('ips', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_global_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_global': {
- 'anomaly_mode': 'periodical',
- 'database': 'regular',
- 'deep_app_insp_db_limit': '5',
- 'deep_app_insp_timeout': '6',
- 'engine_count': '7',
- 'exclude_signatures': 'none',
- 'fail_open': 'enable',
- 'intelligent_mode': 'enable',
- 'session_limit_mode': 'accurate',
- 'skype_client_public_ipaddr': 'test_value_12',
- 'socket_size': '13',
- 'sync_session_ttl': 'enable',
- 'traffic_submit': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_global.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'anomaly-mode': 'periodical',
- 'database': 'regular',
- 'deep-app-insp-db-limit': '5',
- 'deep-app-insp-timeout': '6',
- 'engine-count': '7',
- 'exclude-signatures': 'none',
- 'fail-open': 'enable',
- 'intelligent-mode': 'enable',
- 'session-limit-mode': 'accurate',
- 'skype-client-public-ipaddr': 'test_value_12',
- 'socket-size': '13',
- 'sync-session-ttl': 'enable',
- 'traffic-submit': 'enable'
- }
-
- set_method_mock.assert_called_with('ips', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_ips_global_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_global': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly_mode': 'periodical',
- 'database': 'regular',
- 'deep_app_insp_db_limit': '5',
- 'deep_app_insp_timeout': '6',
- 'engine_count': '7',
- 'exclude_signatures': 'none',
- 'fail_open': 'enable',
- 'intelligent_mode': 'enable',
- 'session_limit_mode': 'accurate',
- 'skype_client_public_ipaddr': 'test_value_12',
- 'socket_size': '13',
- 'sync_session_ttl': 'enable',
- 'traffic_submit': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_global.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'anomaly-mode': 'periodical',
- 'database': 'regular',
- 'deep-app-insp-db-limit': '5',
- 'deep-app-insp-timeout': '6',
- 'engine-count': '7',
- 'exclude-signatures': 'none',
- 'fail-open': 'enable',
- 'intelligent-mode': 'enable',
- 'session-limit-mode': 'accurate',
- 'skype-client-public-ipaddr': 'test_value_12',
- 'socket-size': '13',
- 'sync-session-ttl': 'enable',
- 'traffic-submit': 'enable'
- }
-
- set_method_mock.assert_called_with('ips', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_ips_rule.py b/test/units/modules/network/fortios/test_fortios_ips_rule.py
deleted file mode 100644
index 5ca2e06e26..0000000000
--- a/test/units/modules/network/fortios/test_fortios_ips_rule.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_ips_rule
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_ips_rule.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_ips_rule_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_rule': {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'date': '5',
- 'group': 'test_value_6',
- 'location': 'test_value_7,',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'name': 'default_name_10',
- 'os': 'test_value_11',
- 'rev': '12',
- 'rule_id': '13',
- 'service': 'test_value_14',
- 'severity': 'test_value_15,',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'date': '5',
- 'group': 'test_value_6',
- 'location': 'test_value_7,',
- 'log': 'disable',
- 'log-packet': 'disable',
- 'name': 'default_name_10',
- 'os': 'test_value_11',
- 'rev': '12',
- 'rule-id': '13',
- 'service': 'test_value_14',
- 'severity': 'test_value_15,',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('ips', 'rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_rule_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_rule': {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'date': '5',
- 'group': 'test_value_6',
- 'location': 'test_value_7,',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'name': 'default_name_10',
- 'os': 'test_value_11',
- 'rev': '12',
- 'rule_id': '13',
- 'service': 'test_value_14',
- 'severity': 'test_value_15,',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'date': '5',
- 'group': 'test_value_6',
- 'location': 'test_value_7,',
- 'log': 'disable',
- 'log-packet': 'disable',
- 'name': 'default_name_10',
- 'os': 'test_value_11',
- 'rev': '12',
- 'rule-id': '13',
- 'service': 'test_value_14',
- 'severity': 'test_value_15,',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('ips', 'rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_rule_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ips_rule': {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'date': '5',
- 'group': 'test_value_6',
- 'location': 'test_value_7,',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'name': 'default_name_10',
- 'os': 'test_value_11',
- 'rev': '12',
- 'rule_id': '13',
- 'service': 'test_value_14',
- 'severity': 'test_value_15,',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule.fortios_ips(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ips', 'rule', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_rule_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ips_rule': {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'date': '5',
- 'group': 'test_value_6',
- 'location': 'test_value_7,',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'name': 'default_name_10',
- 'os': 'test_value_11',
- 'rev': '12',
- 'rule_id': '13',
- 'service': 'test_value_14',
- 'severity': 'test_value_15,',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule.fortios_ips(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ips', 'rule', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_rule_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_rule': {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'date': '5',
- 'group': 'test_value_6',
- 'location': 'test_value_7,',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'name': 'default_name_10',
- 'os': 'test_value_11',
- 'rev': '12',
- 'rule_id': '13',
- 'service': 'test_value_14',
- 'severity': 'test_value_15,',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'date': '5',
- 'group': 'test_value_6',
- 'location': 'test_value_7,',
- 'log': 'disable',
- 'log-packet': 'disable',
- 'name': 'default_name_10',
- 'os': 'test_value_11',
- 'rev': '12',
- 'rule-id': '13',
- 'service': 'test_value_14',
- 'severity': 'test_value_15,',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('ips', 'rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_ips_rule_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_rule': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'pass',
- 'application': 'test_value_4',
- 'date': '5',
- 'group': 'test_value_6',
- 'location': 'test_value_7,',
- 'log': 'disable',
- 'log_packet': 'disable',
- 'name': 'default_name_10',
- 'os': 'test_value_11',
- 'rev': '12',
- 'rule_id': '13',
- 'service': 'test_value_14',
- 'severity': 'test_value_15,',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'action': 'pass',
- 'application': 'test_value_4',
- 'date': '5',
- 'group': 'test_value_6',
- 'location': 'test_value_7,',
- 'log': 'disable',
- 'log-packet': 'disable',
- 'name': 'default_name_10',
- 'os': 'test_value_11',
- 'rev': '12',
- 'rule-id': '13',
- 'service': 'test_value_14',
- 'severity': 'test_value_15,',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('ips', 'rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_ips_rule_settings.py b/test/units/modules/network/fortios/test_fortios_ips_rule_settings.py
deleted file mode 100644
index 73dc9015fb..0000000000
--- a/test/units/modules/network/fortios/test_fortios_ips_rule_settings.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_ips_rule_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_ips_rule_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_ips_rule_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_rule_settings': {
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule_settings.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'id': '3'
- }
-
- set_method_mock.assert_called_with('ips', 'rule-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_rule_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_rule_settings': {
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule_settings.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'id': '3'
- }
-
- set_method_mock.assert_called_with('ips', 'rule-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_rule_settings_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ips_rule_settings': {
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule_settings.fortios_ips(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ips', 'rule-settings', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_rule_settings_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ips_rule_settings': {
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule_settings.fortios_ips(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ips', 'rule-settings', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_rule_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_rule_settings': {
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule_settings.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'id': '3'
- }
-
- set_method_mock.assert_called_with('ips', 'rule-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_ips_rule_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_rule_settings': {
- 'random_attribute_not_valid': 'tag',
- 'id': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_rule_settings.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'id': '3'
- }
-
- set_method_mock.assert_called_with('ips', 'rule-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_ips_sensor.py b/test/units/modules/network/fortios/test_fortios_ips_sensor.py
deleted file mode 100644
index dad537080c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_ips_sensor.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_ips_sensor
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_ips_sensor.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_ips_sensor_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_sensor': {
- 'block_malicious_url': 'disable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_sensor.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'block-malicious-url': 'disable',
- 'comment': 'Comment.',
- 'extended-log': 'enable',
- 'name': 'default_name_6',
- 'replacemsg-group': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('ips', 'sensor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_sensor_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_sensor': {
- 'block_malicious_url': 'disable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_sensor.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'block-malicious-url': 'disable',
- 'comment': 'Comment.',
- 'extended-log': 'enable',
- 'name': 'default_name_6',
- 'replacemsg-group': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('ips', 'sensor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_sensor_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ips_sensor': {
- 'block_malicious_url': 'disable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_sensor.fortios_ips(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ips', 'sensor', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_sensor_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ips_sensor': {
- 'block_malicious_url': 'disable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_sensor.fortios_ips(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ips', 'sensor', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_sensor_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_sensor': {
- 'block_malicious_url': 'disable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_sensor.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'block-malicious-url': 'disable',
- 'comment': 'Comment.',
- 'extended-log': 'enable',
- 'name': 'default_name_6',
- 'replacemsg-group': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('ips', 'sensor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_ips_sensor_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_sensor': {
- 'random_attribute_not_valid': 'tag',
- 'block_malicious_url': 'disable',
- 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_sensor.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'block-malicious-url': 'disable',
- 'comment': 'Comment.',
- 'extended-log': 'enable',
- 'name': 'default_name_6',
- 'replacemsg-group': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('ips', 'sensor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_ips_settings.py b/test/units/modules/network/fortios/test_fortios_ips_settings.py
deleted file mode 100644
index 00132bcd83..0000000000
--- a/test/units/modules/network/fortios/test_fortios_ips_settings.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_ips_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_ips_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_ips_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_settings': {
- 'ips_packet_quota': '3',
- 'packet_log_history': '4',
- 'packet_log_memory': '5',
- 'packet_log_post_attack': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_settings.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'ips-packet-quota': '3',
- 'packet-log-history': '4',
- 'packet-log-memory': '5',
- 'packet-log-post-attack': '6'
- }
-
- set_method_mock.assert_called_with('ips', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ips_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_settings': {
- 'ips_packet_quota': '3',
- 'packet_log_history': '4',
- 'packet_log_memory': '5',
- 'packet_log_post_attack': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_settings.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'ips-packet-quota': '3',
- 'packet-log-history': '4',
- 'packet-log-memory': '5',
- 'packet-log-post-attack': '6'
- }
-
- set_method_mock.assert_called_with('ips', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ips_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_settings': {
- 'ips_packet_quota': '3',
- 'packet_log_history': '4',
- 'packet_log_memory': '5',
- 'packet_log_post_attack': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_settings.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'ips-packet-quota': '3',
- 'packet-log-history': '4',
- 'packet-log-memory': '5',
- 'packet-log-post-attack': '6'
- }
-
- set_method_mock.assert_called_with('ips', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_ips_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ips_settings': {
- 'random_attribute_not_valid': 'tag',
- 'ips_packet_quota': '3',
- 'packet_log_history': '4',
- 'packet_log_memory': '5',
- 'packet_log_post_attack': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ips_settings.fortios_ips(input_data, fos_instance)
-
- expected_data = {
- 'ips-packet-quota': '3',
- 'packet-log-history': '4',
- 'packet-log-memory': '5',
- 'packet-log-post-attack': '6'
- }
-
- set_method_mock.assert_called_with('ips', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_custom_field.py b/test/units/modules/network/fortios/test_fortios_log_custom_field.py
deleted file mode 100644
index 74035aa91e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_custom_field.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_custom_field
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_custom_field.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_custom_field_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_custom_field': {
- 'id': '3',
- 'name': 'default_name_4',
- 'value': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_custom_field.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4',
- 'value': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('log', 'custom-field', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_custom_field_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_custom_field': {
- 'id': '3',
- 'name': 'default_name_4',
- 'value': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_custom_field.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4',
- 'value': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('log', 'custom-field', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_custom_field_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'log_custom_field': {
- 'id': '3',
- 'name': 'default_name_4',
- 'value': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_custom_field.fortios_log(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('log', 'custom-field', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_custom_field_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'log_custom_field': {
- 'id': '3',
- 'name': 'default_name_4',
- 'value': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_custom_field.fortios_log(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('log', 'custom-field', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_custom_field_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_custom_field': {
- 'id': '3',
- 'name': 'default_name_4',
- 'value': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_custom_field.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4',
- 'value': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('log', 'custom-field', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_custom_field_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_custom_field': {
- 'random_attribute_not_valid': 'tag',
- 'id': '3',
- 'name': 'default_name_4',
- 'value': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_custom_field.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4',
- 'value': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('log', 'custom-field', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_disk_filter.py b/test/units/modules/network/fortios/test_fortios_log_disk_filter.py
deleted file mode 100644
index 6ffef21cdb..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_disk_filter.py
+++ /dev/null
@@ -1,407 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_disk_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_disk_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_disk_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_disk_filter': {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu_memory_usage': 'enable',
- 'dhcp': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_11',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb_monitor': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_20,',
- 'netscan_vulnerability': 'test_value_21,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn_log_adm': 'enable',
- 'sslvpn_log_auth': 'enable',
- 'sslvpn_log_session': 'enable',
- 'system': 'enable',
- 'vip_ssl': 'enable',
- 'voip': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_disk_filter.fortios_log_disk(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu-memory-usage': 'enable',
- 'dhcp': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_11',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb-monitor': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_20,',
- 'netscan-vulnerability': 'test_value_21,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn-log-adm': 'enable',
- 'sslvpn-log-auth': 'enable',
- 'sslvpn-log-session': 'enable',
- 'system': 'enable',
- 'vip-ssl': 'enable',
- 'voip': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log.disk', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_disk_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_disk_filter': {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu_memory_usage': 'enable',
- 'dhcp': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_11',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb_monitor': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_20,',
- 'netscan_vulnerability': 'test_value_21,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn_log_adm': 'enable',
- 'sslvpn_log_auth': 'enable',
- 'sslvpn_log_session': 'enable',
- 'system': 'enable',
- 'vip_ssl': 'enable',
- 'voip': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_disk_filter.fortios_log_disk(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu-memory-usage': 'enable',
- 'dhcp': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_11',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb-monitor': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_20,',
- 'netscan-vulnerability': 'test_value_21,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn-log-adm': 'enable',
- 'sslvpn-log-auth': 'enable',
- 'sslvpn-log-session': 'enable',
- 'system': 'enable',
- 'vip-ssl': 'enable',
- 'voip': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log.disk', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_disk_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_disk_filter': {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu_memory_usage': 'enable',
- 'dhcp': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_11',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb_monitor': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_20,',
- 'netscan_vulnerability': 'test_value_21,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn_log_adm': 'enable',
- 'sslvpn_log_auth': 'enable',
- 'sslvpn_log_session': 'enable',
- 'system': 'enable',
- 'vip_ssl': 'enable',
- 'voip': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_disk_filter.fortios_log_disk(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu-memory-usage': 'enable',
- 'dhcp': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_11',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb-monitor': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_20,',
- 'netscan-vulnerability': 'test_value_21,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn-log-adm': 'enable',
- 'sslvpn-log-auth': 'enable',
- 'sslvpn-log-session': 'enable',
- 'system': 'enable',
- 'vip-ssl': 'enable',
- 'voip': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log.disk', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_disk_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_disk_filter': {
- 'random_attribute_not_valid': 'tag',
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu_memory_usage': 'enable',
- 'dhcp': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_11',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb_monitor': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_20,',
- 'netscan_vulnerability': 'test_value_21,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn_log_adm': 'enable',
- 'sslvpn_log_auth': 'enable',
- 'sslvpn_log_session': 'enable',
- 'system': 'enable',
- 'vip_ssl': 'enable',
- 'voip': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_disk_filter.fortios_log_disk(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu-memory-usage': 'enable',
- 'dhcp': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_11',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb-monitor': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_20,',
- 'netscan-vulnerability': 'test_value_21,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn-log-adm': 'enable',
- 'sslvpn-log-auth': 'enable',
- 'sslvpn-log-session': 'enable',
- 'system': 'enable',
- 'vip-ssl': 'enable',
- 'voip': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log.disk', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_disk_setting.py b/test/units/modules/network/fortios/test_fortios_log_disk_setting.py
deleted file mode 100644
index 1751571678..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_disk_setting.py
+++ /dev/null
@@ -1,367 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_disk_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_disk_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_disk_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_disk_setting': {
- 'diskfull': 'overwrite',
- 'dlp_archive_quota': '4',
- 'full_final_warning_threshold': '5',
- 'full_first_warning_threshold': '6',
- 'full_second_warning_threshold': '7',
- 'ips_archive': 'enable',
- 'log_quota': '9',
- 'max_log_file_size': '10',
- 'max_policy_packet_capture_size': '11',
- 'maximum_log_age': '12',
- 'report_quota': '13',
- 'roll_day': 'sunday',
- 'roll_schedule': 'daily',
- 'roll_time': 'test_value_16',
- 'source_ip': '84.230.14.17',
- 'status': 'enable',
- 'upload': 'enable',
- 'upload_delete_files': 'enable',
- 'upload_destination': 'ftp-server',
- 'upload_ssl_conn': 'default',
- 'uploaddir': 'test_value_23',
- 'uploadip': 'test_value_24',
- 'uploadpass': 'test_value_25',
- 'uploadport': '26',
- 'uploadsched': 'disable',
- 'uploadtime': 'test_value_28',
- 'uploadtype': 'traffic',
- 'uploaduser': 'test_value_30'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_disk_setting.fortios_log_disk(input_data, fos_instance)
-
- expected_data = {
- 'diskfull': 'overwrite',
- 'dlp-archive-quota': '4',
- 'full-final-warning-threshold': '5',
- 'full-first-warning-threshold': '6',
- 'full-second-warning-threshold': '7',
- 'ips-archive': 'enable',
- 'log-quota': '9',
- 'max-log-file-size': '10',
- 'max-policy-packet-capture-size': '11',
- 'maximum-log-age': '12',
- 'report-quota': '13',
- 'roll-day': 'sunday',
- 'roll-schedule': 'daily',
- 'roll-time': 'test_value_16',
- 'source-ip': '84.230.14.17',
- 'status': 'enable',
- 'upload': 'enable',
- 'upload-delete-files': 'enable',
- 'upload-destination': 'ftp-server',
- 'upload-ssl-conn': 'default',
- 'uploaddir': 'test_value_23',
- 'uploadip': 'test_value_24',
- 'uploadpass': 'test_value_25',
- 'uploadport': '26',
- 'uploadsched': 'disable',
- 'uploadtime': 'test_value_28',
- 'uploadtype': 'traffic',
- 'uploaduser': 'test_value_30'
- }
-
- set_method_mock.assert_called_with('log.disk', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_disk_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_disk_setting': {
- 'diskfull': 'overwrite',
- 'dlp_archive_quota': '4',
- 'full_final_warning_threshold': '5',
- 'full_first_warning_threshold': '6',
- 'full_second_warning_threshold': '7',
- 'ips_archive': 'enable',
- 'log_quota': '9',
- 'max_log_file_size': '10',
- 'max_policy_packet_capture_size': '11',
- 'maximum_log_age': '12',
- 'report_quota': '13',
- 'roll_day': 'sunday',
- 'roll_schedule': 'daily',
- 'roll_time': 'test_value_16',
- 'source_ip': '84.230.14.17',
- 'status': 'enable',
- 'upload': 'enable',
- 'upload_delete_files': 'enable',
- 'upload_destination': 'ftp-server',
- 'upload_ssl_conn': 'default',
- 'uploaddir': 'test_value_23',
- 'uploadip': 'test_value_24',
- 'uploadpass': 'test_value_25',
- 'uploadport': '26',
- 'uploadsched': 'disable',
- 'uploadtime': 'test_value_28',
- 'uploadtype': 'traffic',
- 'uploaduser': 'test_value_30'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_disk_setting.fortios_log_disk(input_data, fos_instance)
-
- expected_data = {
- 'diskfull': 'overwrite',
- 'dlp-archive-quota': '4',
- 'full-final-warning-threshold': '5',
- 'full-first-warning-threshold': '6',
- 'full-second-warning-threshold': '7',
- 'ips-archive': 'enable',
- 'log-quota': '9',
- 'max-log-file-size': '10',
- 'max-policy-packet-capture-size': '11',
- 'maximum-log-age': '12',
- 'report-quota': '13',
- 'roll-day': 'sunday',
- 'roll-schedule': 'daily',
- 'roll-time': 'test_value_16',
- 'source-ip': '84.230.14.17',
- 'status': 'enable',
- 'upload': 'enable',
- 'upload-delete-files': 'enable',
- 'upload-destination': 'ftp-server',
- 'upload-ssl-conn': 'default',
- 'uploaddir': 'test_value_23',
- 'uploadip': 'test_value_24',
- 'uploadpass': 'test_value_25',
- 'uploadport': '26',
- 'uploadsched': 'disable',
- 'uploadtime': 'test_value_28',
- 'uploadtype': 'traffic',
- 'uploaduser': 'test_value_30'
- }
-
- set_method_mock.assert_called_with('log.disk', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_disk_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_disk_setting': {
- 'diskfull': 'overwrite',
- 'dlp_archive_quota': '4',
- 'full_final_warning_threshold': '5',
- 'full_first_warning_threshold': '6',
- 'full_second_warning_threshold': '7',
- 'ips_archive': 'enable',
- 'log_quota': '9',
- 'max_log_file_size': '10',
- 'max_policy_packet_capture_size': '11',
- 'maximum_log_age': '12',
- 'report_quota': '13',
- 'roll_day': 'sunday',
- 'roll_schedule': 'daily',
- 'roll_time': 'test_value_16',
- 'source_ip': '84.230.14.17',
- 'status': 'enable',
- 'upload': 'enable',
- 'upload_delete_files': 'enable',
- 'upload_destination': 'ftp-server',
- 'upload_ssl_conn': 'default',
- 'uploaddir': 'test_value_23',
- 'uploadip': 'test_value_24',
- 'uploadpass': 'test_value_25',
- 'uploadport': '26',
- 'uploadsched': 'disable',
- 'uploadtime': 'test_value_28',
- 'uploadtype': 'traffic',
- 'uploaduser': 'test_value_30'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_disk_setting.fortios_log_disk(input_data, fos_instance)
-
- expected_data = {
- 'diskfull': 'overwrite',
- 'dlp-archive-quota': '4',
- 'full-final-warning-threshold': '5',
- 'full-first-warning-threshold': '6',
- 'full-second-warning-threshold': '7',
- 'ips-archive': 'enable',
- 'log-quota': '9',
- 'max-log-file-size': '10',
- 'max-policy-packet-capture-size': '11',
- 'maximum-log-age': '12',
- 'report-quota': '13',
- 'roll-day': 'sunday',
- 'roll-schedule': 'daily',
- 'roll-time': 'test_value_16',
- 'source-ip': '84.230.14.17',
- 'status': 'enable',
- 'upload': 'enable',
- 'upload-delete-files': 'enable',
- 'upload-destination': 'ftp-server',
- 'upload-ssl-conn': 'default',
- 'uploaddir': 'test_value_23',
- 'uploadip': 'test_value_24',
- 'uploadpass': 'test_value_25',
- 'uploadport': '26',
- 'uploadsched': 'disable',
- 'uploadtime': 'test_value_28',
- 'uploadtype': 'traffic',
- 'uploaduser': 'test_value_30'
- }
-
- set_method_mock.assert_called_with('log.disk', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_disk_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_disk_setting': {
- 'random_attribute_not_valid': 'tag',
- 'diskfull': 'overwrite',
- 'dlp_archive_quota': '4',
- 'full_final_warning_threshold': '5',
- 'full_first_warning_threshold': '6',
- 'full_second_warning_threshold': '7',
- 'ips_archive': 'enable',
- 'log_quota': '9',
- 'max_log_file_size': '10',
- 'max_policy_packet_capture_size': '11',
- 'maximum_log_age': '12',
- 'report_quota': '13',
- 'roll_day': 'sunday',
- 'roll_schedule': 'daily',
- 'roll_time': 'test_value_16',
- 'source_ip': '84.230.14.17',
- 'status': 'enable',
- 'upload': 'enable',
- 'upload_delete_files': 'enable',
- 'upload_destination': 'ftp-server',
- 'upload_ssl_conn': 'default',
- 'uploaddir': 'test_value_23',
- 'uploadip': 'test_value_24',
- 'uploadpass': 'test_value_25',
- 'uploadport': '26',
- 'uploadsched': 'disable',
- 'uploadtime': 'test_value_28',
- 'uploadtype': 'traffic',
- 'uploaduser': 'test_value_30'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_disk_setting.fortios_log_disk(input_data, fos_instance)
-
- expected_data = {
- 'diskfull': 'overwrite',
- 'dlp-archive-quota': '4',
- 'full-final-warning-threshold': '5',
- 'full-first-warning-threshold': '6',
- 'full-second-warning-threshold': '7',
- 'ips-archive': 'enable',
- 'log-quota': '9',
- 'max-log-file-size': '10',
- 'max-policy-packet-capture-size': '11',
- 'maximum-log-age': '12',
- 'report-quota': '13',
- 'roll-day': 'sunday',
- 'roll-schedule': 'daily',
- 'roll-time': 'test_value_16',
- 'source-ip': '84.230.14.17',
- 'status': 'enable',
- 'upload': 'enable',
- 'upload-delete-files': 'enable',
- 'upload-destination': 'ftp-server',
- 'upload-ssl-conn': 'default',
- 'uploaddir': 'test_value_23',
- 'uploadip': 'test_value_24',
- 'uploadpass': 'test_value_25',
- 'uploadport': '26',
- 'uploadsched': 'disable',
- 'uploadtime': 'test_value_28',
- 'uploadtype': 'traffic',
- 'uploaduser': 'test_value_30'
- }
-
- set_method_mock.assert_called_with('log.disk', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_eventfilter.py b/test/units/modules/network/fortios/test_fortios_log_eventfilter.py
deleted file mode 100644
index 09d66d4ada..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_eventfilter.py
+++ /dev/null
@@ -1,231 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_eventfilter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_eventfilter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_eventfilter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_eventfilter': {
- 'compliance_check': 'enable',
- 'endpoint': 'enable',
- 'event': 'enable',
- 'ha': 'enable',
- 'router': 'enable',
- 'security_rating': 'enable',
- 'system': 'enable',
- 'user': 'enable',
- 'vpn': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_eventfilter.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'compliance-check': 'enable',
- 'endpoint': 'enable',
- 'event': 'enable',
- 'ha': 'enable',
- 'router': 'enable',
- 'security-rating': 'enable',
- 'system': 'enable',
- 'user': 'enable',
- 'vpn': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'eventfilter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_eventfilter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_eventfilter': {
- 'compliance_check': 'enable',
- 'endpoint': 'enable',
- 'event': 'enable',
- 'ha': 'enable',
- 'router': 'enable',
- 'security_rating': 'enable',
- 'system': 'enable',
- 'user': 'enable',
- 'vpn': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_eventfilter.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'compliance-check': 'enable',
- 'endpoint': 'enable',
- 'event': 'enable',
- 'ha': 'enable',
- 'router': 'enable',
- 'security-rating': 'enable',
- 'system': 'enable',
- 'user': 'enable',
- 'vpn': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'eventfilter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_eventfilter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_eventfilter': {
- 'compliance_check': 'enable',
- 'endpoint': 'enable',
- 'event': 'enable',
- 'ha': 'enable',
- 'router': 'enable',
- 'security_rating': 'enable',
- 'system': 'enable',
- 'user': 'enable',
- 'vpn': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_eventfilter.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'compliance-check': 'enable',
- 'endpoint': 'enable',
- 'event': 'enable',
- 'ha': 'enable',
- 'router': 'enable',
- 'security-rating': 'enable',
- 'system': 'enable',
- 'user': 'enable',
- 'vpn': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'eventfilter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_eventfilter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_eventfilter': {
- 'random_attribute_not_valid': 'tag',
- 'compliance_check': 'enable',
- 'endpoint': 'enable',
- 'event': 'enable',
- 'ha': 'enable',
- 'router': 'enable',
- 'security_rating': 'enable',
- 'system': 'enable',
- 'user': 'enable',
- 'vpn': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_eventfilter.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'compliance-check': 'enable',
- 'endpoint': 'enable',
- 'event': 'enable',
- 'ha': 'enable',
- 'router': 'enable',
- 'security-rating': 'enable',
- 'system': 'enable',
- 'user': 'enable',
- 'vpn': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'eventfilter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer2_filter.py b/test/units/modules/network/fortios/test_fortios_log_fortianalyzer2_filter.py
deleted file mode 100644
index 7643660361..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer2_filter.py
+++ /dev/null
@@ -1,263 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortianalyzer2_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortianalyzer2_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortianalyzer2_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer2_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer2_filter.fortios_log_fortianalyzer2(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer2', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortianalyzer2_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer2_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer2_filter.fortios_log_fortianalyzer2(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer2', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortianalyzer2_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer2_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer2_filter.fortios_log_fortianalyzer2(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer2', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortianalyzer2_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer2_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer2_filter.fortios_log_fortianalyzer2(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer2', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer2_setting.py b/test/units/modules/network/fortios/test_fortios_log_fortianalyzer2_setting.py
deleted file mode 100644
index 7b1b3269d3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer2_setting.py
+++ /dev/null
@@ -1,295 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortianalyzer2_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortianalyzer2_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortianalyzer2_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer2_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer2_setting.fortios_log_fortianalyzer2(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer2', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortianalyzer2_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer2_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer2_setting.fortios_log_fortianalyzer2(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer2', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortianalyzer2_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer2_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer2_setting.fortios_log_fortianalyzer2(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer2', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortianalyzer2_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer2_setting': {
- 'random_attribute_not_valid': 'tag',
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer2_setting.fortios_log_fortianalyzer2(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer2', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer3_filter.py b/test/units/modules/network/fortios/test_fortios_log_fortianalyzer3_filter.py
deleted file mode 100644
index 325f4cace1..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer3_filter.py
+++ /dev/null
@@ -1,263 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortianalyzer3_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortianalyzer3_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortianalyzer3_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer3_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer3_filter.fortios_log_fortianalyzer3(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer3', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortianalyzer3_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer3_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer3_filter.fortios_log_fortianalyzer3(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer3', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortianalyzer3_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer3_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer3_filter.fortios_log_fortianalyzer3(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer3', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortianalyzer3_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer3_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer3_filter.fortios_log_fortianalyzer3(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer3', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer3_setting.py b/test/units/modules/network/fortios/test_fortios_log_fortianalyzer3_setting.py
deleted file mode 100644
index 59a76a48e4..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer3_setting.py
+++ /dev/null
@@ -1,295 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortianalyzer3_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortianalyzer3_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortianalyzer3_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer3_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer3_setting.fortios_log_fortianalyzer3(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer3', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortianalyzer3_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer3_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer3_setting.fortios_log_fortianalyzer3(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer3', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortianalyzer3_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer3_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer3_setting.fortios_log_fortianalyzer3(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer3', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortianalyzer3_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer3_setting': {
- 'random_attribute_not_valid': 'tag',
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer3_setting.fortios_log_fortianalyzer3(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer3', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_filter.py b/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_filter.py
deleted file mode 100644
index cd3273cb33..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_filter.py
+++ /dev/null
@@ -1,263 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortianalyzer_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortianalyzer_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortianalyzer_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_filter.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortianalyzer_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_filter.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortianalyzer_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_filter.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortianalyzer_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_filter.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_override_filter.py b/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_override_filter.py
deleted file mode 100644
index 30e42c9c2a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_override_filter.py
+++ /dev/null
@@ -1,263 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortianalyzer_override_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortianalyzer_override_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortianalyzer_override_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_override_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_override_filter.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortianalyzer_override_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_override_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_override_filter.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortianalyzer_override_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_override_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_override_filter.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortianalyzer_override_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_override_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_override_filter.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_override_setting.py b/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_override_setting.py
deleted file mode 100644
index c933de926f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_override_setting.py
+++ /dev/null
@@ -1,311 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortianalyzer_override_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortianalyzer_override_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortianalyzer_override_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_override_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'override': 'enable',
- 'reliable': 'enable',
- 'server': '192.168.100.15',
- 'source_ip': '84.230.14.16',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_19',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_22',
- 'use_management_vdom': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_override_setting.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'override': 'enable',
- 'reliable': 'enable',
- 'server': '192.168.100.15',
- 'source-ip': '84.230.14.16',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_19',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_22',
- 'use-management-vdom': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortianalyzer_override_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_override_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'override': 'enable',
- 'reliable': 'enable',
- 'server': '192.168.100.15',
- 'source_ip': '84.230.14.16',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_19',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_22',
- 'use_management_vdom': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_override_setting.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'override': 'enable',
- 'reliable': 'enable',
- 'server': '192.168.100.15',
- 'source-ip': '84.230.14.16',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_19',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_22',
- 'use-management-vdom': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortianalyzer_override_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_override_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'override': 'enable',
- 'reliable': 'enable',
- 'server': '192.168.100.15',
- 'source_ip': '84.230.14.16',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_19',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_22',
- 'use_management_vdom': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_override_setting.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'override': 'enable',
- 'reliable': 'enable',
- 'server': '192.168.100.15',
- 'source-ip': '84.230.14.16',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_19',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_22',
- 'use-management-vdom': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortianalyzer_override_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_override_setting': {
- 'random_attribute_not_valid': 'tag',
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'override': 'enable',
- 'reliable': 'enable',
- 'server': '192.168.100.15',
- 'source_ip': '84.230.14.16',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_19',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_22',
- 'use_management_vdom': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_override_setting.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'override': 'enable',
- 'reliable': 'enable',
- 'server': '192.168.100.15',
- 'source-ip': '84.230.14.16',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_19',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_22',
- 'use-management-vdom': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_setting.py b/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_setting.py
deleted file mode 100644
index 6f19cf21e3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortianalyzer_setting.py
+++ /dev/null
@@ -1,295 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortianalyzer_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortianalyzer_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortianalyzer_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_setting.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortianalyzer_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_setting.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortianalyzer_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_setting': {
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_setting.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortianalyzer_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortianalyzer_setting': {
- 'random_attribute_not_valid': 'tag',
- '__change_ip': '3',
- 'certificate': 'test_value_4',
- 'conn_timeout': '5',
- 'enc_algorithm': 'high-medium',
- 'faz_type': '7',
- 'hmac_algorithm': 'sha256',
- 'ips_archive': 'enable',
- 'mgmt_name': 'test_value_10',
- 'monitor_failure_retry_period': '11',
- 'monitor_keepalive_period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source_ip': '84.230.14.15',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_18',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortianalyzer_setting.fortios_log_fortianalyzer(input_data, fos_instance)
-
- expected_data = {
- '--change-ip': '3',
- 'certificate': 'test_value_4',
- 'conn-timeout': '5',
- 'enc-algorithm': 'high-medium',
- 'faz-type': '7',
- 'hmac-algorithm': 'sha256',
- 'ips-archive': 'enable',
- 'mgmt-name': 'test_value_10',
- 'monitor-failure-retry-period': '11',
- 'monitor-keepalive-period': '12',
- 'reliable': 'enable',
- 'server': '192.168.100.14',
- 'source-ip': '84.230.14.15',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_18',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('log.fortianalyzer', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortiguard_filter.py b/test/units/modules/network/fortios/test_fortios_log_fortiguard_filter.py
deleted file mode 100644
index 94bf1ff49f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortiguard_filter.py
+++ /dev/null
@@ -1,263 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortiguard_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortiguard_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortiguard_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_filter.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortiguard_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_filter.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortiguard_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_filter.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortiguard_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_filter.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortiguard_override_filter.py b/test/units/modules/network/fortios/test_fortios_log_fortiguard_override_filter.py
deleted file mode 100644
index b28f9d81e3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortiguard_override_filter.py
+++ /dev/null
@@ -1,263 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortiguard_override_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortiguard_override_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortiguard_override_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_override_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_override_filter.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortiguard_override_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_override_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_override_filter.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortiguard_override_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_override_filter': {
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_override_filter.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortiguard_override_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_override_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dlp_archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_12,',
- 'netscan_vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_override_filter.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dlp-archive': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_6',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_12,',
- 'netscan-vulnerability': 'test_value_13,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortiguard_override_setting.py b/test/units/modules/network/fortios/test_fortios_log_fortiguard_override_setting.py
deleted file mode 100644
index 4882a1027a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortiguard_override_setting.py
+++ /dev/null
@@ -1,191 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortiguard_override_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortiguard_override_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortiguard_override_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_override_setting': {
- 'override': 'enable',
- 'status': 'enable',
- 'upload_day': 'test_value_5',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_override_setting.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'override': 'enable',
- 'status': 'enable',
- 'upload-day': 'test_value_5',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortiguard_override_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_override_setting': {
- 'override': 'enable',
- 'status': 'enable',
- 'upload_day': 'test_value_5',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_override_setting.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'override': 'enable',
- 'status': 'enable',
- 'upload-day': 'test_value_5',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortiguard_override_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_override_setting': {
- 'override': 'enable',
- 'status': 'enable',
- 'upload_day': 'test_value_5',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_override_setting.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'override': 'enable',
- 'status': 'enable',
- 'upload-day': 'test_value_5',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortiguard_override_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_override_setting': {
- 'random_attribute_not_valid': 'tag',
- 'override': 'enable',
- 'status': 'enable',
- 'upload_day': 'test_value_5',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_override_setting.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'override': 'enable',
- 'status': 'enable',
- 'upload-day': 'test_value_5',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_fortiguard_setting.py b/test/units/modules/network/fortios/test_fortios_log_fortiguard_setting.py
deleted file mode 100644
index 5978b84e3e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_fortiguard_setting.py
+++ /dev/null
@@ -1,207 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_fortiguard_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_fortiguard_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_fortiguard_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_setting': {
- 'enc_algorithm': 'high-medium',
- 'source_ip': '84.230.14.4',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_7',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_setting.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'enc-algorithm': 'high-medium',
- 'source-ip': '84.230.14.4',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_7',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_fortiguard_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_setting': {
- 'enc_algorithm': 'high-medium',
- 'source_ip': '84.230.14.4',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_7',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_setting.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'enc-algorithm': 'high-medium',
- 'source-ip': '84.230.14.4',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_7',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_fortiguard_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_setting': {
- 'enc_algorithm': 'high-medium',
- 'source_ip': '84.230.14.4',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_7',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_setting.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'enc-algorithm': 'high-medium',
- 'source-ip': '84.230.14.4',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_7',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_fortiguard_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_fortiguard_setting': {
- 'random_attribute_not_valid': 'tag',
- 'enc_algorithm': 'high-medium',
- 'source_ip': '84.230.14.4',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable',
- 'upload_day': 'test_value_7',
- 'upload_interval': 'daily',
- 'upload_option': 'store-and-upload',
- 'upload_time': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_fortiguard_setting.fortios_log_fortiguard(input_data, fos_instance)
-
- expected_data = {
- 'enc-algorithm': 'high-medium',
- 'source-ip': '84.230.14.4',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable',
- 'upload-day': 'test_value_7',
- 'upload-interval': 'daily',
- 'upload-option': 'store-and-upload',
- 'upload-time': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('log.fortiguard', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_gui_display.py b/test/units/modules/network/fortios/test_fortios_log_gui_display.py
deleted file mode 100644
index f54b2d66fe..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_gui_display.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_gui_display
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_gui_display.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_gui_display_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_gui_display': {
- 'fortiview_unscanned_apps': 'enable',
- 'resolve_apps': 'enable',
- 'resolve_hosts': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_gui_display.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'fortiview-unscanned-apps': 'enable',
- 'resolve-apps': 'enable',
- 'resolve-hosts': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'gui-display', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_gui_display_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_gui_display': {
- 'fortiview_unscanned_apps': 'enable',
- 'resolve_apps': 'enable',
- 'resolve_hosts': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_gui_display.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'fortiview-unscanned-apps': 'enable',
- 'resolve-apps': 'enable',
- 'resolve-hosts': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'gui-display', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_gui_display_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_gui_display': {
- 'fortiview_unscanned_apps': 'enable',
- 'resolve_apps': 'enable',
- 'resolve_hosts': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_gui_display.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'fortiview-unscanned-apps': 'enable',
- 'resolve-apps': 'enable',
- 'resolve-hosts': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'gui-display', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_gui_display_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_gui_display': {
- 'random_attribute_not_valid': 'tag',
- 'fortiview_unscanned_apps': 'enable',
- 'resolve_apps': 'enable',
- 'resolve_hosts': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_gui_display.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'fortiview-unscanned-apps': 'enable',
- 'resolve-apps': 'enable',
- 'resolve-hosts': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'gui-display', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_memory_filter.py b/test/units/modules/network/fortios/test_fortios_log_memory_filter.py
deleted file mode 100644
index 488709c52f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_memory_filter.py
+++ /dev/null
@@ -1,399 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_memory_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_memory_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_memory_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_filter': {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu_memory_usage': 'enable',
- 'dhcp': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_10',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb_monitor': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_19,',
- 'netscan_vulnerability': 'test_value_20,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn_log_adm': 'enable',
- 'sslvpn_log_auth': 'enable',
- 'sslvpn_log_session': 'enable',
- 'system': 'enable',
- 'vip_ssl': 'enable',
- 'voip': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_filter.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu-memory-usage': 'enable',
- 'dhcp': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_10',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb-monitor': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_19,',
- 'netscan-vulnerability': 'test_value_20,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn-log-adm': 'enable',
- 'sslvpn-log-auth': 'enable',
- 'sslvpn-log-session': 'enable',
- 'system': 'enable',
- 'vip-ssl': 'enable',
- 'voip': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log.memory', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_memory_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_filter': {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu_memory_usage': 'enable',
- 'dhcp': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_10',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb_monitor': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_19,',
- 'netscan_vulnerability': 'test_value_20,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn_log_adm': 'enable',
- 'sslvpn_log_auth': 'enable',
- 'sslvpn_log_session': 'enable',
- 'system': 'enable',
- 'vip_ssl': 'enable',
- 'voip': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_filter.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu-memory-usage': 'enable',
- 'dhcp': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_10',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb-monitor': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_19,',
- 'netscan-vulnerability': 'test_value_20,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn-log-adm': 'enable',
- 'sslvpn-log-auth': 'enable',
- 'sslvpn-log-session': 'enable',
- 'system': 'enable',
- 'vip-ssl': 'enable',
- 'voip': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log.memory', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_memory_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_filter': {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu_memory_usage': 'enable',
- 'dhcp': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_10',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb_monitor': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_19,',
- 'netscan_vulnerability': 'test_value_20,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn_log_adm': 'enable',
- 'sslvpn_log_auth': 'enable',
- 'sslvpn_log_session': 'enable',
- 'system': 'enable',
- 'vip_ssl': 'enable',
- 'voip': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_filter.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu-memory-usage': 'enable',
- 'dhcp': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_10',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb-monitor': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_19,',
- 'netscan-vulnerability': 'test_value_20,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn-log-adm': 'enable',
- 'sslvpn-log-auth': 'enable',
- 'sslvpn-log-session': 'enable',
- 'system': 'enable',
- 'vip-ssl': 'enable',
- 'voip': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log.memory', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_memory_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_filter': {
- 'random_attribute_not_valid': 'tag',
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu_memory_usage': 'enable',
- 'dhcp': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_10',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb_monitor': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_19,',
- 'netscan_vulnerability': 'test_value_20,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn_log_adm': 'enable',
- 'sslvpn_log_auth': 'enable',
- 'sslvpn_log_session': 'enable',
- 'system': 'enable',
- 'vip_ssl': 'enable',
- 'voip': 'enable',
- 'wan_opt': 'enable',
- 'wireless_activity': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_filter.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'enable',
- 'anomaly': 'enable',
- 'auth': 'enable',
- 'cpu-memory-usage': 'enable',
- 'dhcp': 'enable',
- 'dns': 'enable',
- 'event': 'enable',
- 'filter': 'test_value_10',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'ha': 'enable',
- 'ipsec': 'enable',
- 'ldb-monitor': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_19,',
- 'netscan-vulnerability': 'test_value_20,',
- 'pattern': 'enable',
- 'ppp': 'enable',
- 'radius': 'enable',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'sslvpn-log-adm': 'enable',
- 'sslvpn-log-auth': 'enable',
- 'sslvpn-log-session': 'enable',
- 'system': 'enable',
- 'vip-ssl': 'enable',
- 'voip': 'enable',
- 'wan-opt': 'enable',
- 'wireless-activity': 'enable'
- }
-
- set_method_mock.assert_called_with('log.memory', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_memory_global_setting.py b/test/units/modules/network/fortios/test_fortios_log_memory_global_setting.py
deleted file mode 100644
index 0782f5e9a9..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_memory_global_setting.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_memory_global_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_memory_global_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_memory_global_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_global_setting': {
- 'full_final_warning_threshold': '3',
- 'full_first_warning_threshold': '4',
- 'full_second_warning_threshold': '5',
- 'max_size': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_global_setting.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'full-final-warning-threshold': '3',
- 'full-first-warning-threshold': '4',
- 'full-second-warning-threshold': '5',
- 'max-size': '6'
- }
-
- set_method_mock.assert_called_with('log.memory', 'global-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_memory_global_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_global_setting': {
- 'full_final_warning_threshold': '3',
- 'full_first_warning_threshold': '4',
- 'full_second_warning_threshold': '5',
- 'max_size': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_global_setting.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'full-final-warning-threshold': '3',
- 'full-first-warning-threshold': '4',
- 'full-second-warning-threshold': '5',
- 'max-size': '6'
- }
-
- set_method_mock.assert_called_with('log.memory', 'global-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_memory_global_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_global_setting': {
- 'full_final_warning_threshold': '3',
- 'full_first_warning_threshold': '4',
- 'full_second_warning_threshold': '5',
- 'max_size': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_global_setting.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'full-final-warning-threshold': '3',
- 'full-first-warning-threshold': '4',
- 'full-second-warning-threshold': '5',
- 'max-size': '6'
- }
-
- set_method_mock.assert_called_with('log.memory', 'global-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_memory_global_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_global_setting': {
- 'random_attribute_not_valid': 'tag',
- 'full_final_warning_threshold': '3',
- 'full_first_warning_threshold': '4',
- 'full_second_warning_threshold': '5',
- 'max_size': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_global_setting.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'full-final-warning-threshold': '3',
- 'full-first-warning-threshold': '4',
- 'full-second-warning-threshold': '5',
- 'max-size': '6'
- }
-
- set_method_mock.assert_called_with('log.memory', 'global-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_memory_setting.py b/test/units/modules/network/fortios/test_fortios_log_memory_setting.py
deleted file mode 100644
index 64101c7a14..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_memory_setting.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_memory_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_memory_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_memory_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_setting': {
- 'diskfull': 'overwrite',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_setting.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'diskfull': 'overwrite',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.memory', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_memory_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_setting': {
- 'diskfull': 'overwrite',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_setting.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'diskfull': 'overwrite',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.memory', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_memory_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_setting': {
- 'diskfull': 'overwrite',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_setting.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'diskfull': 'overwrite',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.memory', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_memory_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_memory_setting': {
- 'random_attribute_not_valid': 'tag',
- 'diskfull': 'overwrite',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_memory_setting.fortios_log_memory(input_data, fos_instance)
-
- expected_data = {
- 'diskfull': 'overwrite',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.memory', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_null_device_filter.py b/test/units/modules/network/fortios/test_fortios_log_null_device_filter.py
deleted file mode 100644
index 86c2c90799..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_null_device_filter.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_null_device_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_null_device_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_null_device_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_null_device_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_null_device_filter.fortios_log_null_device(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.null-device', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_null_device_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_null_device_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_null_device_filter.fortios_log_null_device(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.null-device', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_null_device_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_null_device_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_null_device_filter.fortios_log_null_device(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.null-device', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_null_device_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_null_device_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_null_device_filter.fortios_log_null_device(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.null-device', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_null_device_setting.py b/test/units/modules/network/fortios/test_fortios_log_null_device_setting.py
deleted file mode 100644
index bf4e63c478..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_null_device_setting.py
+++ /dev/null
@@ -1,151 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_null_device_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_null_device_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_null_device_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_null_device_setting': {
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_null_device_setting.fortios_log_null_device(input_data, fos_instance)
-
- expected_data = {
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.null-device', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_null_device_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_null_device_setting': {
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_null_device_setting.fortios_log_null_device(input_data, fos_instance)
-
- expected_data = {
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.null-device', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_null_device_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_null_device_setting': {
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_null_device_setting.fortios_log_null_device(input_data, fos_instance)
-
- expected_data = {
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.null-device', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_null_device_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_null_device_setting': {
- 'random_attribute_not_valid': 'tag',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_null_device_setting.fortios_log_null_device(input_data, fos_instance)
-
- expected_data = {
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.null-device', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_setting.py b/test/units/modules/network/fortios/test_fortios_log_setting.py
deleted file mode 100644
index e3434e531a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_setting.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_setting': {
- 'brief_traffic_format': 'enable',
- 'daemon_log': 'enable',
- 'expolicy_implicit_log': 'enable',
- 'fwpolicy_implicit_log': 'enable',
- 'fwpolicy6_implicit_log': 'enable',
- 'local_in_allow': 'enable',
- 'local_in_deny_broadcast': 'enable',
- 'local_in_deny_unicast': 'enable',
- 'local_out': 'enable',
- 'log_invalid_packet': 'enable',
- 'log_policy_comment': 'enable',
- 'log_policy_name': 'enable',
- 'log_user_in_upper': 'enable',
- 'neighbor_event': 'enable',
- 'resolve_ip': 'enable',
- 'resolve_port': 'enable',
- 'user_anonymize': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_setting.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'brief-traffic-format': 'enable',
- 'daemon-log': 'enable',
- 'expolicy-implicit-log': 'enable',
- 'fwpolicy-implicit-log': 'enable',
- 'fwpolicy6-implicit-log': 'enable',
- 'local-in-allow': 'enable',
- 'local-in-deny-broadcast': 'enable',
- 'local-in-deny-unicast': 'enable',
- 'local-out': 'enable',
- 'log-invalid-packet': 'enable',
- 'log-policy-comment': 'enable',
- 'log-policy-name': 'enable',
- 'log-user-in-upper': 'enable',
- 'neighbor-event': 'enable',
- 'resolve-ip': 'enable',
- 'resolve-port': 'enable',
- 'user-anonymize': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_setting': {
- 'brief_traffic_format': 'enable',
- 'daemon_log': 'enable',
- 'expolicy_implicit_log': 'enable',
- 'fwpolicy_implicit_log': 'enable',
- 'fwpolicy6_implicit_log': 'enable',
- 'local_in_allow': 'enable',
- 'local_in_deny_broadcast': 'enable',
- 'local_in_deny_unicast': 'enable',
- 'local_out': 'enable',
- 'log_invalid_packet': 'enable',
- 'log_policy_comment': 'enable',
- 'log_policy_name': 'enable',
- 'log_user_in_upper': 'enable',
- 'neighbor_event': 'enable',
- 'resolve_ip': 'enable',
- 'resolve_port': 'enable',
- 'user_anonymize': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_setting.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'brief-traffic-format': 'enable',
- 'daemon-log': 'enable',
- 'expolicy-implicit-log': 'enable',
- 'fwpolicy-implicit-log': 'enable',
- 'fwpolicy6-implicit-log': 'enable',
- 'local-in-allow': 'enable',
- 'local-in-deny-broadcast': 'enable',
- 'local-in-deny-unicast': 'enable',
- 'local-out': 'enable',
- 'log-invalid-packet': 'enable',
- 'log-policy-comment': 'enable',
- 'log-policy-name': 'enable',
- 'log-user-in-upper': 'enable',
- 'neighbor-event': 'enable',
- 'resolve-ip': 'enable',
- 'resolve-port': 'enable',
- 'user-anonymize': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_setting': {
- 'brief_traffic_format': 'enable',
- 'daemon_log': 'enable',
- 'expolicy_implicit_log': 'enable',
- 'fwpolicy_implicit_log': 'enable',
- 'fwpolicy6_implicit_log': 'enable',
- 'local_in_allow': 'enable',
- 'local_in_deny_broadcast': 'enable',
- 'local_in_deny_unicast': 'enable',
- 'local_out': 'enable',
- 'log_invalid_packet': 'enable',
- 'log_policy_comment': 'enable',
- 'log_policy_name': 'enable',
- 'log_user_in_upper': 'enable',
- 'neighbor_event': 'enable',
- 'resolve_ip': 'enable',
- 'resolve_port': 'enable',
- 'user_anonymize': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_setting.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'brief-traffic-format': 'enable',
- 'daemon-log': 'enable',
- 'expolicy-implicit-log': 'enable',
- 'fwpolicy-implicit-log': 'enable',
- 'fwpolicy6-implicit-log': 'enable',
- 'local-in-allow': 'enable',
- 'local-in-deny-broadcast': 'enable',
- 'local-in-deny-unicast': 'enable',
- 'local-out': 'enable',
- 'log-invalid-packet': 'enable',
- 'log-policy-comment': 'enable',
- 'log-policy-name': 'enable',
- 'log-user-in-upper': 'enable',
- 'neighbor-event': 'enable',
- 'resolve-ip': 'enable',
- 'resolve-port': 'enable',
- 'user-anonymize': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_setting': {
- 'random_attribute_not_valid': 'tag',
- 'brief_traffic_format': 'enable',
- 'daemon_log': 'enable',
- 'expolicy_implicit_log': 'enable',
- 'fwpolicy_implicit_log': 'enable',
- 'fwpolicy6_implicit_log': 'enable',
- 'local_in_allow': 'enable',
- 'local_in_deny_broadcast': 'enable',
- 'local_in_deny_unicast': 'enable',
- 'local_out': 'enable',
- 'log_invalid_packet': 'enable',
- 'log_policy_comment': 'enable',
- 'log_policy_name': 'enable',
- 'log_user_in_upper': 'enable',
- 'neighbor_event': 'enable',
- 'resolve_ip': 'enable',
- 'resolve_port': 'enable',
- 'user_anonymize': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_setting.fortios_log(input_data, fos_instance)
-
- expected_data = {
- 'brief-traffic-format': 'enable',
- 'daemon-log': 'enable',
- 'expolicy-implicit-log': 'enable',
- 'fwpolicy-implicit-log': 'enable',
- 'fwpolicy6-implicit-log': 'enable',
- 'local-in-allow': 'enable',
- 'local-in-deny-broadcast': 'enable',
- 'local-in-deny-unicast': 'enable',
- 'local-out': 'enable',
- 'log-invalid-packet': 'enable',
- 'log-policy-comment': 'enable',
- 'log-policy-name': 'enable',
- 'log-user-in-upper': 'enable',
- 'neighbor-event': 'enable',
- 'resolve-ip': 'enable',
- 'resolve-port': 'enable',
- 'user-anonymize': 'enable'
- }
-
- set_method_mock.assert_called_with('log', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_syslogd2_filter.py b/test/units/modules/network/fortios/test_fortios_log_syslogd2_filter.py
deleted file mode 100644
index ee91549436..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_syslogd2_filter.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_syslogd2_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_syslogd2_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_syslogd2_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd2_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd2_filter.fortios_log_syslogd2(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd2', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_syslogd2_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd2_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd2_filter.fortios_log_syslogd2(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd2', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_syslogd2_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd2_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd2_filter.fortios_log_syslogd2(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd2', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_syslogd2_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd2_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd2_filter.fortios_log_syslogd2(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd2', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_syslogd2_setting.py b/test/units/modules/network/fortios/test_fortios_log_syslogd2_setting.py
deleted file mode 100644
index ec4061bb6d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_syslogd2_setting.py
+++ /dev/null
@@ -1,223 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_syslogd2_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_syslogd2_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_syslogd2_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd2_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd2_setting.fortios_log_syslogd2(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd2', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_syslogd2_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd2_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd2_setting.fortios_log_syslogd2(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd2', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_syslogd2_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd2_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd2_setting.fortios_log_syslogd2(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd2', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_syslogd2_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd2_setting': {
- 'random_attribute_not_valid': 'tag',
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd2_setting.fortios_log_syslogd2(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd2', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_syslogd3_filter.py b/test/units/modules/network/fortios/test_fortios_log_syslogd3_filter.py
deleted file mode 100644
index ff3fc99c8b..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_syslogd3_filter.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_syslogd3_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_syslogd3_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_syslogd3_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd3_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd3_filter.fortios_log_syslogd3(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd3', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_syslogd3_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd3_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd3_filter.fortios_log_syslogd3(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd3', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_syslogd3_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd3_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd3_filter.fortios_log_syslogd3(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd3', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_syslogd3_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd3_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd3_filter.fortios_log_syslogd3(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd3', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_syslogd3_setting.py b/test/units/modules/network/fortios/test_fortios_log_syslogd3_setting.py
deleted file mode 100644
index 3398f57623..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_syslogd3_setting.py
+++ /dev/null
@@ -1,223 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_syslogd3_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_syslogd3_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_syslogd3_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd3_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd3_setting.fortios_log_syslogd3(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd3', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_syslogd3_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd3_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd3_setting.fortios_log_syslogd3(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd3', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_syslogd3_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd3_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd3_setting.fortios_log_syslogd3(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd3', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_syslogd3_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd3_setting': {
- 'random_attribute_not_valid': 'tag',
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd3_setting.fortios_log_syslogd3(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd3', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_syslogd4_filter.py b/test/units/modules/network/fortios/test_fortios_log_syslogd4_filter.py
deleted file mode 100644
index 5e16cc4804..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_syslogd4_filter.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_syslogd4_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_syslogd4_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_syslogd4_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd4_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd4_filter.fortios_log_syslogd4(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd4', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_syslogd4_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd4_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd4_filter.fortios_log_syslogd4(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd4', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_syslogd4_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd4_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd4_filter.fortios_log_syslogd4(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd4', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_syslogd4_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd4_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd4_filter.fortios_log_syslogd4(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd4', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_syslogd4_setting.py b/test/units/modules/network/fortios/test_fortios_log_syslogd4_setting.py
deleted file mode 100644
index 582865fe43..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_syslogd4_setting.py
+++ /dev/null
@@ -1,223 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_syslogd4_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_syslogd4_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_syslogd4_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd4_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd4_setting.fortios_log_syslogd4(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd4', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_syslogd4_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd4_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd4_setting.fortios_log_syslogd4(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd4', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_syslogd4_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd4_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd4_setting.fortios_log_syslogd4(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd4', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_syslogd4_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd4_setting': {
- 'random_attribute_not_valid': 'tag',
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd4_setting.fortios_log_syslogd4(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd4', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_syslogd_filter.py b/test/units/modules/network/fortios/test_fortios_log_syslogd_filter.py
deleted file mode 100644
index 2ecaf06441..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_syslogd_filter.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_syslogd_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_syslogd_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_syslogd_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_filter.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_syslogd_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_filter.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_syslogd_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_filter.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_syslogd_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_filter.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_syslogd_override_filter.py b/test/units/modules/network/fortios/test_fortios_log_syslogd_override_filter.py
deleted file mode 100644
index eedbcbdf32..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_syslogd_override_filter.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_syslogd_override_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_syslogd_override_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_syslogd_override_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_override_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_override_filter.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_syslogd_override_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_override_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_override_filter.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_syslogd_override_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_override_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_override_filter.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_syslogd_override_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_override_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_override_filter.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'override-filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_syslogd_override_setting.py b/test/units/modules/network/fortios/test_fortios_log_syslogd_override_setting.py
deleted file mode 100644
index 460d03bab9..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_syslogd_override_setting.py
+++ /dev/null
@@ -1,231 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_syslogd_override_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_syslogd_override_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_syslogd_override_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_override_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'override': 'enable',
- 'port': '9',
- 'server': '192.168.100.10',
- 'source_ip': '84.230.14.11',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_override_setting.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'override': 'enable',
- 'port': '9',
- 'server': '192.168.100.10',
- 'source-ip': '84.230.14.11',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_syslogd_override_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_override_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'override': 'enable',
- 'port': '9',
- 'server': '192.168.100.10',
- 'source_ip': '84.230.14.11',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_override_setting.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'override': 'enable',
- 'port': '9',
- 'server': '192.168.100.10',
- 'source-ip': '84.230.14.11',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_syslogd_override_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_override_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'override': 'enable',
- 'port': '9',
- 'server': '192.168.100.10',
- 'source_ip': '84.230.14.11',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_override_setting.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'override': 'enable',
- 'port': '9',
- 'server': '192.168.100.10',
- 'source-ip': '84.230.14.11',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_syslogd_override_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_override_setting': {
- 'random_attribute_not_valid': 'tag',
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'override': 'enable',
- 'port': '9',
- 'server': '192.168.100.10',
- 'source_ip': '84.230.14.11',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_override_setting.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'override': 'enable',
- 'port': '9',
- 'server': '192.168.100.10',
- 'source-ip': '84.230.14.11',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'override-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_syslogd_setting.py b/test/units/modules/network/fortios/test_fortios_log_syslogd_setting.py
deleted file mode 100644
index 8f63cda92d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_syslogd_setting.py
+++ /dev/null
@@ -1,223 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_syslogd_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_syslogd_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_syslogd_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_setting.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_syslogd_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_setting.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_syslogd_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_setting': {
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_setting.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_syslogd_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_syslogd_setting': {
- 'random_attribute_not_valid': 'tag',
- 'certificate': 'test_value_3',
- 'enc_algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source_ip': '84.230.14.10',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_syslogd_setting.fortios_log_syslogd(input_data, fos_instance)
-
- expected_data = {
- 'certificate': 'test_value_3',
- 'enc-algorithm': 'high-medium',
- 'facility': 'kernel',
- 'format': 'default',
- 'mode': 'udp',
- 'port': '8',
- 'server': '192.168.100.9',
- 'source-ip': '84.230.14.10',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.syslogd', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_threat_weight.py b/test/units/modules/network/fortios/test_fortios_log_threat_weight.py
deleted file mode 100644
index 991529da8c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_threat_weight.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_threat_weight
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_threat_weight.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_threat_weight_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_threat_weight': {'blocked_connection': 'disable',
- 'failed_connection': 'disable',
- 'status': 'enable',
- 'url_block_detected': 'disable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_threat_weight.fortios_log(input_data, fos_instance)
-
- expected_data = {'blocked-connection': 'disable',
- 'failed-connection': 'disable',
- 'status': 'enable',
- 'url-block-detected': 'disable',
-
- }
-
- set_method_mock.assert_called_with('log', 'threat-weight', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_threat_weight_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_threat_weight': {'blocked_connection': 'disable',
- 'failed_connection': 'disable',
- 'status': 'enable',
- 'url_block_detected': 'disable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_threat_weight.fortios_log(input_data, fos_instance)
-
- expected_data = {'blocked-connection': 'disable',
- 'failed-connection': 'disable',
- 'status': 'enable',
- 'url-block-detected': 'disable',
-
- }
-
- set_method_mock.assert_called_with('log', 'threat-weight', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_threat_weight_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_threat_weight': {'blocked_connection': 'disable',
- 'failed_connection': 'disable',
- 'status': 'enable',
- 'url_block_detected': 'disable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_threat_weight.fortios_log(input_data, fos_instance)
-
- expected_data = {'blocked-connection': 'disable',
- 'failed-connection': 'disable',
- 'status': 'enable',
- 'url-block-detected': 'disable',
-
- }
-
- set_method_mock.assert_called_with('log', 'threat-weight', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_threat_weight_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_threat_weight': {
- 'random_attribute_not_valid': 'tag', 'blocked_connection': 'disable',
- 'failed_connection': 'disable',
- 'status': 'enable',
- 'url_block_detected': 'disable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_threat_weight.fortios_log(input_data, fos_instance)
-
- expected_data = {'blocked-connection': 'disable',
- 'failed-connection': 'disable',
- 'status': 'enable',
- 'url-block-detected': 'disable',
-
- }
-
- set_method_mock.assert_called_with('log', 'threat-weight', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_webtrends_filter.py b/test/units/modules/network/fortios/test_fortios_log_webtrends_filter.py
deleted file mode 100644
index c955da75ca..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_webtrends_filter.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_webtrends_filter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_webtrends_filter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_webtrends_filter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_webtrends_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_webtrends_filter.fortios_log_webtrends(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.webtrends', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_webtrends_filter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_webtrends_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_webtrends_filter.fortios_log_webtrends(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.webtrends', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_webtrends_filter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_webtrends_filter': {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_webtrends_filter.fortios_log_webtrends(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.webtrends', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_webtrends_filter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_webtrends_filter': {
- 'random_attribute_not_valid': 'tag',
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter_type': 'include',
- 'forward_traffic': 'enable',
- 'gtp': 'enable',
- 'local_traffic': 'enable',
- 'multicast_traffic': 'enable',
- 'netscan_discovery': 'test_value_11,',
- 'netscan_vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer_traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_webtrends_filter.fortios_log_webtrends(input_data, fos_instance)
-
- expected_data = {
- 'anomaly': 'enable',
- 'dns': 'enable',
- 'filter': 'test_value_5',
- 'filter-type': 'include',
- 'forward-traffic': 'enable',
- 'gtp': 'enable',
- 'local-traffic': 'enable',
- 'multicast-traffic': 'enable',
- 'netscan-discovery': 'test_value_11,',
- 'netscan-vulnerability': 'test_value_12,',
- 'severity': 'emergency',
- 'sniffer-traffic': 'enable',
- 'ssh': 'enable',
- 'voip': 'enable'
- }
-
- set_method_mock.assert_called_with('log.webtrends', 'filter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_log_webtrends_setting.py b/test/units/modules/network/fortios/test_fortios_log_webtrends_setting.py
deleted file mode 100644
index 0685fff5dc..0000000000
--- a/test/units/modules/network/fortios/test_fortios_log_webtrends_setting.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_log_webtrends_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_log_webtrends_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_log_webtrends_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_webtrends_setting': {
- 'server': '192.168.100.3',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_webtrends_setting.fortios_log_webtrends(input_data, fos_instance)
-
- expected_data = {
- 'server': '192.168.100.3',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.webtrends', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_log_webtrends_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_webtrends_setting': {
- 'server': '192.168.100.3',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_webtrends_setting.fortios_log_webtrends(input_data, fos_instance)
-
- expected_data = {
- 'server': '192.168.100.3',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.webtrends', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_log_webtrends_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_webtrends_setting': {
- 'server': '192.168.100.3',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_webtrends_setting.fortios_log_webtrends(input_data, fos_instance)
-
- expected_data = {
- 'server': '192.168.100.3',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.webtrends', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_log_webtrends_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'log_webtrends_setting': {
- 'random_attribute_not_valid': 'tag',
- 'server': '192.168.100.3',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_log_webtrends_setting.fortios_log_webtrends(input_data, fos_instance)
-
- expected_data = {
- 'server': '192.168.100.3',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('log.webtrends', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_report_chart.py b/test/units/modules/network/fortios/test_fortios_report_chart.py
deleted file mode 100644
index 211ee29936..0000000000
--- a/test/units/modules/network/fortios/test_fortios_report_chart.py
+++ /dev/null
@@ -1,369 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_report_chart
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_report_chart.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_report_chart_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_chart': {
- 'background': 'test_value_3',
- 'category': 'misc',
- 'color_palette': 'test_value_5',
- 'comments': 'test_value_6',
- 'dataset': 'test_value_7',
- 'dimension': '2D',
- 'favorite': 'no',
- 'graph_type': 'none',
- 'legend': 'enable',
- 'legend_font_size': '12',
- 'name': 'default_name_13',
- 'period': 'last24h',
- 'policy': '15',
- 'style': 'auto',
- 'title': 'test_value_17',
- 'title_font_size': '18',
- 'type': 'graph',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_chart.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'background': 'test_value_3',
- 'category': 'misc',
- 'color-palette': 'test_value_5',
- 'comments': 'test_value_6',
- 'dataset': 'test_value_7',
- 'dimension': '2D',
- 'favorite': 'no',
- 'graph-type': 'none',
- 'legend': 'enable',
- 'legend-font-size': '12',
- 'name': 'default_name_13',
- 'period': 'last24h',
- 'policy': '15',
- 'style': 'auto',
- 'title': 'test_value_17',
- 'title-font-size': '18',
- 'type': 'graph',
-
- }
-
- set_method_mock.assert_called_with('report', 'chart', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_report_chart_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_chart': {
- 'background': 'test_value_3',
- 'category': 'misc',
- 'color_palette': 'test_value_5',
- 'comments': 'test_value_6',
- 'dataset': 'test_value_7',
- 'dimension': '2D',
- 'favorite': 'no',
- 'graph_type': 'none',
- 'legend': 'enable',
- 'legend_font_size': '12',
- 'name': 'default_name_13',
- 'period': 'last24h',
- 'policy': '15',
- 'style': 'auto',
- 'title': 'test_value_17',
- 'title_font_size': '18',
- 'type': 'graph',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_chart.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'background': 'test_value_3',
- 'category': 'misc',
- 'color-palette': 'test_value_5',
- 'comments': 'test_value_6',
- 'dataset': 'test_value_7',
- 'dimension': '2D',
- 'favorite': 'no',
- 'graph-type': 'none',
- 'legend': 'enable',
- 'legend-font-size': '12',
- 'name': 'default_name_13',
- 'period': 'last24h',
- 'policy': '15',
- 'style': 'auto',
- 'title': 'test_value_17',
- 'title-font-size': '18',
- 'type': 'graph',
-
- }
-
- set_method_mock.assert_called_with('report', 'chart', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_report_chart_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'report_chart': {
- 'background': 'test_value_3',
- 'category': 'misc',
- 'color_palette': 'test_value_5',
- 'comments': 'test_value_6',
- 'dataset': 'test_value_7',
- 'dimension': '2D',
- 'favorite': 'no',
- 'graph_type': 'none',
- 'legend': 'enable',
- 'legend_font_size': '12',
- 'name': 'default_name_13',
- 'period': 'last24h',
- 'policy': '15',
- 'style': 'auto',
- 'title': 'test_value_17',
- 'title_font_size': '18',
- 'type': 'graph',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_chart.fortios_report(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('report', 'chart', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_report_chart_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'report_chart': {
- 'background': 'test_value_3',
- 'category': 'misc',
- 'color_palette': 'test_value_5',
- 'comments': 'test_value_6',
- 'dataset': 'test_value_7',
- 'dimension': '2D',
- 'favorite': 'no',
- 'graph_type': 'none',
- 'legend': 'enable',
- 'legend_font_size': '12',
- 'name': 'default_name_13',
- 'period': 'last24h',
- 'policy': '15',
- 'style': 'auto',
- 'title': 'test_value_17',
- 'title_font_size': '18',
- 'type': 'graph',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_chart.fortios_report(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('report', 'chart', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_report_chart_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_chart': {
- 'background': 'test_value_3',
- 'category': 'misc',
- 'color_palette': 'test_value_5',
- 'comments': 'test_value_6',
- 'dataset': 'test_value_7',
- 'dimension': '2D',
- 'favorite': 'no',
- 'graph_type': 'none',
- 'legend': 'enable',
- 'legend_font_size': '12',
- 'name': 'default_name_13',
- 'period': 'last24h',
- 'policy': '15',
- 'style': 'auto',
- 'title': 'test_value_17',
- 'title_font_size': '18',
- 'type': 'graph',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_chart.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'background': 'test_value_3',
- 'category': 'misc',
- 'color-palette': 'test_value_5',
- 'comments': 'test_value_6',
- 'dataset': 'test_value_7',
- 'dimension': '2D',
- 'favorite': 'no',
- 'graph-type': 'none',
- 'legend': 'enable',
- 'legend-font-size': '12',
- 'name': 'default_name_13',
- 'period': 'last24h',
- 'policy': '15',
- 'style': 'auto',
- 'title': 'test_value_17',
- 'title-font-size': '18',
- 'type': 'graph',
-
- }
-
- set_method_mock.assert_called_with('report', 'chart', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_report_chart_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_chart': {
- 'random_attribute_not_valid': 'tag',
- 'background': 'test_value_3',
- 'category': 'misc',
- 'color_palette': 'test_value_5',
- 'comments': 'test_value_6',
- 'dataset': 'test_value_7',
- 'dimension': '2D',
- 'favorite': 'no',
- 'graph_type': 'none',
- 'legend': 'enable',
- 'legend_font_size': '12',
- 'name': 'default_name_13',
- 'period': 'last24h',
- 'policy': '15',
- 'style': 'auto',
- 'title': 'test_value_17',
- 'title_font_size': '18',
- 'type': 'graph',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_chart.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'background': 'test_value_3',
- 'category': 'misc',
- 'color-palette': 'test_value_5',
- 'comments': 'test_value_6',
- 'dataset': 'test_value_7',
- 'dimension': '2D',
- 'favorite': 'no',
- 'graph-type': 'none',
- 'legend': 'enable',
- 'legend-font-size': '12',
- 'name': 'default_name_13',
- 'period': 'last24h',
- 'policy': '15',
- 'style': 'auto',
- 'title': 'test_value_17',
- 'title-font-size': '18',
- 'type': 'graph',
-
- }
-
- set_method_mock.assert_called_with('report', 'chart', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_report_dataset.py b/test/units/modules/network/fortios/test_fortios_report_dataset.py
deleted file mode 100644
index 6026d8e514..0000000000
--- a/test/units/modules/network/fortios/test_fortios_report_dataset.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_report_dataset
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_report_dataset.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_report_dataset_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_dataset': {'name': 'default_name_3',
- 'policy': '4',
- 'query': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_dataset.fortios_report(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'policy': '4',
- 'query': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('report', 'dataset', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_report_dataset_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_dataset': {'name': 'default_name_3',
- 'policy': '4',
- 'query': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_dataset.fortios_report(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'policy': '4',
- 'query': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('report', 'dataset', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_report_dataset_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'report_dataset': {'name': 'default_name_3',
- 'policy': '4',
- 'query': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_dataset.fortios_report(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('report', 'dataset', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_report_dataset_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'report_dataset': {'name': 'default_name_3',
- 'policy': '4',
- 'query': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_dataset.fortios_report(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('report', 'dataset', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_report_dataset_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_dataset': {'name': 'default_name_3',
- 'policy': '4',
- 'query': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_dataset.fortios_report(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'policy': '4',
- 'query': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('report', 'dataset', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_report_dataset_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_dataset': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3',
- 'policy': '4',
- 'query': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_dataset.fortios_report(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'policy': '4',
- 'query': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('report', 'dataset', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_report_layout.py b/test/units/modules/network/fortios/test_fortios_report_layout.py
deleted file mode 100644
index 63ed503ed5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_report_layout.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_report_layout
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_report_layout.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_report_layout_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_layout': {'cutoff_option': 'run-time',
- 'cutoff_time': 'test_value_4',
- 'day': 'sunday',
- 'description': 'test_value_6',
- 'email_recipients': 'test_value_7',
- 'email_send': 'enable',
- 'format': 'pdf',
- 'max_pdf_report': '10',
- 'name': 'default_name_11',
- 'options': 'include-table-of-content',
- 'schedule_type': 'demand',
- 'style_theme': 'test_value_14',
- 'subtitle': 'test_value_15',
- 'time': 'test_value_16',
- 'title': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_layout.fortios_report(input_data, fos_instance)
-
- expected_data = {'cutoff-option': 'run-time',
- 'cutoff-time': 'test_value_4',
- 'day': 'sunday',
- 'description': 'test_value_6',
- 'email-recipients': 'test_value_7',
- 'email-send': 'enable',
- 'format': 'pdf',
- 'max-pdf-report': '10',
- 'name': 'default_name_11',
- 'options': 'include-table-of-content',
- 'schedule-type': 'demand',
- 'style-theme': 'test_value_14',
- 'subtitle': 'test_value_15',
- 'time': 'test_value_16',
- 'title': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('report', 'layout', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_report_layout_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_layout': {'cutoff_option': 'run-time',
- 'cutoff_time': 'test_value_4',
- 'day': 'sunday',
- 'description': 'test_value_6',
- 'email_recipients': 'test_value_7',
- 'email_send': 'enable',
- 'format': 'pdf',
- 'max_pdf_report': '10',
- 'name': 'default_name_11',
- 'options': 'include-table-of-content',
- 'schedule_type': 'demand',
- 'style_theme': 'test_value_14',
- 'subtitle': 'test_value_15',
- 'time': 'test_value_16',
- 'title': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_layout.fortios_report(input_data, fos_instance)
-
- expected_data = {'cutoff-option': 'run-time',
- 'cutoff-time': 'test_value_4',
- 'day': 'sunday',
- 'description': 'test_value_6',
- 'email-recipients': 'test_value_7',
- 'email-send': 'enable',
- 'format': 'pdf',
- 'max-pdf-report': '10',
- 'name': 'default_name_11',
- 'options': 'include-table-of-content',
- 'schedule-type': 'demand',
- 'style-theme': 'test_value_14',
- 'subtitle': 'test_value_15',
- 'time': 'test_value_16',
- 'title': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('report', 'layout', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_report_layout_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'report_layout': {'cutoff_option': 'run-time',
- 'cutoff_time': 'test_value_4',
- 'day': 'sunday',
- 'description': 'test_value_6',
- 'email_recipients': 'test_value_7',
- 'email_send': 'enable',
- 'format': 'pdf',
- 'max_pdf_report': '10',
- 'name': 'default_name_11',
- 'options': 'include-table-of-content',
- 'schedule_type': 'demand',
- 'style_theme': 'test_value_14',
- 'subtitle': 'test_value_15',
- 'time': 'test_value_16',
- 'title': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_layout.fortios_report(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('report', 'layout', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_report_layout_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'report_layout': {'cutoff_option': 'run-time',
- 'cutoff_time': 'test_value_4',
- 'day': 'sunday',
- 'description': 'test_value_6',
- 'email_recipients': 'test_value_7',
- 'email_send': 'enable',
- 'format': 'pdf',
- 'max_pdf_report': '10',
- 'name': 'default_name_11',
- 'options': 'include-table-of-content',
- 'schedule_type': 'demand',
- 'style_theme': 'test_value_14',
- 'subtitle': 'test_value_15',
- 'time': 'test_value_16',
- 'title': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_layout.fortios_report(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('report', 'layout', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_report_layout_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_layout': {'cutoff_option': 'run-time',
- 'cutoff_time': 'test_value_4',
- 'day': 'sunday',
- 'description': 'test_value_6',
- 'email_recipients': 'test_value_7',
- 'email_send': 'enable',
- 'format': 'pdf',
- 'max_pdf_report': '10',
- 'name': 'default_name_11',
- 'options': 'include-table-of-content',
- 'schedule_type': 'demand',
- 'style_theme': 'test_value_14',
- 'subtitle': 'test_value_15',
- 'time': 'test_value_16',
- 'title': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_layout.fortios_report(input_data, fos_instance)
-
- expected_data = {'cutoff-option': 'run-time',
- 'cutoff-time': 'test_value_4',
- 'day': 'sunday',
- 'description': 'test_value_6',
- 'email-recipients': 'test_value_7',
- 'email-send': 'enable',
- 'format': 'pdf',
- 'max-pdf-report': '10',
- 'name': 'default_name_11',
- 'options': 'include-table-of-content',
- 'schedule-type': 'demand',
- 'style-theme': 'test_value_14',
- 'subtitle': 'test_value_15',
- 'time': 'test_value_16',
- 'title': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('report', 'layout', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_report_layout_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_layout': {
- 'random_attribute_not_valid': 'tag', 'cutoff_option': 'run-time',
- 'cutoff_time': 'test_value_4',
- 'day': 'sunday',
- 'description': 'test_value_6',
- 'email_recipients': 'test_value_7',
- 'email_send': 'enable',
- 'format': 'pdf',
- 'max_pdf_report': '10',
- 'name': 'default_name_11',
- 'options': 'include-table-of-content',
- 'schedule_type': 'demand',
- 'style_theme': 'test_value_14',
- 'subtitle': 'test_value_15',
- 'time': 'test_value_16',
- 'title': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_layout.fortios_report(input_data, fos_instance)
-
- expected_data = {'cutoff-option': 'run-time',
- 'cutoff-time': 'test_value_4',
- 'day': 'sunday',
- 'description': 'test_value_6',
- 'email-recipients': 'test_value_7',
- 'email-send': 'enable',
- 'format': 'pdf',
- 'max-pdf-report': '10',
- 'name': 'default_name_11',
- 'options': 'include-table-of-content',
- 'schedule-type': 'demand',
- 'style-theme': 'test_value_14',
- 'subtitle': 'test_value_15',
- 'time': 'test_value_16',
- 'title': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('report', 'layout', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_report_setting.py b/test/units/modules/network/fortios/test_fortios_report_setting.py
deleted file mode 100644
index b8450dabd7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_report_setting.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_report_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_report_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_report_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_setting': {
- 'fortiview': 'enable',
- 'pdf_report': 'enable',
- 'report_source': 'forward-traffic',
- 'top_n': '6',
- 'web_browsing_threshold': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_setting.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'fortiview': 'enable',
- 'pdf-report': 'enable',
- 'report-source': 'forward-traffic',
- 'top-n': '6',
- 'web-browsing-threshold': '7'
- }
-
- set_method_mock.assert_called_with('report', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_report_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_setting': {
- 'fortiview': 'enable',
- 'pdf_report': 'enable',
- 'report_source': 'forward-traffic',
- 'top_n': '6',
- 'web_browsing_threshold': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_setting.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'fortiview': 'enable',
- 'pdf-report': 'enable',
- 'report-source': 'forward-traffic',
- 'top-n': '6',
- 'web-browsing-threshold': '7'
- }
-
- set_method_mock.assert_called_with('report', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_report_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_setting': {
- 'fortiview': 'enable',
- 'pdf_report': 'enable',
- 'report_source': 'forward-traffic',
- 'top_n': '6',
- 'web_browsing_threshold': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_setting.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'fortiview': 'enable',
- 'pdf-report': 'enable',
- 'report-source': 'forward-traffic',
- 'top-n': '6',
- 'web-browsing-threshold': '7'
- }
-
- set_method_mock.assert_called_with('report', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_report_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_setting': {
- 'random_attribute_not_valid': 'tag',
- 'fortiview': 'enable',
- 'pdf_report': 'enable',
- 'report_source': 'forward-traffic',
- 'top_n': '6',
- 'web_browsing_threshold': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_setting.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'fortiview': 'enable',
- 'pdf-report': 'enable',
- 'report-source': 'forward-traffic',
- 'top-n': '6',
- 'web-browsing-threshold': '7'
- }
-
- set_method_mock.assert_called_with('report', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_report_style.py b/test/units/modules/network/fortios/test_fortios_report_style.py
deleted file mode 100644
index bf97f0be03..0000000000
--- a/test/units/modules/network/fortios/test_fortios_report_style.py
+++ /dev/null
@@ -1,449 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_report_style
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_report_style.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_report_style_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_style': {
- 'align': 'left',
- 'bg_color': 'test_value_4',
- 'border_bottom': 'test_value_5',
- 'border_left': 'test_value_6',
- 'border_right': 'test_value_7',
- 'border_top': 'test_value_8',
- 'column_gap': 'test_value_9',
- 'column_span': 'none',
- 'fg_color': 'test_value_11',
- 'font_family': 'Verdana',
- 'font_size': 'test_value_13',
- 'font_style': 'normal',
- 'font_weight': 'normal',
- 'height': 'test_value_16',
- 'line_height': 'test_value_17',
- 'margin_bottom': 'test_value_18',
- 'margin_left': 'test_value_19',
- 'margin_right': 'test_value_20',
- 'margin_top': 'test_value_21',
- 'name': 'default_name_22',
- 'options': 'font',
- 'padding_bottom': 'test_value_24',
- 'padding_left': 'test_value_25',
- 'padding_right': 'test_value_26',
- 'padding_top': 'test_value_27',
- 'width': 'test_value_28'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_style.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'align': 'left',
- 'bg-color': 'test_value_4',
- 'border-bottom': 'test_value_5',
- 'border-left': 'test_value_6',
- 'border-right': 'test_value_7',
- 'border-top': 'test_value_8',
- 'column-gap': 'test_value_9',
- 'column-span': 'none',
- 'fg-color': 'test_value_11',
- 'font-family': 'Verdana',
- 'font-size': 'test_value_13',
- 'font-style': 'normal',
- 'font-weight': 'normal',
- 'height': 'test_value_16',
- 'line-height': 'test_value_17',
- 'margin-bottom': 'test_value_18',
- 'margin-left': 'test_value_19',
- 'margin-right': 'test_value_20',
- 'margin-top': 'test_value_21',
- 'name': 'default_name_22',
- 'options': 'font',
- 'padding-bottom': 'test_value_24',
- 'padding-left': 'test_value_25',
- 'padding-right': 'test_value_26',
- 'padding-top': 'test_value_27',
- 'width': 'test_value_28'
- }
-
- set_method_mock.assert_called_with('report', 'style', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_report_style_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_style': {
- 'align': 'left',
- 'bg_color': 'test_value_4',
- 'border_bottom': 'test_value_5',
- 'border_left': 'test_value_6',
- 'border_right': 'test_value_7',
- 'border_top': 'test_value_8',
- 'column_gap': 'test_value_9',
- 'column_span': 'none',
- 'fg_color': 'test_value_11',
- 'font_family': 'Verdana',
- 'font_size': 'test_value_13',
- 'font_style': 'normal',
- 'font_weight': 'normal',
- 'height': 'test_value_16',
- 'line_height': 'test_value_17',
- 'margin_bottom': 'test_value_18',
- 'margin_left': 'test_value_19',
- 'margin_right': 'test_value_20',
- 'margin_top': 'test_value_21',
- 'name': 'default_name_22',
- 'options': 'font',
- 'padding_bottom': 'test_value_24',
- 'padding_left': 'test_value_25',
- 'padding_right': 'test_value_26',
- 'padding_top': 'test_value_27',
- 'width': 'test_value_28'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_style.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'align': 'left',
- 'bg-color': 'test_value_4',
- 'border-bottom': 'test_value_5',
- 'border-left': 'test_value_6',
- 'border-right': 'test_value_7',
- 'border-top': 'test_value_8',
- 'column-gap': 'test_value_9',
- 'column-span': 'none',
- 'fg-color': 'test_value_11',
- 'font-family': 'Verdana',
- 'font-size': 'test_value_13',
- 'font-style': 'normal',
- 'font-weight': 'normal',
- 'height': 'test_value_16',
- 'line-height': 'test_value_17',
- 'margin-bottom': 'test_value_18',
- 'margin-left': 'test_value_19',
- 'margin-right': 'test_value_20',
- 'margin-top': 'test_value_21',
- 'name': 'default_name_22',
- 'options': 'font',
- 'padding-bottom': 'test_value_24',
- 'padding-left': 'test_value_25',
- 'padding-right': 'test_value_26',
- 'padding-top': 'test_value_27',
- 'width': 'test_value_28'
- }
-
- set_method_mock.assert_called_with('report', 'style', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_report_style_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'report_style': {
- 'align': 'left',
- 'bg_color': 'test_value_4',
- 'border_bottom': 'test_value_5',
- 'border_left': 'test_value_6',
- 'border_right': 'test_value_7',
- 'border_top': 'test_value_8',
- 'column_gap': 'test_value_9',
- 'column_span': 'none',
- 'fg_color': 'test_value_11',
- 'font_family': 'Verdana',
- 'font_size': 'test_value_13',
- 'font_style': 'normal',
- 'font_weight': 'normal',
- 'height': 'test_value_16',
- 'line_height': 'test_value_17',
- 'margin_bottom': 'test_value_18',
- 'margin_left': 'test_value_19',
- 'margin_right': 'test_value_20',
- 'margin_top': 'test_value_21',
- 'name': 'default_name_22',
- 'options': 'font',
- 'padding_bottom': 'test_value_24',
- 'padding_left': 'test_value_25',
- 'padding_right': 'test_value_26',
- 'padding_top': 'test_value_27',
- 'width': 'test_value_28'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_style.fortios_report(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('report', 'style', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_report_style_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'report_style': {
- 'align': 'left',
- 'bg_color': 'test_value_4',
- 'border_bottom': 'test_value_5',
- 'border_left': 'test_value_6',
- 'border_right': 'test_value_7',
- 'border_top': 'test_value_8',
- 'column_gap': 'test_value_9',
- 'column_span': 'none',
- 'fg_color': 'test_value_11',
- 'font_family': 'Verdana',
- 'font_size': 'test_value_13',
- 'font_style': 'normal',
- 'font_weight': 'normal',
- 'height': 'test_value_16',
- 'line_height': 'test_value_17',
- 'margin_bottom': 'test_value_18',
- 'margin_left': 'test_value_19',
- 'margin_right': 'test_value_20',
- 'margin_top': 'test_value_21',
- 'name': 'default_name_22',
- 'options': 'font',
- 'padding_bottom': 'test_value_24',
- 'padding_left': 'test_value_25',
- 'padding_right': 'test_value_26',
- 'padding_top': 'test_value_27',
- 'width': 'test_value_28'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_style.fortios_report(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('report', 'style', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_report_style_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_style': {
- 'align': 'left',
- 'bg_color': 'test_value_4',
- 'border_bottom': 'test_value_5',
- 'border_left': 'test_value_6',
- 'border_right': 'test_value_7',
- 'border_top': 'test_value_8',
- 'column_gap': 'test_value_9',
- 'column_span': 'none',
- 'fg_color': 'test_value_11',
- 'font_family': 'Verdana',
- 'font_size': 'test_value_13',
- 'font_style': 'normal',
- 'font_weight': 'normal',
- 'height': 'test_value_16',
- 'line_height': 'test_value_17',
- 'margin_bottom': 'test_value_18',
- 'margin_left': 'test_value_19',
- 'margin_right': 'test_value_20',
- 'margin_top': 'test_value_21',
- 'name': 'default_name_22',
- 'options': 'font',
- 'padding_bottom': 'test_value_24',
- 'padding_left': 'test_value_25',
- 'padding_right': 'test_value_26',
- 'padding_top': 'test_value_27',
- 'width': 'test_value_28'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_style.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'align': 'left',
- 'bg-color': 'test_value_4',
- 'border-bottom': 'test_value_5',
- 'border-left': 'test_value_6',
- 'border-right': 'test_value_7',
- 'border-top': 'test_value_8',
- 'column-gap': 'test_value_9',
- 'column-span': 'none',
- 'fg-color': 'test_value_11',
- 'font-family': 'Verdana',
- 'font-size': 'test_value_13',
- 'font-style': 'normal',
- 'font-weight': 'normal',
- 'height': 'test_value_16',
- 'line-height': 'test_value_17',
- 'margin-bottom': 'test_value_18',
- 'margin-left': 'test_value_19',
- 'margin-right': 'test_value_20',
- 'margin-top': 'test_value_21',
- 'name': 'default_name_22',
- 'options': 'font',
- 'padding-bottom': 'test_value_24',
- 'padding-left': 'test_value_25',
- 'padding-right': 'test_value_26',
- 'padding-top': 'test_value_27',
- 'width': 'test_value_28'
- }
-
- set_method_mock.assert_called_with('report', 'style', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_report_style_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_style': {
- 'random_attribute_not_valid': 'tag',
- 'align': 'left',
- 'bg_color': 'test_value_4',
- 'border_bottom': 'test_value_5',
- 'border_left': 'test_value_6',
- 'border_right': 'test_value_7',
- 'border_top': 'test_value_8',
- 'column_gap': 'test_value_9',
- 'column_span': 'none',
- 'fg_color': 'test_value_11',
- 'font_family': 'Verdana',
- 'font_size': 'test_value_13',
- 'font_style': 'normal',
- 'font_weight': 'normal',
- 'height': 'test_value_16',
- 'line_height': 'test_value_17',
- 'margin_bottom': 'test_value_18',
- 'margin_left': 'test_value_19',
- 'margin_right': 'test_value_20',
- 'margin_top': 'test_value_21',
- 'name': 'default_name_22',
- 'options': 'font',
- 'padding_bottom': 'test_value_24',
- 'padding_left': 'test_value_25',
- 'padding_right': 'test_value_26',
- 'padding_top': 'test_value_27',
- 'width': 'test_value_28'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_style.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'align': 'left',
- 'bg-color': 'test_value_4',
- 'border-bottom': 'test_value_5',
- 'border-left': 'test_value_6',
- 'border-right': 'test_value_7',
- 'border-top': 'test_value_8',
- 'column-gap': 'test_value_9',
- 'column-span': 'none',
- 'fg-color': 'test_value_11',
- 'font-family': 'Verdana',
- 'font-size': 'test_value_13',
- 'font-style': 'normal',
- 'font-weight': 'normal',
- 'height': 'test_value_16',
- 'line-height': 'test_value_17',
- 'margin-bottom': 'test_value_18',
- 'margin-left': 'test_value_19',
- 'margin-right': 'test_value_20',
- 'margin-top': 'test_value_21',
- 'name': 'default_name_22',
- 'options': 'font',
- 'padding-bottom': 'test_value_24',
- 'padding-left': 'test_value_25',
- 'padding-right': 'test_value_26',
- 'padding-top': 'test_value_27',
- 'width': 'test_value_28'
- }
-
- set_method_mock.assert_called_with('report', 'style', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_report_theme.py b/test/units/modules/network/fortios/test_fortios_report_theme.py
deleted file mode 100644
index 2164b3da61..0000000000
--- a/test/units/modules/network/fortios/test_fortios_report_theme.py
+++ /dev/null
@@ -1,489 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_report_theme
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_report_theme.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_report_theme_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_theme': {
- 'bullet_list_style': 'test_value_3',
- 'column_count': '1',
- 'default_html_style': 'test_value_5',
- 'default_pdf_style': 'test_value_6',
- 'graph_chart_style': 'test_value_7',
- 'heading1_style': 'test_value_8',
- 'heading2_style': 'test_value_9',
- 'heading3_style': 'test_value_10',
- 'heading4_style': 'test_value_11',
- 'hline_style': 'test_value_12',
- 'image_style': 'test_value_13',
- 'name': 'default_name_14',
- 'normal_text_style': 'test_value_15',
- 'numbered_list_style': 'test_value_16',
- 'page_footer_style': 'test_value_17',
- 'page_header_style': 'test_value_18',
- 'page_orient': 'portrait',
- 'page_style': 'test_value_20',
- 'report_subtitle_style': 'test_value_21',
- 'report_title_style': 'test_value_22',
- 'table_chart_caption_style': 'test_value_23',
- 'table_chart_even_row_style': 'test_value_24',
- 'table_chart_head_style': 'test_value_25',
- 'table_chart_odd_row_style': 'test_value_26',
- 'table_chart_style': 'test_value_27',
- 'toc_heading1_style': 'test_value_28',
- 'toc_heading2_style': 'test_value_29',
- 'toc_heading3_style': 'test_value_30',
- 'toc_heading4_style': 'test_value_31',
- 'toc_title_style': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_theme.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'bullet-list-style': 'test_value_3',
- 'column-count': '1',
- 'default-html-style': 'test_value_5',
- 'default-pdf-style': 'test_value_6',
- 'graph-chart-style': 'test_value_7',
- 'heading1-style': 'test_value_8',
- 'heading2-style': 'test_value_9',
- 'heading3-style': 'test_value_10',
- 'heading4-style': 'test_value_11',
- 'hline-style': 'test_value_12',
- 'image-style': 'test_value_13',
- 'name': 'default_name_14',
- 'normal-text-style': 'test_value_15',
- 'numbered-list-style': 'test_value_16',
- 'page-footer-style': 'test_value_17',
- 'page-header-style': 'test_value_18',
- 'page-orient': 'portrait',
- 'page-style': 'test_value_20',
- 'report-subtitle-style': 'test_value_21',
- 'report-title-style': 'test_value_22',
- 'table-chart-caption-style': 'test_value_23',
- 'table-chart-even-row-style': 'test_value_24',
- 'table-chart-head-style': 'test_value_25',
- 'table-chart-odd-row-style': 'test_value_26',
- 'table-chart-style': 'test_value_27',
- 'toc-heading1-style': 'test_value_28',
- 'toc-heading2-style': 'test_value_29',
- 'toc-heading3-style': 'test_value_30',
- 'toc-heading4-style': 'test_value_31',
- 'toc-title-style': 'test_value_32'
- }
-
- set_method_mock.assert_called_with('report', 'theme', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_report_theme_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_theme': {
- 'bullet_list_style': 'test_value_3',
- 'column_count': '1',
- 'default_html_style': 'test_value_5',
- 'default_pdf_style': 'test_value_6',
- 'graph_chart_style': 'test_value_7',
- 'heading1_style': 'test_value_8',
- 'heading2_style': 'test_value_9',
- 'heading3_style': 'test_value_10',
- 'heading4_style': 'test_value_11',
- 'hline_style': 'test_value_12',
- 'image_style': 'test_value_13',
- 'name': 'default_name_14',
- 'normal_text_style': 'test_value_15',
- 'numbered_list_style': 'test_value_16',
- 'page_footer_style': 'test_value_17',
- 'page_header_style': 'test_value_18',
- 'page_orient': 'portrait',
- 'page_style': 'test_value_20',
- 'report_subtitle_style': 'test_value_21',
- 'report_title_style': 'test_value_22',
- 'table_chart_caption_style': 'test_value_23',
- 'table_chart_even_row_style': 'test_value_24',
- 'table_chart_head_style': 'test_value_25',
- 'table_chart_odd_row_style': 'test_value_26',
- 'table_chart_style': 'test_value_27',
- 'toc_heading1_style': 'test_value_28',
- 'toc_heading2_style': 'test_value_29',
- 'toc_heading3_style': 'test_value_30',
- 'toc_heading4_style': 'test_value_31',
- 'toc_title_style': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_theme.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'bullet-list-style': 'test_value_3',
- 'column-count': '1',
- 'default-html-style': 'test_value_5',
- 'default-pdf-style': 'test_value_6',
- 'graph-chart-style': 'test_value_7',
- 'heading1-style': 'test_value_8',
- 'heading2-style': 'test_value_9',
- 'heading3-style': 'test_value_10',
- 'heading4-style': 'test_value_11',
- 'hline-style': 'test_value_12',
- 'image-style': 'test_value_13',
- 'name': 'default_name_14',
- 'normal-text-style': 'test_value_15',
- 'numbered-list-style': 'test_value_16',
- 'page-footer-style': 'test_value_17',
- 'page-header-style': 'test_value_18',
- 'page-orient': 'portrait',
- 'page-style': 'test_value_20',
- 'report-subtitle-style': 'test_value_21',
- 'report-title-style': 'test_value_22',
- 'table-chart-caption-style': 'test_value_23',
- 'table-chart-even-row-style': 'test_value_24',
- 'table-chart-head-style': 'test_value_25',
- 'table-chart-odd-row-style': 'test_value_26',
- 'table-chart-style': 'test_value_27',
- 'toc-heading1-style': 'test_value_28',
- 'toc-heading2-style': 'test_value_29',
- 'toc-heading3-style': 'test_value_30',
- 'toc-heading4-style': 'test_value_31',
- 'toc-title-style': 'test_value_32'
- }
-
- set_method_mock.assert_called_with('report', 'theme', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_report_theme_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'report_theme': {
- 'bullet_list_style': 'test_value_3',
- 'column_count': '1',
- 'default_html_style': 'test_value_5',
- 'default_pdf_style': 'test_value_6',
- 'graph_chart_style': 'test_value_7',
- 'heading1_style': 'test_value_8',
- 'heading2_style': 'test_value_9',
- 'heading3_style': 'test_value_10',
- 'heading4_style': 'test_value_11',
- 'hline_style': 'test_value_12',
- 'image_style': 'test_value_13',
- 'name': 'default_name_14',
- 'normal_text_style': 'test_value_15',
- 'numbered_list_style': 'test_value_16',
- 'page_footer_style': 'test_value_17',
- 'page_header_style': 'test_value_18',
- 'page_orient': 'portrait',
- 'page_style': 'test_value_20',
- 'report_subtitle_style': 'test_value_21',
- 'report_title_style': 'test_value_22',
- 'table_chart_caption_style': 'test_value_23',
- 'table_chart_even_row_style': 'test_value_24',
- 'table_chart_head_style': 'test_value_25',
- 'table_chart_odd_row_style': 'test_value_26',
- 'table_chart_style': 'test_value_27',
- 'toc_heading1_style': 'test_value_28',
- 'toc_heading2_style': 'test_value_29',
- 'toc_heading3_style': 'test_value_30',
- 'toc_heading4_style': 'test_value_31',
- 'toc_title_style': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_theme.fortios_report(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('report', 'theme', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_report_theme_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'report_theme': {
- 'bullet_list_style': 'test_value_3',
- 'column_count': '1',
- 'default_html_style': 'test_value_5',
- 'default_pdf_style': 'test_value_6',
- 'graph_chart_style': 'test_value_7',
- 'heading1_style': 'test_value_8',
- 'heading2_style': 'test_value_9',
- 'heading3_style': 'test_value_10',
- 'heading4_style': 'test_value_11',
- 'hline_style': 'test_value_12',
- 'image_style': 'test_value_13',
- 'name': 'default_name_14',
- 'normal_text_style': 'test_value_15',
- 'numbered_list_style': 'test_value_16',
- 'page_footer_style': 'test_value_17',
- 'page_header_style': 'test_value_18',
- 'page_orient': 'portrait',
- 'page_style': 'test_value_20',
- 'report_subtitle_style': 'test_value_21',
- 'report_title_style': 'test_value_22',
- 'table_chart_caption_style': 'test_value_23',
- 'table_chart_even_row_style': 'test_value_24',
- 'table_chart_head_style': 'test_value_25',
- 'table_chart_odd_row_style': 'test_value_26',
- 'table_chart_style': 'test_value_27',
- 'toc_heading1_style': 'test_value_28',
- 'toc_heading2_style': 'test_value_29',
- 'toc_heading3_style': 'test_value_30',
- 'toc_heading4_style': 'test_value_31',
- 'toc_title_style': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_theme.fortios_report(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('report', 'theme', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_report_theme_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_theme': {
- 'bullet_list_style': 'test_value_3',
- 'column_count': '1',
- 'default_html_style': 'test_value_5',
- 'default_pdf_style': 'test_value_6',
- 'graph_chart_style': 'test_value_7',
- 'heading1_style': 'test_value_8',
- 'heading2_style': 'test_value_9',
- 'heading3_style': 'test_value_10',
- 'heading4_style': 'test_value_11',
- 'hline_style': 'test_value_12',
- 'image_style': 'test_value_13',
- 'name': 'default_name_14',
- 'normal_text_style': 'test_value_15',
- 'numbered_list_style': 'test_value_16',
- 'page_footer_style': 'test_value_17',
- 'page_header_style': 'test_value_18',
- 'page_orient': 'portrait',
- 'page_style': 'test_value_20',
- 'report_subtitle_style': 'test_value_21',
- 'report_title_style': 'test_value_22',
- 'table_chart_caption_style': 'test_value_23',
- 'table_chart_even_row_style': 'test_value_24',
- 'table_chart_head_style': 'test_value_25',
- 'table_chart_odd_row_style': 'test_value_26',
- 'table_chart_style': 'test_value_27',
- 'toc_heading1_style': 'test_value_28',
- 'toc_heading2_style': 'test_value_29',
- 'toc_heading3_style': 'test_value_30',
- 'toc_heading4_style': 'test_value_31',
- 'toc_title_style': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_theme.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'bullet-list-style': 'test_value_3',
- 'column-count': '1',
- 'default-html-style': 'test_value_5',
- 'default-pdf-style': 'test_value_6',
- 'graph-chart-style': 'test_value_7',
- 'heading1-style': 'test_value_8',
- 'heading2-style': 'test_value_9',
- 'heading3-style': 'test_value_10',
- 'heading4-style': 'test_value_11',
- 'hline-style': 'test_value_12',
- 'image-style': 'test_value_13',
- 'name': 'default_name_14',
- 'normal-text-style': 'test_value_15',
- 'numbered-list-style': 'test_value_16',
- 'page-footer-style': 'test_value_17',
- 'page-header-style': 'test_value_18',
- 'page-orient': 'portrait',
- 'page-style': 'test_value_20',
- 'report-subtitle-style': 'test_value_21',
- 'report-title-style': 'test_value_22',
- 'table-chart-caption-style': 'test_value_23',
- 'table-chart-even-row-style': 'test_value_24',
- 'table-chart-head-style': 'test_value_25',
- 'table-chart-odd-row-style': 'test_value_26',
- 'table-chart-style': 'test_value_27',
- 'toc-heading1-style': 'test_value_28',
- 'toc-heading2-style': 'test_value_29',
- 'toc-heading3-style': 'test_value_30',
- 'toc-heading4-style': 'test_value_31',
- 'toc-title-style': 'test_value_32'
- }
-
- set_method_mock.assert_called_with('report', 'theme', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_report_theme_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'report_theme': {
- 'random_attribute_not_valid': 'tag',
- 'bullet_list_style': 'test_value_3',
- 'column_count': '1',
- 'default_html_style': 'test_value_5',
- 'default_pdf_style': 'test_value_6',
- 'graph_chart_style': 'test_value_7',
- 'heading1_style': 'test_value_8',
- 'heading2_style': 'test_value_9',
- 'heading3_style': 'test_value_10',
- 'heading4_style': 'test_value_11',
- 'hline_style': 'test_value_12',
- 'image_style': 'test_value_13',
- 'name': 'default_name_14',
- 'normal_text_style': 'test_value_15',
- 'numbered_list_style': 'test_value_16',
- 'page_footer_style': 'test_value_17',
- 'page_header_style': 'test_value_18',
- 'page_orient': 'portrait',
- 'page_style': 'test_value_20',
- 'report_subtitle_style': 'test_value_21',
- 'report_title_style': 'test_value_22',
- 'table_chart_caption_style': 'test_value_23',
- 'table_chart_even_row_style': 'test_value_24',
- 'table_chart_head_style': 'test_value_25',
- 'table_chart_odd_row_style': 'test_value_26',
- 'table_chart_style': 'test_value_27',
- 'toc_heading1_style': 'test_value_28',
- 'toc_heading2_style': 'test_value_29',
- 'toc_heading3_style': 'test_value_30',
- 'toc_heading4_style': 'test_value_31',
- 'toc_title_style': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_report_theme.fortios_report(input_data, fos_instance)
-
- expected_data = {
- 'bullet-list-style': 'test_value_3',
- 'column-count': '1',
- 'default-html-style': 'test_value_5',
- 'default-pdf-style': 'test_value_6',
- 'graph-chart-style': 'test_value_7',
- 'heading1-style': 'test_value_8',
- 'heading2-style': 'test_value_9',
- 'heading3-style': 'test_value_10',
- 'heading4-style': 'test_value_11',
- 'hline-style': 'test_value_12',
- 'image-style': 'test_value_13',
- 'name': 'default_name_14',
- 'normal-text-style': 'test_value_15',
- 'numbered-list-style': 'test_value_16',
- 'page-footer-style': 'test_value_17',
- 'page-header-style': 'test_value_18',
- 'page-orient': 'portrait',
- 'page-style': 'test_value_20',
- 'report-subtitle-style': 'test_value_21',
- 'report-title-style': 'test_value_22',
- 'table-chart-caption-style': 'test_value_23',
- 'table-chart-even-row-style': 'test_value_24',
- 'table-chart-head-style': 'test_value_25',
- 'table-chart-odd-row-style': 'test_value_26',
- 'table-chart-style': 'test_value_27',
- 'toc-heading1-style': 'test_value_28',
- 'toc-heading2-style': 'test_value_29',
- 'toc-heading3-style': 'test_value_30',
- 'toc-heading4-style': 'test_value_31',
- 'toc-title-style': 'test_value_32'
- }
-
- set_method_mock.assert_called_with('report', 'theme', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_access_list.py b/test/units/modules/network/fortios/test_fortios_router_access_list.py
deleted file mode 100644
index f0cf338ba6..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_access_list.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_access_list
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_access_list.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_access_list_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_access_list': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'access-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_access_list_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_access_list': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'access-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_access_list_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_access_list': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'access-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_access_list_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_access_list': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'access-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_access_list_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_access_list': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'access-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_access_list_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_access_list': {
- 'random_attribute_not_valid': 'tag',
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'access-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_access_list6.py b/test/units/modules/network/fortios/test_fortios_router_access_list6.py
deleted file mode 100644
index 9b45dfd282..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_access_list6.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_access_list6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_access_list6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_access_list6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_access_list6': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'access-list6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_access_list6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_access_list6': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'access-list6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_access_list6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_access_list6': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list6.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'access-list6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_access_list6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_access_list6': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list6.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'access-list6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_access_list6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_access_list6': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'access-list6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_access_list6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_access_list6': {
- 'random_attribute_not_valid': 'tag',
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_access_list6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'access-list6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_aspath_list.py b/test/units/modules/network/fortios/test_fortios_router_aspath_list.py
deleted file mode 100644
index 3441ac2684..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_aspath_list.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_aspath_list
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_aspath_list.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_aspath_list_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_aspath_list': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_aspath_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('router', 'aspath-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_aspath_list_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_aspath_list': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_aspath_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('router', 'aspath-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_aspath_list_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_aspath_list': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_aspath_list.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'aspath-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_aspath_list_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_aspath_list': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_aspath_list.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'aspath-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_aspath_list_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_aspath_list': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_aspath_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('router', 'aspath-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_aspath_list_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_aspath_list': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_aspath_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('router', 'aspath-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_auth_path.py b/test/units/modules/network/fortios/test_fortios_router_auth_path.py
deleted file mode 100644
index 8762f7d60b..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_auth_path.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_auth_path
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_auth_path.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_auth_path_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_auth_path': {
- 'device': 'test_value_3',
- 'gateway': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_auth_path.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'gateway': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('router', 'auth-path', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_auth_path_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_auth_path': {
- 'device': 'test_value_3',
- 'gateway': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_auth_path.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'gateway': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('router', 'auth-path', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_auth_path_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_auth_path': {
- 'device': 'test_value_3',
- 'gateway': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_auth_path.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'auth-path', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_auth_path_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_auth_path': {
- 'device': 'test_value_3',
- 'gateway': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_auth_path.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'auth-path', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_auth_path_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_auth_path': {
- 'device': 'test_value_3',
- 'gateway': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_auth_path.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'gateway': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('router', 'auth-path', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_auth_path_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_auth_path': {
- 'random_attribute_not_valid': 'tag',
- 'device': 'test_value_3',
- 'gateway': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_auth_path.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'gateway': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('router', 'auth-path', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_bfd.py b/test/units/modules/network/fortios/test_fortios_router_bfd.py
deleted file mode 100644
index d462853d90..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_bfd.py
+++ /dev/null
@@ -1,143 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_bfd
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_bfd.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_bfd_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bfd': {
- 'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bfd.fortios_router(input_data, fos_instance)
-
- expected_data = {'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]}
-
- set_method_mock.assert_called_with('router', 'bfd', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_bfd_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bfd': {
- 'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bfd.fortios_router(input_data, fos_instance)
-
- expected_data = {'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]}
-
- set_method_mock.assert_called_with('router', 'bfd', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_bfd_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bfd': {
- 'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bfd.fortios_router(input_data, fos_instance)
-
- expected_data = {'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]}
-
- set_method_mock.assert_called_with('router', 'bfd', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_bfd_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bfd': {
- 'random_attribute_not_valid': 'tag',
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bfd.fortios_router(input_data, fos_instance)
-
- expected_data = {
- }
-
- set_method_mock.assert_called_with('router', 'bfd', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_bfd6.py b/test/units/modules/network/fortios/test_fortios_router_bfd6.py
deleted file mode 100644
index 94b6e3d7fb..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_bfd6.py
+++ /dev/null
@@ -1,143 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_bfd6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_bfd6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_bfd6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bfd6': {
- 'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bfd6.fortios_router(input_data, fos_instance)
-
- expected_data = {'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]}
-
- set_method_mock.assert_called_with('router', 'bfd6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_bfd6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bfd6': {
- 'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bfd6.fortios_router(input_data, fos_instance)
-
- expected_data = {'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]}
-
- set_method_mock.assert_called_with('router', 'bfd6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_bfd6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bfd6': {
- 'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bfd6.fortios_router(input_data, fos_instance)
-
- expected_data = {'neighbor': [{'interface': 'if1', 'ip': '10.20.10.10'}]}
-
- set_method_mock.assert_called_with('router', 'bfd6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_bfd6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bfd6': {
- 'random_attribute_not_valid': 'tag',
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bfd6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- }
-
- set_method_mock.assert_called_with('router', 'bfd6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_bgp.py b/test/units/modules/network/fortios/test_fortios_router_bgp.py
deleted file mode 100644
index 0d7617ee7a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_bgp.py
+++ /dev/null
@@ -1,447 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_bgp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_bgp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_bgp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bgp': {'always_compare_med': 'enable',
- 'as': '4',
- 'bestpath_as_path_ignore': 'enable',
- 'bestpath_cmp_confed_aspath': 'enable',
- 'bestpath_cmp_routerid': 'enable',
- 'bestpath_med_confed': 'enable',
- 'bestpath_med_missing_as_worst': 'enable',
- 'client_to_client_reflection': 'enable',
- 'cluster_id': 'test_value_11',
- 'confederation_identifier': '12',
- 'dampening': 'enable',
- 'dampening_max_suppress_time': '14',
- 'dampening_reachability_half_life': '15',
- 'dampening_reuse': '16',
- 'dampening_route_map': 'test_value_17',
- 'dampening_suppress': '18',
- 'dampening_unreachability_half_life': '19',
- 'default_local_preference': '20',
- 'deterministic_med': 'enable',
- 'distance_external': '22',
- 'distance_internal': '23',
- 'distance_local': '24',
- 'ebgp_multipath': 'enable',
- 'enforce_first_as': 'enable',
- 'fast_external_failover': 'enable',
- 'graceful_end_on_timer': 'enable',
- 'graceful_restart': 'enable',
- 'graceful_restart_time': '30',
- 'graceful_stalepath_time': '31',
- 'graceful_update_delay': '32',
- 'holdtime_timer': '33',
- 'ibgp_multipath': 'enable',
- 'ignore_optional_capability': 'enable',
- 'keepalive_timer': '36',
- 'log_neighbour_changes': 'enable',
- 'network_import_check': 'enable',
- 'router_id': 'test_value_39',
- 'scan_time': '40',
- 'synchronization': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bgp.fortios_router(input_data, fos_instance)
-
- expected_data = {'always-compare-med': 'enable',
- 'as': '4',
- 'bestpath-as-path-ignore': 'enable',
- 'bestpath-cmp-confed-aspath': 'enable',
- 'bestpath-cmp-routerid': 'enable',
- 'bestpath-med-confed': 'enable',
- 'bestpath-med-missing-as-worst': 'enable',
- 'client-to-client-reflection': 'enable',
- 'cluster-id': 'test_value_11',
- 'confederation-identifier': '12',
- 'dampening': 'enable',
- 'dampening-max-suppress-time': '14',
- 'dampening-reachability-half-life': '15',
- 'dampening-reuse': '16',
- 'dampening-route-map': 'test_value_17',
- 'dampening-suppress': '18',
- 'dampening-unreachability-half-life': '19',
- 'default-local-preference': '20',
- 'deterministic-med': 'enable',
- 'distance-external': '22',
- 'distance-internal': '23',
- 'distance-local': '24',
- 'ebgp-multipath': 'enable',
- 'enforce-first-as': 'enable',
- 'fast-external-failover': 'enable',
- 'graceful-end-on-timer': 'enable',
- 'graceful-restart': 'enable',
- 'graceful-restart-time': '30',
- 'graceful-stalepath-time': '31',
- 'graceful-update-delay': '32',
- 'holdtime-timer': '33',
- 'ibgp-multipath': 'enable',
- 'ignore-optional-capability': 'enable',
- 'keepalive-timer': '36',
- 'log-neighbour-changes': 'enable',
- 'network-import-check': 'enable',
- 'router-id': 'test_value_39',
- 'scan-time': '40',
- 'synchronization': 'enable'
- }
-
- set_method_mock.assert_called_with('router', 'bgp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_bgp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bgp': {'always_compare_med': 'enable',
- 'as': '4',
- 'bestpath_as_path_ignore': 'enable',
- 'bestpath_cmp_confed_aspath': 'enable',
- 'bestpath_cmp_routerid': 'enable',
- 'bestpath_med_confed': 'enable',
- 'bestpath_med_missing_as_worst': 'enable',
- 'client_to_client_reflection': 'enable',
- 'cluster_id': 'test_value_11',
- 'confederation_identifier': '12',
- 'dampening': 'enable',
- 'dampening_max_suppress_time': '14',
- 'dampening_reachability_half_life': '15',
- 'dampening_reuse': '16',
- 'dampening_route_map': 'test_value_17',
- 'dampening_suppress': '18',
- 'dampening_unreachability_half_life': '19',
- 'default_local_preference': '20',
- 'deterministic_med': 'enable',
- 'distance_external': '22',
- 'distance_internal': '23',
- 'distance_local': '24',
- 'ebgp_multipath': 'enable',
- 'enforce_first_as': 'enable',
- 'fast_external_failover': 'enable',
- 'graceful_end_on_timer': 'enable',
- 'graceful_restart': 'enable',
- 'graceful_restart_time': '30',
- 'graceful_stalepath_time': '31',
- 'graceful_update_delay': '32',
- 'holdtime_timer': '33',
- 'ibgp_multipath': 'enable',
- 'ignore_optional_capability': 'enable',
- 'keepalive_timer': '36',
- 'log_neighbour_changes': 'enable',
- 'network_import_check': 'enable',
- 'router_id': 'test_value_39',
- 'scan_time': '40',
- 'synchronization': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bgp.fortios_router(input_data, fos_instance)
-
- expected_data = {'always-compare-med': 'enable',
- 'as': '4',
- 'bestpath-as-path-ignore': 'enable',
- 'bestpath-cmp-confed-aspath': 'enable',
- 'bestpath-cmp-routerid': 'enable',
- 'bestpath-med-confed': 'enable',
- 'bestpath-med-missing-as-worst': 'enable',
- 'client-to-client-reflection': 'enable',
- 'cluster-id': 'test_value_11',
- 'confederation-identifier': '12',
- 'dampening': 'enable',
- 'dampening-max-suppress-time': '14',
- 'dampening-reachability-half-life': '15',
- 'dampening-reuse': '16',
- 'dampening-route-map': 'test_value_17',
- 'dampening-suppress': '18',
- 'dampening-unreachability-half-life': '19',
- 'default-local-preference': '20',
- 'deterministic-med': 'enable',
- 'distance-external': '22',
- 'distance-internal': '23',
- 'distance-local': '24',
- 'ebgp-multipath': 'enable',
- 'enforce-first-as': 'enable',
- 'fast-external-failover': 'enable',
- 'graceful-end-on-timer': 'enable',
- 'graceful-restart': 'enable',
- 'graceful-restart-time': '30',
- 'graceful-stalepath-time': '31',
- 'graceful-update-delay': '32',
- 'holdtime-timer': '33',
- 'ibgp-multipath': 'enable',
- 'ignore-optional-capability': 'enable',
- 'keepalive-timer': '36',
- 'log-neighbour-changes': 'enable',
- 'network-import-check': 'enable',
- 'router-id': 'test_value_39',
- 'scan-time': '40',
- 'synchronization': 'enable'
- }
-
- set_method_mock.assert_called_with('router', 'bgp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_bgp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bgp': {'always_compare_med': 'enable',
- 'as': '4',
- 'bestpath_as_path_ignore': 'enable',
- 'bestpath_cmp_confed_aspath': 'enable',
- 'bestpath_cmp_routerid': 'enable',
- 'bestpath_med_confed': 'enable',
- 'bestpath_med_missing_as_worst': 'enable',
- 'client_to_client_reflection': 'enable',
- 'cluster_id': 'test_value_11',
- 'confederation_identifier': '12',
- 'dampening': 'enable',
- 'dampening_max_suppress_time': '14',
- 'dampening_reachability_half_life': '15',
- 'dampening_reuse': '16',
- 'dampening_route_map': 'test_value_17',
- 'dampening_suppress': '18',
- 'dampening_unreachability_half_life': '19',
- 'default_local_preference': '20',
- 'deterministic_med': 'enable',
- 'distance_external': '22',
- 'distance_internal': '23',
- 'distance_local': '24',
- 'ebgp_multipath': 'enable',
- 'enforce_first_as': 'enable',
- 'fast_external_failover': 'enable',
- 'graceful_end_on_timer': 'enable',
- 'graceful_restart': 'enable',
- 'graceful_restart_time': '30',
- 'graceful_stalepath_time': '31',
- 'graceful_update_delay': '32',
- 'holdtime_timer': '33',
- 'ibgp_multipath': 'enable',
- 'ignore_optional_capability': 'enable',
- 'keepalive_timer': '36',
- 'log_neighbour_changes': 'enable',
- 'network_import_check': 'enable',
- 'router_id': 'test_value_39',
- 'scan_time': '40',
- 'synchronization': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bgp.fortios_router(input_data, fos_instance)
-
- expected_data = {'always-compare-med': 'enable',
- 'as': '4',
- 'bestpath-as-path-ignore': 'enable',
- 'bestpath-cmp-confed-aspath': 'enable',
- 'bestpath-cmp-routerid': 'enable',
- 'bestpath-med-confed': 'enable',
- 'bestpath-med-missing-as-worst': 'enable',
- 'client-to-client-reflection': 'enable',
- 'cluster-id': 'test_value_11',
- 'confederation-identifier': '12',
- 'dampening': 'enable',
- 'dampening-max-suppress-time': '14',
- 'dampening-reachability-half-life': '15',
- 'dampening-reuse': '16',
- 'dampening-route-map': 'test_value_17',
- 'dampening-suppress': '18',
- 'dampening-unreachability-half-life': '19',
- 'default-local-preference': '20',
- 'deterministic-med': 'enable',
- 'distance-external': '22',
- 'distance-internal': '23',
- 'distance-local': '24',
- 'ebgp-multipath': 'enable',
- 'enforce-first-as': 'enable',
- 'fast-external-failover': 'enable',
- 'graceful-end-on-timer': 'enable',
- 'graceful-restart': 'enable',
- 'graceful-restart-time': '30',
- 'graceful-stalepath-time': '31',
- 'graceful-update-delay': '32',
- 'holdtime-timer': '33',
- 'ibgp-multipath': 'enable',
- 'ignore-optional-capability': 'enable',
- 'keepalive-timer': '36',
- 'log-neighbour-changes': 'enable',
- 'network-import-check': 'enable',
- 'router-id': 'test_value_39',
- 'scan-time': '40',
- 'synchronization': 'enable'
- }
-
- set_method_mock.assert_called_with('router', 'bgp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_bgp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_bgp': {
- 'random_attribute_not_valid': 'tag', 'always_compare_med': 'enable',
- 'as': '4',
- 'bestpath_as_path_ignore': 'enable',
- 'bestpath_cmp_confed_aspath': 'enable',
- 'bestpath_cmp_routerid': 'enable',
- 'bestpath_med_confed': 'enable',
- 'bestpath_med_missing_as_worst': 'enable',
- 'client_to_client_reflection': 'enable',
- 'cluster_id': 'test_value_11',
- 'confederation_identifier': '12',
- 'dampening': 'enable',
- 'dampening_max_suppress_time': '14',
- 'dampening_reachability_half_life': '15',
- 'dampening_reuse': '16',
- 'dampening_route_map': 'test_value_17',
- 'dampening_suppress': '18',
- 'dampening_unreachability_half_life': '19',
- 'default_local_preference': '20',
- 'deterministic_med': 'enable',
- 'distance_external': '22',
- 'distance_internal': '23',
- 'distance_local': '24',
- 'ebgp_multipath': 'enable',
- 'enforce_first_as': 'enable',
- 'fast_external_failover': 'enable',
- 'graceful_end_on_timer': 'enable',
- 'graceful_restart': 'enable',
- 'graceful_restart_time': '30',
- 'graceful_stalepath_time': '31',
- 'graceful_update_delay': '32',
- 'holdtime_timer': '33',
- 'ibgp_multipath': 'enable',
- 'ignore_optional_capability': 'enable',
- 'keepalive_timer': '36',
- 'log_neighbour_changes': 'enable',
- 'network_import_check': 'enable',
- 'router_id': 'test_value_39',
- 'scan_time': '40',
- 'synchronization': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_bgp.fortios_router(input_data, fos_instance)
-
- expected_data = {'always-compare-med': 'enable',
- 'as': '4',
- 'bestpath-as-path-ignore': 'enable',
- 'bestpath-cmp-confed-aspath': 'enable',
- 'bestpath-cmp-routerid': 'enable',
- 'bestpath-med-confed': 'enable',
- 'bestpath-med-missing-as-worst': 'enable',
- 'client-to-client-reflection': 'enable',
- 'cluster-id': 'test_value_11',
- 'confederation-identifier': '12',
- 'dampening': 'enable',
- 'dampening-max-suppress-time': '14',
- 'dampening-reachability-half-life': '15',
- 'dampening-reuse': '16',
- 'dampening-route-map': 'test_value_17',
- 'dampening-suppress': '18',
- 'dampening-unreachability-half-life': '19',
- 'default-local-preference': '20',
- 'deterministic-med': 'enable',
- 'distance-external': '22',
- 'distance-internal': '23',
- 'distance-local': '24',
- 'ebgp-multipath': 'enable',
- 'enforce-first-as': 'enable',
- 'fast-external-failover': 'enable',
- 'graceful-end-on-timer': 'enable',
- 'graceful-restart': 'enable',
- 'graceful-restart-time': '30',
- 'graceful-stalepath-time': '31',
- 'graceful-update-delay': '32',
- 'holdtime-timer': '33',
- 'ibgp-multipath': 'enable',
- 'ignore-optional-capability': 'enable',
- 'keepalive-timer': '36',
- 'log-neighbour-changes': 'enable',
- 'network-import-check': 'enable',
- 'router-id': 'test_value_39',
- 'scan-time': '40',
- 'synchronization': 'enable'
- }
-
- set_method_mock.assert_called_with('router', 'bgp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_community_list.py b/test/units/modules/network/fortios/test_fortios_router_community_list.py
deleted file mode 100644
index 7891d005e7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_community_list.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_community_list
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_community_list.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_community_list_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_community_list': {
- 'name': 'default_name_3',
- 'type': 'standard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_community_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'type': 'standard'
- }
-
- set_method_mock.assert_called_with('router', 'community-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_community_list_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_community_list': {
- 'name': 'default_name_3',
- 'type': 'standard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_community_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'type': 'standard'
- }
-
- set_method_mock.assert_called_with('router', 'community-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_community_list_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_community_list': {
- 'name': 'default_name_3',
- 'type': 'standard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_community_list.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'community-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_community_list_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_community_list': {
- 'name': 'default_name_3',
- 'type': 'standard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_community_list.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'community-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_community_list_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_community_list': {
- 'name': 'default_name_3',
- 'type': 'standard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_community_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'type': 'standard'
- }
-
- set_method_mock.assert_called_with('router', 'community-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_community_list_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_community_list': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
- 'type': 'standard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_community_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'type': 'standard'
- }
-
- set_method_mock.assert_called_with('router', 'community-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_isis.py b/test/units/modules/network/fortios/test_fortios_router_isis.py
deleted file mode 100644
index 708ea1ab66..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_isis.py
+++ /dev/null
@@ -1,431 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_isis
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_isis.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_isis_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_isis': {
- 'adjacency_check': 'enable',
- 'adjacency_check6': 'enable',
- 'adv_passive_only': 'enable',
- 'adv_passive_only6': 'enable',
- 'auth_keychain_l1': 'test_value_7',
- 'auth_keychain_l2': 'test_value_8',
- 'auth_mode_l1': 'password',
- 'auth_mode_l2': 'password',
- 'auth_password_l1': 'test_value_11',
- 'auth_password_l2': 'test_value_12',
- 'auth_sendonly_l1': 'enable',
- 'auth_sendonly_l2': 'enable',
- 'default_originate': 'enable',
- 'default_originate6': 'enable',
- 'dynamic_hostname': 'enable',
- 'ignore_lsp_errors': 'enable',
- 'is_type': 'level-1-2',
- 'lsp_gen_interval_l1': '20',
- 'lsp_gen_interval_l2': '21',
- 'lsp_refresh_interval': '22',
- 'max_lsp_lifetime': '23',
- 'metric_style': 'narrow',
- 'overload_bit': 'enable',
- 'overload_bit_on_startup': '26',
- 'overload_bit_suppress': 'external',
- 'redistribute_l1': 'enable',
- 'redistribute_l1_list': 'test_value_29',
- 'redistribute_l2': 'enable',
- 'redistribute_l2_list': 'test_value_31',
- 'redistribute6_l1': 'enable',
- 'redistribute6_l1_list': 'test_value_33',
- 'redistribute6_l2': 'enable',
- 'redistribute6_l2_list': 'test_value_35',
- 'spf_interval_exp_l1': 'test_value_36',
- 'spf_interval_exp_l2': 'test_value_37',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_isis.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'adjacency-check': 'enable',
- 'adjacency-check6': 'enable',
- 'adv-passive-only': 'enable',
- 'adv-passive-only6': 'enable',
- 'auth-keychain-l1': 'test_value_7',
- 'auth-keychain-l2': 'test_value_8',
- 'auth-mode-l1': 'password',
- 'auth-mode-l2': 'password',
- 'auth-password-l1': 'test_value_11',
- 'auth-password-l2': 'test_value_12',
- 'auth-sendonly-l1': 'enable',
- 'auth-sendonly-l2': 'enable',
- 'default-originate': 'enable',
- 'default-originate6': 'enable',
- 'dynamic-hostname': 'enable',
- 'ignore-lsp-errors': 'enable',
- 'is-type': 'level-1-2',
- 'lsp-gen-interval-l1': '20',
- 'lsp-gen-interval-l2': '21',
- 'lsp-refresh-interval': '22',
- 'max-lsp-lifetime': '23',
- 'metric-style': 'narrow',
- 'overload-bit': 'enable',
- 'overload-bit-on-startup': '26',
- 'overload-bit-suppress': 'external',
- 'redistribute-l1': 'enable',
- 'redistribute-l1-list': 'test_value_29',
- 'redistribute-l2': 'enable',
- 'redistribute-l2-list': 'test_value_31',
- 'redistribute6-l1': 'enable',
- 'redistribute6-l1-list': 'test_value_33',
- 'redistribute6-l2': 'enable',
- 'redistribute6-l2-list': 'test_value_35',
- 'spf-interval-exp-l1': 'test_value_36',
- 'spf-interval-exp-l2': 'test_value_37',
-
- }
-
- set_method_mock.assert_called_with('router', 'isis', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_isis_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_isis': {
- 'adjacency_check': 'enable',
- 'adjacency_check6': 'enable',
- 'adv_passive_only': 'enable',
- 'adv_passive_only6': 'enable',
- 'auth_keychain_l1': 'test_value_7',
- 'auth_keychain_l2': 'test_value_8',
- 'auth_mode_l1': 'password',
- 'auth_mode_l2': 'password',
- 'auth_password_l1': 'test_value_11',
- 'auth_password_l2': 'test_value_12',
- 'auth_sendonly_l1': 'enable',
- 'auth_sendonly_l2': 'enable',
- 'default_originate': 'enable',
- 'default_originate6': 'enable',
- 'dynamic_hostname': 'enable',
- 'ignore_lsp_errors': 'enable',
- 'is_type': 'level-1-2',
- 'lsp_gen_interval_l1': '20',
- 'lsp_gen_interval_l2': '21',
- 'lsp_refresh_interval': '22',
- 'max_lsp_lifetime': '23',
- 'metric_style': 'narrow',
- 'overload_bit': 'enable',
- 'overload_bit_on_startup': '26',
- 'overload_bit_suppress': 'external',
- 'redistribute_l1': 'enable',
- 'redistribute_l1_list': 'test_value_29',
- 'redistribute_l2': 'enable',
- 'redistribute_l2_list': 'test_value_31',
- 'redistribute6_l1': 'enable',
- 'redistribute6_l1_list': 'test_value_33',
- 'redistribute6_l2': 'enable',
- 'redistribute6_l2_list': 'test_value_35',
- 'spf_interval_exp_l1': 'test_value_36',
- 'spf_interval_exp_l2': 'test_value_37',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_isis.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'adjacency-check': 'enable',
- 'adjacency-check6': 'enable',
- 'adv-passive-only': 'enable',
- 'adv-passive-only6': 'enable',
- 'auth-keychain-l1': 'test_value_7',
- 'auth-keychain-l2': 'test_value_8',
- 'auth-mode-l1': 'password',
- 'auth-mode-l2': 'password',
- 'auth-password-l1': 'test_value_11',
- 'auth-password-l2': 'test_value_12',
- 'auth-sendonly-l1': 'enable',
- 'auth-sendonly-l2': 'enable',
- 'default-originate': 'enable',
- 'default-originate6': 'enable',
- 'dynamic-hostname': 'enable',
- 'ignore-lsp-errors': 'enable',
- 'is-type': 'level-1-2',
- 'lsp-gen-interval-l1': '20',
- 'lsp-gen-interval-l2': '21',
- 'lsp-refresh-interval': '22',
- 'max-lsp-lifetime': '23',
- 'metric-style': 'narrow',
- 'overload-bit': 'enable',
- 'overload-bit-on-startup': '26',
- 'overload-bit-suppress': 'external',
- 'redistribute-l1': 'enable',
- 'redistribute-l1-list': 'test_value_29',
- 'redistribute-l2': 'enable',
- 'redistribute-l2-list': 'test_value_31',
- 'redistribute6-l1': 'enable',
- 'redistribute6-l1-list': 'test_value_33',
- 'redistribute6-l2': 'enable',
- 'redistribute6-l2-list': 'test_value_35',
- 'spf-interval-exp-l1': 'test_value_36',
- 'spf-interval-exp-l2': 'test_value_37',
-
- }
-
- set_method_mock.assert_called_with('router', 'isis', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_isis_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_isis': {
- 'adjacency_check': 'enable',
- 'adjacency_check6': 'enable',
- 'adv_passive_only': 'enable',
- 'adv_passive_only6': 'enable',
- 'auth_keychain_l1': 'test_value_7',
- 'auth_keychain_l2': 'test_value_8',
- 'auth_mode_l1': 'password',
- 'auth_mode_l2': 'password',
- 'auth_password_l1': 'test_value_11',
- 'auth_password_l2': 'test_value_12',
- 'auth_sendonly_l1': 'enable',
- 'auth_sendonly_l2': 'enable',
- 'default_originate': 'enable',
- 'default_originate6': 'enable',
- 'dynamic_hostname': 'enable',
- 'ignore_lsp_errors': 'enable',
- 'is_type': 'level-1-2',
- 'lsp_gen_interval_l1': '20',
- 'lsp_gen_interval_l2': '21',
- 'lsp_refresh_interval': '22',
- 'max_lsp_lifetime': '23',
- 'metric_style': 'narrow',
- 'overload_bit': 'enable',
- 'overload_bit_on_startup': '26',
- 'overload_bit_suppress': 'external',
- 'redistribute_l1': 'enable',
- 'redistribute_l1_list': 'test_value_29',
- 'redistribute_l2': 'enable',
- 'redistribute_l2_list': 'test_value_31',
- 'redistribute6_l1': 'enable',
- 'redistribute6_l1_list': 'test_value_33',
- 'redistribute6_l2': 'enable',
- 'redistribute6_l2_list': 'test_value_35',
- 'spf_interval_exp_l1': 'test_value_36',
- 'spf_interval_exp_l2': 'test_value_37',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_isis.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'adjacency-check': 'enable',
- 'adjacency-check6': 'enable',
- 'adv-passive-only': 'enable',
- 'adv-passive-only6': 'enable',
- 'auth-keychain-l1': 'test_value_7',
- 'auth-keychain-l2': 'test_value_8',
- 'auth-mode-l1': 'password',
- 'auth-mode-l2': 'password',
- 'auth-password-l1': 'test_value_11',
- 'auth-password-l2': 'test_value_12',
- 'auth-sendonly-l1': 'enable',
- 'auth-sendonly-l2': 'enable',
- 'default-originate': 'enable',
- 'default-originate6': 'enable',
- 'dynamic-hostname': 'enable',
- 'ignore-lsp-errors': 'enable',
- 'is-type': 'level-1-2',
- 'lsp-gen-interval-l1': '20',
- 'lsp-gen-interval-l2': '21',
- 'lsp-refresh-interval': '22',
- 'max-lsp-lifetime': '23',
- 'metric-style': 'narrow',
- 'overload-bit': 'enable',
- 'overload-bit-on-startup': '26',
- 'overload-bit-suppress': 'external',
- 'redistribute-l1': 'enable',
- 'redistribute-l1-list': 'test_value_29',
- 'redistribute-l2': 'enable',
- 'redistribute-l2-list': 'test_value_31',
- 'redistribute6-l1': 'enable',
- 'redistribute6-l1-list': 'test_value_33',
- 'redistribute6-l2': 'enable',
- 'redistribute6-l2-list': 'test_value_35',
- 'spf-interval-exp-l1': 'test_value_36',
- 'spf-interval-exp-l2': 'test_value_37',
-
- }
-
- set_method_mock.assert_called_with('router', 'isis', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_isis_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_isis': {
- 'random_attribute_not_valid': 'tag',
- 'adjacency_check': 'enable',
- 'adjacency_check6': 'enable',
- 'adv_passive_only': 'enable',
- 'adv_passive_only6': 'enable',
- 'auth_keychain_l1': 'test_value_7',
- 'auth_keychain_l2': 'test_value_8',
- 'auth_mode_l1': 'password',
- 'auth_mode_l2': 'password',
- 'auth_password_l1': 'test_value_11',
- 'auth_password_l2': 'test_value_12',
- 'auth_sendonly_l1': 'enable',
- 'auth_sendonly_l2': 'enable',
- 'default_originate': 'enable',
- 'default_originate6': 'enable',
- 'dynamic_hostname': 'enable',
- 'ignore_lsp_errors': 'enable',
- 'is_type': 'level-1-2',
- 'lsp_gen_interval_l1': '20',
- 'lsp_gen_interval_l2': '21',
- 'lsp_refresh_interval': '22',
- 'max_lsp_lifetime': '23',
- 'metric_style': 'narrow',
- 'overload_bit': 'enable',
- 'overload_bit_on_startup': '26',
- 'overload_bit_suppress': 'external',
- 'redistribute_l1': 'enable',
- 'redistribute_l1_list': 'test_value_29',
- 'redistribute_l2': 'enable',
- 'redistribute_l2_list': 'test_value_31',
- 'redistribute6_l1': 'enable',
- 'redistribute6_l1_list': 'test_value_33',
- 'redistribute6_l2': 'enable',
- 'redistribute6_l2_list': 'test_value_35',
- 'spf_interval_exp_l1': 'test_value_36',
- 'spf_interval_exp_l2': 'test_value_37',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_isis.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'adjacency-check': 'enable',
- 'adjacency-check6': 'enable',
- 'adv-passive-only': 'enable',
- 'adv-passive-only6': 'enable',
- 'auth-keychain-l1': 'test_value_7',
- 'auth-keychain-l2': 'test_value_8',
- 'auth-mode-l1': 'password',
- 'auth-mode-l2': 'password',
- 'auth-password-l1': 'test_value_11',
- 'auth-password-l2': 'test_value_12',
- 'auth-sendonly-l1': 'enable',
- 'auth-sendonly-l2': 'enable',
- 'default-originate': 'enable',
- 'default-originate6': 'enable',
- 'dynamic-hostname': 'enable',
- 'ignore-lsp-errors': 'enable',
- 'is-type': 'level-1-2',
- 'lsp-gen-interval-l1': '20',
- 'lsp-gen-interval-l2': '21',
- 'lsp-refresh-interval': '22',
- 'max-lsp-lifetime': '23',
- 'metric-style': 'narrow',
- 'overload-bit': 'enable',
- 'overload-bit-on-startup': '26',
- 'overload-bit-suppress': 'external',
- 'redistribute-l1': 'enable',
- 'redistribute-l1-list': 'test_value_29',
- 'redistribute-l2': 'enable',
- 'redistribute-l2-list': 'test_value_31',
- 'redistribute6-l1': 'enable',
- 'redistribute6-l1-list': 'test_value_33',
- 'redistribute6-l2': 'enable',
- 'redistribute6-l2-list': 'test_value_35',
- 'spf-interval-exp-l1': 'test_value_36',
- 'spf-interval-exp-l2': 'test_value_37',
-
- }
-
- set_method_mock.assert_called_with('router', 'isis', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_key_chain.py b/test/units/modules/network/fortios/test_fortios_router_key_chain.py
deleted file mode 100644
index 09277d2b34..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_key_chain.py
+++ /dev/null
@@ -1,189 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_key_chain
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_key_chain.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_key_chain_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_key_chain': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_key_chain.fortios_router(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('router', 'key-chain', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_key_chain_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_key_chain': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_key_chain.fortios_router(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('router', 'key-chain', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_key_chain_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_key_chain': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_key_chain.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'key-chain', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_key_chain_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_key_chain': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_key_chain.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'key-chain', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_key_chain_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_key_chain': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_key_chain.fortios_router(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('router', 'key-chain', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_key_chain_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_key_chain': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_key_chain.fortios_router(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('router', 'key-chain', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_multicast.py b/test/units/modules/network/fortios/test_fortios_router_multicast.py
deleted file mode 100644
index 34e3dc562d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_multicast.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_multicast
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_multicast.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_multicast_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast': {'multicast_routing': 'enable',
- 'route_limit': '4',
- 'route_threshold': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast.fortios_router(input_data, fos_instance)
-
- expected_data = {'multicast-routing': 'enable',
- 'route-limit': '4',
- 'route-threshold': '5'
- }
-
- set_method_mock.assert_called_with('router', 'multicast', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_multicast_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast': {'multicast_routing': 'enable',
- 'route_limit': '4',
- 'route_threshold': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast.fortios_router(input_data, fos_instance)
-
- expected_data = {'multicast-routing': 'enable',
- 'route-limit': '4',
- 'route-threshold': '5'
- }
-
- set_method_mock.assert_called_with('router', 'multicast', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_multicast_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast': {'multicast_routing': 'enable',
- 'route_limit': '4',
- 'route_threshold': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast.fortios_router(input_data, fos_instance)
-
- expected_data = {'multicast-routing': 'enable',
- 'route-limit': '4',
- 'route-threshold': '5'
- }
-
- set_method_mock.assert_called_with('router', 'multicast', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_multicast_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast': {
- 'random_attribute_not_valid': 'tag', 'multicast_routing': 'enable',
- 'route_limit': '4',
- 'route_threshold': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast.fortios_router(input_data, fos_instance)
-
- expected_data = {'multicast-routing': 'enable',
- 'route-limit': '4',
- 'route-threshold': '5'
- }
-
- set_method_mock.assert_called_with('router', 'multicast', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_multicast6.py b/test/units/modules/network/fortios/test_fortios_router_multicast6.py
deleted file mode 100644
index 5fb6e25a87..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_multicast6.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_multicast6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_multicast6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_multicast6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast6': {'multicast_pmtu': 'enable',
- 'multicast_routing': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast6.fortios_router(input_data, fos_instance)
-
- expected_data = {'multicast-pmtu': 'enable',
- 'multicast-routing': 'enable',
-
- }
-
- set_method_mock.assert_called_with('router', 'multicast6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_multicast6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast6': {'multicast_pmtu': 'enable',
- 'multicast_routing': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast6.fortios_router(input_data, fos_instance)
-
- expected_data = {'multicast-pmtu': 'enable',
- 'multicast-routing': 'enable',
-
- }
-
- set_method_mock.assert_called_with('router', 'multicast6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_multicast6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast6': {'multicast_pmtu': 'enable',
- 'multicast_routing': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast6.fortios_router(input_data, fos_instance)
-
- expected_data = {'multicast-pmtu': 'enable',
- 'multicast-routing': 'enable',
-
- }
-
- set_method_mock.assert_called_with('router', 'multicast6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_multicast6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast6': {
- 'random_attribute_not_valid': 'tag', 'multicast_pmtu': 'enable',
- 'multicast_routing': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast6.fortios_router(input_data, fos_instance)
-
- expected_data = {'multicast-pmtu': 'enable',
- 'multicast-routing': 'enable',
-
- }
-
- set_method_mock.assert_called_with('router', 'multicast6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_multicast_flow.py b/test/units/modules/network/fortios/test_fortios_router_multicast_flow.py
deleted file mode 100644
index 92eada85f3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_multicast_flow.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_multicast_flow
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_multicast_flow.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_multicast_flow_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast_flow': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast_flow.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('router', 'multicast-flow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_multicast_flow_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast_flow': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast_flow.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('router', 'multicast-flow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_multicast_flow_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_multicast_flow': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast_flow.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'multicast-flow', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_multicast_flow_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_multicast_flow': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast_flow.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'multicast-flow', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_multicast_flow_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast_flow': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast_flow.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('router', 'multicast-flow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_multicast_flow_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_multicast_flow': {
- 'random_attribute_not_valid': 'tag',
- 'comments': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_multicast_flow.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('router', 'multicast-flow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_ospf.py b/test/units/modules/network/fortios/test_fortios_router_ospf.py
deleted file mode 100644
index f7b8565d09..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_ospf.py
+++ /dev/null
@@ -1,335 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_ospf
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_ospf.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_ospf_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ospf': {
- 'abr_type': 'cisco',
- 'auto_cost_ref_bandwidth': '4',
- 'bfd': 'enable',
- 'database_overflow': 'enable',
- 'database_overflow_max_lsas': '7',
- 'database_overflow_time_to_recover': '8',
- 'default_information_metric': '9',
- 'default_information_metric_type': '1',
- 'default_information_originate': 'enable',
- 'default_information_route_map': 'test_value_12',
- 'default_metric': '13',
- 'distance': '14',
- 'distance_external': '15',
- 'distance_inter_area': '16',
- 'distance_intra_area': '17',
- 'distribute_list_in': 'test_value_18',
- 'distribute_route_map_in': 'test_value_19',
- 'log_neighbour_changes': 'enable',
- 'restart_mode': 'none',
- 'restart_period': '22',
- 'rfc1583_compatible': 'enable',
- 'router_id': 'test_value_24',
- 'spf_timers': 'test_value_25',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ospf.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'abr-type': 'cisco',
- 'auto-cost-ref-bandwidth': '4',
- 'bfd': 'enable',
- 'database-overflow': 'enable',
- 'database-overflow-max-lsas': '7',
- 'database-overflow-time-to-recover': '8',
- 'default-information-metric': '9',
- 'default-information-metric-type': '1',
- 'default-information-originate': 'enable',
- 'default-information-route-map': 'test_value_12',
- 'default-metric': '13',
- 'distance': '14',
- 'distance-external': '15',
- 'distance-inter-area': '16',
- 'distance-intra-area': '17',
- 'distribute-list-in': 'test_value_18',
- 'distribute-route-map-in': 'test_value_19',
- 'log-neighbour-changes': 'enable',
- 'restart-mode': 'none',
- 'restart-period': '22',
- 'rfc1583-compatible': 'enable',
- 'router-id': 'test_value_24',
- 'spf-timers': 'test_value_25',
-
- }
-
- set_method_mock.assert_called_with('router', 'ospf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_ospf_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ospf': {
- 'abr_type': 'cisco',
- 'auto_cost_ref_bandwidth': '4',
- 'bfd': 'enable',
- 'database_overflow': 'enable',
- 'database_overflow_max_lsas': '7',
- 'database_overflow_time_to_recover': '8',
- 'default_information_metric': '9',
- 'default_information_metric_type': '1',
- 'default_information_originate': 'enable',
- 'default_information_route_map': 'test_value_12',
- 'default_metric': '13',
- 'distance': '14',
- 'distance_external': '15',
- 'distance_inter_area': '16',
- 'distance_intra_area': '17',
- 'distribute_list_in': 'test_value_18',
- 'distribute_route_map_in': 'test_value_19',
- 'log_neighbour_changes': 'enable',
- 'restart_mode': 'none',
- 'restart_period': '22',
- 'rfc1583_compatible': 'enable',
- 'router_id': 'test_value_24',
- 'spf_timers': 'test_value_25',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ospf.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'abr-type': 'cisco',
- 'auto-cost-ref-bandwidth': '4',
- 'bfd': 'enable',
- 'database-overflow': 'enable',
- 'database-overflow-max-lsas': '7',
- 'database-overflow-time-to-recover': '8',
- 'default-information-metric': '9',
- 'default-information-metric-type': '1',
- 'default-information-originate': 'enable',
- 'default-information-route-map': 'test_value_12',
- 'default-metric': '13',
- 'distance': '14',
- 'distance-external': '15',
- 'distance-inter-area': '16',
- 'distance-intra-area': '17',
- 'distribute-list-in': 'test_value_18',
- 'distribute-route-map-in': 'test_value_19',
- 'log-neighbour-changes': 'enable',
- 'restart-mode': 'none',
- 'restart-period': '22',
- 'rfc1583-compatible': 'enable',
- 'router-id': 'test_value_24',
- 'spf-timers': 'test_value_25',
-
- }
-
- set_method_mock.assert_called_with('router', 'ospf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_ospf_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ospf': {
- 'abr_type': 'cisco',
- 'auto_cost_ref_bandwidth': '4',
- 'bfd': 'enable',
- 'database_overflow': 'enable',
- 'database_overflow_max_lsas': '7',
- 'database_overflow_time_to_recover': '8',
- 'default_information_metric': '9',
- 'default_information_metric_type': '1',
- 'default_information_originate': 'enable',
- 'default_information_route_map': 'test_value_12',
- 'default_metric': '13',
- 'distance': '14',
- 'distance_external': '15',
- 'distance_inter_area': '16',
- 'distance_intra_area': '17',
- 'distribute_list_in': 'test_value_18',
- 'distribute_route_map_in': 'test_value_19',
- 'log_neighbour_changes': 'enable',
- 'restart_mode': 'none',
- 'restart_period': '22',
- 'rfc1583_compatible': 'enable',
- 'router_id': 'test_value_24',
- 'spf_timers': 'test_value_25',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ospf.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'abr-type': 'cisco',
- 'auto-cost-ref-bandwidth': '4',
- 'bfd': 'enable',
- 'database-overflow': 'enable',
- 'database-overflow-max-lsas': '7',
- 'database-overflow-time-to-recover': '8',
- 'default-information-metric': '9',
- 'default-information-metric-type': '1',
- 'default-information-originate': 'enable',
- 'default-information-route-map': 'test_value_12',
- 'default-metric': '13',
- 'distance': '14',
- 'distance-external': '15',
- 'distance-inter-area': '16',
- 'distance-intra-area': '17',
- 'distribute-list-in': 'test_value_18',
- 'distribute-route-map-in': 'test_value_19',
- 'log-neighbour-changes': 'enable',
- 'restart-mode': 'none',
- 'restart-period': '22',
- 'rfc1583-compatible': 'enable',
- 'router-id': 'test_value_24',
- 'spf-timers': 'test_value_25',
-
- }
-
- set_method_mock.assert_called_with('router', 'ospf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_ospf_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ospf': {
- 'random_attribute_not_valid': 'tag',
- 'abr_type': 'cisco',
- 'auto_cost_ref_bandwidth': '4',
- 'bfd': 'enable',
- 'database_overflow': 'enable',
- 'database_overflow_max_lsas': '7',
- 'database_overflow_time_to_recover': '8',
- 'default_information_metric': '9',
- 'default_information_metric_type': '1',
- 'default_information_originate': 'enable',
- 'default_information_route_map': 'test_value_12',
- 'default_metric': '13',
- 'distance': '14',
- 'distance_external': '15',
- 'distance_inter_area': '16',
- 'distance_intra_area': '17',
- 'distribute_list_in': 'test_value_18',
- 'distribute_route_map_in': 'test_value_19',
- 'log_neighbour_changes': 'enable',
- 'restart_mode': 'none',
- 'restart_period': '22',
- 'rfc1583_compatible': 'enable',
- 'router_id': 'test_value_24',
- 'spf_timers': 'test_value_25',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ospf.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'abr-type': 'cisco',
- 'auto-cost-ref-bandwidth': '4',
- 'bfd': 'enable',
- 'database-overflow': 'enable',
- 'database-overflow-max-lsas': '7',
- 'database-overflow-time-to-recover': '8',
- 'default-information-metric': '9',
- 'default-information-metric-type': '1',
- 'default-information-originate': 'enable',
- 'default-information-route-map': 'test_value_12',
- 'default-metric': '13',
- 'distance': '14',
- 'distance-external': '15',
- 'distance-inter-area': '16',
- 'distance-intra-area': '17',
- 'distribute-list-in': 'test_value_18',
- 'distribute-route-map-in': 'test_value_19',
- 'log-neighbour-changes': 'enable',
- 'restart-mode': 'none',
- 'restart-period': '22',
- 'rfc1583-compatible': 'enable',
- 'router-id': 'test_value_24',
- 'spf-timers': 'test_value_25',
-
- }
-
- set_method_mock.assert_called_with('router', 'ospf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_ospf6.py b/test/units/modules/network/fortios/test_fortios_router_ospf6.py
deleted file mode 100644
index 7315167741..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_ospf6.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_ospf6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_ospf6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_ospf6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ospf6': {
- 'abr_type': 'cisco',
- 'auto_cost_ref_bandwidth': '4',
- 'bfd': 'enable',
- 'default_information_metric': '6',
- 'default_information_metric_type': '1',
- 'default_information_originate': 'enable',
- 'default_information_route_map': 'test_value_9',
- 'default_metric': '10',
- 'log_neighbour_changes': 'enable',
- 'router_id': 'test_value_12',
- 'spf_timers': 'test_value_13',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ospf6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'abr-type': 'cisco',
- 'auto-cost-ref-bandwidth': '4',
- 'bfd': 'enable',
- 'default-information-metric': '6',
- 'default-information-metric-type': '1',
- 'default-information-originate': 'enable',
- 'default-information-route-map': 'test_value_9',
- 'default-metric': '10',
- 'log-neighbour-changes': 'enable',
- 'router-id': 'test_value_12',
- 'spf-timers': 'test_value_13',
-
- }
-
- set_method_mock.assert_called_with('router', 'ospf6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_ospf6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ospf6': {
- 'abr_type': 'cisco',
- 'auto_cost_ref_bandwidth': '4',
- 'bfd': 'enable',
- 'default_information_metric': '6',
- 'default_information_metric_type': '1',
- 'default_information_originate': 'enable',
- 'default_information_route_map': 'test_value_9',
- 'default_metric': '10',
- 'log_neighbour_changes': 'enable',
- 'router_id': 'test_value_12',
- 'spf_timers': 'test_value_13',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ospf6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'abr-type': 'cisco',
- 'auto-cost-ref-bandwidth': '4',
- 'bfd': 'enable',
- 'default-information-metric': '6',
- 'default-information-metric-type': '1',
- 'default-information-originate': 'enable',
- 'default-information-route-map': 'test_value_9',
- 'default-metric': '10',
- 'log-neighbour-changes': 'enable',
- 'router-id': 'test_value_12',
- 'spf-timers': 'test_value_13',
-
- }
-
- set_method_mock.assert_called_with('router', 'ospf6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_ospf6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ospf6': {
- 'abr_type': 'cisco',
- 'auto_cost_ref_bandwidth': '4',
- 'bfd': 'enable',
- 'default_information_metric': '6',
- 'default_information_metric_type': '1',
- 'default_information_originate': 'enable',
- 'default_information_route_map': 'test_value_9',
- 'default_metric': '10',
- 'log_neighbour_changes': 'enable',
- 'router_id': 'test_value_12',
- 'spf_timers': 'test_value_13',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ospf6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'abr-type': 'cisco',
- 'auto-cost-ref-bandwidth': '4',
- 'bfd': 'enable',
- 'default-information-metric': '6',
- 'default-information-metric-type': '1',
- 'default-information-originate': 'enable',
- 'default-information-route-map': 'test_value_9',
- 'default-metric': '10',
- 'log-neighbour-changes': 'enable',
- 'router-id': 'test_value_12',
- 'spf-timers': 'test_value_13',
-
- }
-
- set_method_mock.assert_called_with('router', 'ospf6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_ospf6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ospf6': {
- 'random_attribute_not_valid': 'tag',
- 'abr_type': 'cisco',
- 'auto_cost_ref_bandwidth': '4',
- 'bfd': 'enable',
- 'default_information_metric': '6',
- 'default_information_metric_type': '1',
- 'default_information_originate': 'enable',
- 'default_information_route_map': 'test_value_9',
- 'default_metric': '10',
- 'log_neighbour_changes': 'enable',
- 'router_id': 'test_value_12',
- 'spf_timers': 'test_value_13',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ospf6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'abr-type': 'cisco',
- 'auto-cost-ref-bandwidth': '4',
- 'bfd': 'enable',
- 'default-information-metric': '6',
- 'default-information-metric-type': '1',
- 'default-information-originate': 'enable',
- 'default-information-route-map': 'test_value_9',
- 'default-metric': '10',
- 'log-neighbour-changes': 'enable',
- 'router-id': 'test_value_12',
- 'spf-timers': 'test_value_13',
-
- }
-
- set_method_mock.assert_called_with('router', 'ospf6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_policy.py b/test/units/modules/network/fortios/test_fortios_router_policy.py
deleted file mode 100644
index 98d2536130..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_policy.py
+++ /dev/null
@@ -1,339 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_policy': {
- 'action': 'deny',
- 'comments': 'test_value_4',
- 'dst_negate': 'enable',
- 'end_port': '6',
- 'end_source_port': '7',
- 'gateway': 'test_value_8',
- 'output_device': 'test_value_9',
- 'protocol': '10',
- 'seq_num': '11',
- 'src_negate': 'enable',
- 'start_port': '13',
- 'start_source_port': '14',
- 'status': 'enable',
- 'tos': 'test_value_16',
- 'tos_mask': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'action': 'deny',
- 'comments': 'test_value_4',
- 'dst-negate': 'enable',
- 'end-port': '6',
- 'end-source-port': '7',
- 'gateway': 'test_value_8',
- 'output-device': 'test_value_9',
- 'protocol': '10',
- 'seq-num': '11',
- 'src-negate': 'enable',
- 'start-port': '13',
- 'start-source-port': '14',
- 'status': 'enable',
- 'tos': 'test_value_16',
- 'tos-mask': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('router', 'policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_policy': {
- 'action': 'deny',
- 'comments': 'test_value_4',
- 'dst_negate': 'enable',
- 'end_port': '6',
- 'end_source_port': '7',
- 'gateway': 'test_value_8',
- 'output_device': 'test_value_9',
- 'protocol': '10',
- 'seq_num': '11',
- 'src_negate': 'enable',
- 'start_port': '13',
- 'start_source_port': '14',
- 'status': 'enable',
- 'tos': 'test_value_16',
- 'tos_mask': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'action': 'deny',
- 'comments': 'test_value_4',
- 'dst-negate': 'enable',
- 'end-port': '6',
- 'end-source-port': '7',
- 'gateway': 'test_value_8',
- 'output-device': 'test_value_9',
- 'protocol': '10',
- 'seq-num': '11',
- 'src-negate': 'enable',
- 'start-port': '13',
- 'start-source-port': '14',
- 'status': 'enable',
- 'tos': 'test_value_16',
- 'tos-mask': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('router', 'policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_policy': {
- 'action': 'deny',
- 'comments': 'test_value_4',
- 'dst_negate': 'enable',
- 'end_port': '6',
- 'end_source_port': '7',
- 'gateway': 'test_value_8',
- 'output_device': 'test_value_9',
- 'protocol': '10',
- 'seq_num': '11',
- 'src_negate': 'enable',
- 'start_port': '13',
- 'start_source_port': '14',
- 'status': 'enable',
- 'tos': 'test_value_16',
- 'tos_mask': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_policy': {
- 'action': 'deny',
- 'comments': 'test_value_4',
- 'dst_negate': 'enable',
- 'end_port': '6',
- 'end_source_port': '7',
- 'gateway': 'test_value_8',
- 'output_device': 'test_value_9',
- 'protocol': '10',
- 'seq_num': '11',
- 'src_negate': 'enable',
- 'start_port': '13',
- 'start_source_port': '14',
- 'status': 'enable',
- 'tos': 'test_value_16',
- 'tos_mask': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_policy': {
- 'action': 'deny',
- 'comments': 'test_value_4',
- 'dst_negate': 'enable',
- 'end_port': '6',
- 'end_source_port': '7',
- 'gateway': 'test_value_8',
- 'output_device': 'test_value_9',
- 'protocol': '10',
- 'seq_num': '11',
- 'src_negate': 'enable',
- 'start_port': '13',
- 'start_source_port': '14',
- 'status': 'enable',
- 'tos': 'test_value_16',
- 'tos_mask': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'action': 'deny',
- 'comments': 'test_value_4',
- 'dst-negate': 'enable',
- 'end-port': '6',
- 'end-source-port': '7',
- 'gateway': 'test_value_8',
- 'output-device': 'test_value_9',
- 'protocol': '10',
- 'seq-num': '11',
- 'src-negate': 'enable',
- 'start-port': '13',
- 'start-source-port': '14',
- 'status': 'enable',
- 'tos': 'test_value_16',
- 'tos-mask': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('router', 'policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_policy': {
- 'random_attribute_not_valid': 'tag',
- 'action': 'deny',
- 'comments': 'test_value_4',
- 'dst_negate': 'enable',
- 'end_port': '6',
- 'end_source_port': '7',
- 'gateway': 'test_value_8',
- 'output_device': 'test_value_9',
- 'protocol': '10',
- 'seq_num': '11',
- 'src_negate': 'enable',
- 'start_port': '13',
- 'start_source_port': '14',
- 'status': 'enable',
- 'tos': 'test_value_16',
- 'tos_mask': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'action': 'deny',
- 'comments': 'test_value_4',
- 'dst-negate': 'enable',
- 'end-port': '6',
- 'end-source-port': '7',
- 'gateway': 'test_value_8',
- 'output-device': 'test_value_9',
- 'protocol': '10',
- 'seq-num': '11',
- 'src-negate': 'enable',
- 'start-port': '13',
- 'start-source-port': '14',
- 'status': 'enable',
- 'tos': 'test_value_16',
- 'tos-mask': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('router', 'policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_policy6.py b/test/units/modules/network/fortios/test_fortios_router_policy6.py
deleted file mode 100644
index 44347e833c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_policy6.py
+++ /dev/null
@@ -1,319 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_policy6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_policy6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_policy6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_policy6': {
- 'comments': 'test_value_3',
- 'dst': 'test_value_4',
- 'end_port': '5',
- 'gateway': 'test_value_6',
- 'input_device': 'test_value_7',
- 'output_device': 'test_value_8',
- 'protocol': '9',
- 'seq_num': '10',
- 'src': 'test_value_11',
- 'start_port': '12',
- 'status': 'enable',
- 'tos': 'test_value_14',
- 'tos_mask': 'test_value_15'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'dst': 'test_value_4',
- 'end-port': '5',
- 'gateway': 'test_value_6',
- 'input-device': 'test_value_7',
- 'output-device': 'test_value_8',
- 'protocol': '9',
- 'seq-num': '10',
- 'src': 'test_value_11',
- 'start-port': '12',
- 'status': 'enable',
- 'tos': 'test_value_14',
- 'tos-mask': 'test_value_15'
- }
-
- set_method_mock.assert_called_with('router', 'policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_policy6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_policy6': {
- 'comments': 'test_value_3',
- 'dst': 'test_value_4',
- 'end_port': '5',
- 'gateway': 'test_value_6',
- 'input_device': 'test_value_7',
- 'output_device': 'test_value_8',
- 'protocol': '9',
- 'seq_num': '10',
- 'src': 'test_value_11',
- 'start_port': '12',
- 'status': 'enable',
- 'tos': 'test_value_14',
- 'tos_mask': 'test_value_15'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'dst': 'test_value_4',
- 'end-port': '5',
- 'gateway': 'test_value_6',
- 'input-device': 'test_value_7',
- 'output-device': 'test_value_8',
- 'protocol': '9',
- 'seq-num': '10',
- 'src': 'test_value_11',
- 'start-port': '12',
- 'status': 'enable',
- 'tos': 'test_value_14',
- 'tos-mask': 'test_value_15'
- }
-
- set_method_mock.assert_called_with('router', 'policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_policy6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_policy6': {
- 'comments': 'test_value_3',
- 'dst': 'test_value_4',
- 'end_port': '5',
- 'gateway': 'test_value_6',
- 'input_device': 'test_value_7',
- 'output_device': 'test_value_8',
- 'protocol': '9',
- 'seq_num': '10',
- 'src': 'test_value_11',
- 'start_port': '12',
- 'status': 'enable',
- 'tos': 'test_value_14',
- 'tos_mask': 'test_value_15'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy6.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_policy6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_policy6': {
- 'comments': 'test_value_3',
- 'dst': 'test_value_4',
- 'end_port': '5',
- 'gateway': 'test_value_6',
- 'input_device': 'test_value_7',
- 'output_device': 'test_value_8',
- 'protocol': '9',
- 'seq_num': '10',
- 'src': 'test_value_11',
- 'start_port': '12',
- 'status': 'enable',
- 'tos': 'test_value_14',
- 'tos_mask': 'test_value_15'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy6.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'policy6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_policy6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_policy6': {
- 'comments': 'test_value_3',
- 'dst': 'test_value_4',
- 'end_port': '5',
- 'gateway': 'test_value_6',
- 'input_device': 'test_value_7',
- 'output_device': 'test_value_8',
- 'protocol': '9',
- 'seq_num': '10',
- 'src': 'test_value_11',
- 'start_port': '12',
- 'status': 'enable',
- 'tos': 'test_value_14',
- 'tos_mask': 'test_value_15'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'dst': 'test_value_4',
- 'end-port': '5',
- 'gateway': 'test_value_6',
- 'input-device': 'test_value_7',
- 'output-device': 'test_value_8',
- 'protocol': '9',
- 'seq-num': '10',
- 'src': 'test_value_11',
- 'start-port': '12',
- 'status': 'enable',
- 'tos': 'test_value_14',
- 'tos-mask': 'test_value_15'
- }
-
- set_method_mock.assert_called_with('router', 'policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_policy6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_policy6': {
- 'random_attribute_not_valid': 'tag',
- 'comments': 'test_value_3',
- 'dst': 'test_value_4',
- 'end_port': '5',
- 'gateway': 'test_value_6',
- 'input_device': 'test_value_7',
- 'output_device': 'test_value_8',
- 'protocol': '9',
- 'seq_num': '10',
- 'src': 'test_value_11',
- 'start_port': '12',
- 'status': 'enable',
- 'tos': 'test_value_14',
- 'tos_mask': 'test_value_15'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_policy6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'dst': 'test_value_4',
- 'end-port': '5',
- 'gateway': 'test_value_6',
- 'input-device': 'test_value_7',
- 'output-device': 'test_value_8',
- 'protocol': '9',
- 'seq-num': '10',
- 'src': 'test_value_11',
- 'start-port': '12',
- 'status': 'enable',
- 'tos': 'test_value_14',
- 'tos-mask': 'test_value_15'
- }
-
- set_method_mock.assert_called_with('router', 'policy6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_prefix_list.py b/test/units/modules/network/fortios/test_fortios_router_prefix_list.py
deleted file mode 100644
index 7573c3930e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_prefix_list.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_prefix_list
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_prefix_list.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_prefix_list_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_prefix_list': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'prefix-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_prefix_list_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_prefix_list': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'prefix-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_prefix_list_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_prefix_list': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'prefix-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_prefix_list_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_prefix_list': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'prefix-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_prefix_list_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_prefix_list': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'prefix-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_prefix_list_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_prefix_list': {
- 'random_attribute_not_valid': 'tag',
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'prefix-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_prefix_list6.py b/test/units/modules/network/fortios/test_fortios_router_prefix_list6.py
deleted file mode 100644
index 6ed47e49f8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_prefix_list6.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_prefix_list6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_prefix_list6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_prefix_list6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_prefix_list6': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'prefix-list6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_prefix_list6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_prefix_list6': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'prefix-list6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_prefix_list6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_prefix_list6': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list6.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'prefix-list6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_prefix_list6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_prefix_list6': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list6.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'prefix-list6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_prefix_list6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_prefix_list6': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'prefix-list6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_prefix_list6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_prefix_list6': {
- 'random_attribute_not_valid': 'tag',
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_prefix_list6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'prefix-list6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_rip.py b/test/units/modules/network/fortios/test_fortios_router_rip.py
deleted file mode 100644
index 995ea75de3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_rip.py
+++ /dev/null
@@ -1,207 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_rip
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_rip.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_rip_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_rip': {
- 'default_information_originate': 'enable',
- 'default_metric': '4',
- 'garbage_timer': '5',
- 'max_out_metric': '6',
- 'recv_buffer_size': '7',
- 'timeout_timer': '8',
- 'update_timer': '9',
- 'version': '1'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_rip.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'default-information-originate': 'enable',
- 'default-metric': '4',
- 'garbage-timer': '5',
- 'max-out-metric': '6',
- 'recv-buffer-size': '7',
- 'timeout-timer': '8',
- 'update-timer': '9',
- 'version': '1'
- }
-
- set_method_mock.assert_called_with('router', 'rip', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_rip_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_rip': {
- 'default_information_originate': 'enable',
- 'default_metric': '4',
- 'garbage_timer': '5',
- 'max_out_metric': '6',
- 'recv_buffer_size': '7',
- 'timeout_timer': '8',
- 'update_timer': '9',
- 'version': '1'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_rip.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'default-information-originate': 'enable',
- 'default-metric': '4',
- 'garbage-timer': '5',
- 'max-out-metric': '6',
- 'recv-buffer-size': '7',
- 'timeout-timer': '8',
- 'update-timer': '9',
- 'version': '1'
- }
-
- set_method_mock.assert_called_with('router', 'rip', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_rip_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_rip': {
- 'default_information_originate': 'enable',
- 'default_metric': '4',
- 'garbage_timer': '5',
- 'max_out_metric': '6',
- 'recv_buffer_size': '7',
- 'timeout_timer': '8',
- 'update_timer': '9',
- 'version': '1'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_rip.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'default-information-originate': 'enable',
- 'default-metric': '4',
- 'garbage-timer': '5',
- 'max-out-metric': '6',
- 'recv-buffer-size': '7',
- 'timeout-timer': '8',
- 'update-timer': '9',
- 'version': '1'
- }
-
- set_method_mock.assert_called_with('router', 'rip', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_rip_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_rip': {
- 'random_attribute_not_valid': 'tag',
- 'default_information_originate': 'enable',
- 'default_metric': '4',
- 'garbage_timer': '5',
- 'max_out_metric': '6',
- 'recv_buffer_size': '7',
- 'timeout_timer': '8',
- 'update_timer': '9',
- 'version': '1'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_rip.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'default-information-originate': 'enable',
- 'default-metric': '4',
- 'garbage-timer': '5',
- 'max-out-metric': '6',
- 'recv-buffer-size': '7',
- 'timeout-timer': '8',
- 'update-timer': '9',
- 'version': '1'
- }
-
- set_method_mock.assert_called_with('router', 'rip', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_ripng.py b/test/units/modules/network/fortios/test_fortios_router_ripng.py
deleted file mode 100644
index 54e26a7ddb..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_ripng.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_ripng
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_ripng.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_ripng_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ripng': {'default_information_originate': 'enable',
- 'default_metric': '4',
- 'garbage_timer': '5',
- 'max_out_metric': '6',
- 'timeout_timer': '7',
- 'update_timer': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ripng.fortios_router(input_data, fos_instance)
-
- expected_data = {'default-information-originate': 'enable',
- 'default-metric': '4',
- 'garbage-timer': '5',
- 'max-out-metric': '6',
- 'timeout-timer': '7',
- 'update-timer': '8'
- }
-
- set_method_mock.assert_called_with('router', 'ripng', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_ripng_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ripng': {'default_information_originate': 'enable',
- 'default_metric': '4',
- 'garbage_timer': '5',
- 'max_out_metric': '6',
- 'timeout_timer': '7',
- 'update_timer': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ripng.fortios_router(input_data, fos_instance)
-
- expected_data = {'default-information-originate': 'enable',
- 'default-metric': '4',
- 'garbage-timer': '5',
- 'max-out-metric': '6',
- 'timeout-timer': '7',
- 'update-timer': '8'
- }
-
- set_method_mock.assert_called_with('router', 'ripng', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_ripng_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ripng': {'default_information_originate': 'enable',
- 'default_metric': '4',
- 'garbage_timer': '5',
- 'max_out_metric': '6',
- 'timeout_timer': '7',
- 'update_timer': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ripng.fortios_router(input_data, fos_instance)
-
- expected_data = {'default-information-originate': 'enable',
- 'default-metric': '4',
- 'garbage-timer': '5',
- 'max-out-metric': '6',
- 'timeout-timer': '7',
- 'update-timer': '8'
- }
-
- set_method_mock.assert_called_with('router', 'ripng', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_ripng_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_ripng': {
- 'random_attribute_not_valid': 'tag', 'default_information_originate': 'enable',
- 'default_metric': '4',
- 'garbage_timer': '5',
- 'max_out_metric': '6',
- 'timeout_timer': '7',
- 'update_timer': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_ripng.fortios_router(input_data, fos_instance)
-
- expected_data = {'default-information-originate': 'enable',
- 'default-metric': '4',
- 'garbage-timer': '5',
- 'max-out-metric': '6',
- 'timeout-timer': '7',
- 'update-timer': '8'
- }
-
- set_method_mock.assert_called_with('router', 'ripng', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_route_map.py b/test/units/modules/network/fortios/test_fortios_router_route_map.py
deleted file mode 100644
index 6d135cf44a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_route_map.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_route_map
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_route_map.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_route_map_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_route_map': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_route_map.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'route-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_route_map_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_route_map': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_route_map.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'route-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_route_map_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_route_map': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_route_map.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'route-map', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_route_map_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_route_map': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_route_map.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'route-map', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_route_map_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_route_map': {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_route_map.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'route-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_route_map_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_route_map': {
- 'random_attribute_not_valid': 'tag',
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_route_map.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('router', 'route-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_setting.py b/test/units/modules/network/fortios/test_fortios_router_setting.py
deleted file mode 100644
index 1c8be420cb..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_setting.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_setting': {
- 'hostname': 'myhostname3',
- 'show_filter': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_setting.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'hostname': 'myhostname3',
- 'show-filter': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('router', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_setting': {
- 'hostname': 'myhostname3',
- 'show_filter': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_setting.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'hostname': 'myhostname3',
- 'show-filter': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('router', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_setting': {
- 'hostname': 'myhostname3',
- 'show_filter': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_setting.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'hostname': 'myhostname3',
- 'show-filter': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('router', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_setting': {
- 'random_attribute_not_valid': 'tag',
- 'hostname': 'myhostname3',
- 'show_filter': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_setting.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'hostname': 'myhostname3',
- 'show-filter': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('router', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_static.py b/test/units/modules/network/fortios/test_fortios_router_static.py
deleted file mode 100644
index 9180501496..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_static.py
+++ /dev/null
@@ -1,379 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_static
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_static.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_static_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_static': {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'distance': '7',
- 'dst': 'test_value_8',
- 'dstaddr': 'test_value_9',
- 'dynamic_gateway': 'enable',
- 'gateway': 'test_value_11',
- 'internet_service': '12',
- 'internet_service_custom': 'test_value_13',
- 'link_monitor_exempt': 'enable',
- 'priority': '15',
- 'seq_num': '16',
- 'src': 'test_value_17',
- 'status': 'enable',
- 'virtual_wan_link': 'enable',
- 'vrf': '20',
- 'weight': '21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'distance': '7',
- 'dst': 'test_value_8',
- 'dstaddr': 'test_value_9',
- 'dynamic-gateway': 'enable',
- 'gateway': 'test_value_11',
- 'internet-service': '12',
- 'internet-service-custom': 'test_value_13',
- 'link-monitor-exempt': 'enable',
- 'priority': '15',
- 'seq-num': '16',
- 'src': 'test_value_17',
- 'status': 'enable',
- 'virtual-wan-link': 'enable',
- 'vrf': '20',
- 'weight': '21'
- }
-
- set_method_mock.assert_called_with('router', 'static', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_static_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_static': {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'distance': '7',
- 'dst': 'test_value_8',
- 'dstaddr': 'test_value_9',
- 'dynamic_gateway': 'enable',
- 'gateway': 'test_value_11',
- 'internet_service': '12',
- 'internet_service_custom': 'test_value_13',
- 'link_monitor_exempt': 'enable',
- 'priority': '15',
- 'seq_num': '16',
- 'src': 'test_value_17',
- 'status': 'enable',
- 'virtual_wan_link': 'enable',
- 'vrf': '20',
- 'weight': '21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'distance': '7',
- 'dst': 'test_value_8',
- 'dstaddr': 'test_value_9',
- 'dynamic-gateway': 'enable',
- 'gateway': 'test_value_11',
- 'internet-service': '12',
- 'internet-service-custom': 'test_value_13',
- 'link-monitor-exempt': 'enable',
- 'priority': '15',
- 'seq-num': '16',
- 'src': 'test_value_17',
- 'status': 'enable',
- 'virtual-wan-link': 'enable',
- 'vrf': '20',
- 'weight': '21'
- }
-
- set_method_mock.assert_called_with('router', 'static', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_static_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_static': {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'distance': '7',
- 'dst': 'test_value_8',
- 'dstaddr': 'test_value_9',
- 'dynamic_gateway': 'enable',
- 'gateway': 'test_value_11',
- 'internet_service': '12',
- 'internet_service_custom': 'test_value_13',
- 'link_monitor_exempt': 'enable',
- 'priority': '15',
- 'seq_num': '16',
- 'src': 'test_value_17',
- 'status': 'enable',
- 'virtual_wan_link': 'enable',
- 'vrf': '20',
- 'weight': '21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'static', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_static_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_static': {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'distance': '7',
- 'dst': 'test_value_8',
- 'dstaddr': 'test_value_9',
- 'dynamic_gateway': 'enable',
- 'gateway': 'test_value_11',
- 'internet_service': '12',
- 'internet_service_custom': 'test_value_13',
- 'link_monitor_exempt': 'enable',
- 'priority': '15',
- 'seq_num': '16',
- 'src': 'test_value_17',
- 'status': 'enable',
- 'virtual_wan_link': 'enable',
- 'vrf': '20',
- 'weight': '21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'static', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_static_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_static': {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'distance': '7',
- 'dst': 'test_value_8',
- 'dstaddr': 'test_value_9',
- 'dynamic_gateway': 'enable',
- 'gateway': 'test_value_11',
- 'internet_service': '12',
- 'internet_service_custom': 'test_value_13',
- 'link_monitor_exempt': 'enable',
- 'priority': '15',
- 'seq_num': '16',
- 'src': 'test_value_17',
- 'status': 'enable',
- 'virtual_wan_link': 'enable',
- 'vrf': '20',
- 'weight': '21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'distance': '7',
- 'dst': 'test_value_8',
- 'dstaddr': 'test_value_9',
- 'dynamic-gateway': 'enable',
- 'gateway': 'test_value_11',
- 'internet-service': '12',
- 'internet-service-custom': 'test_value_13',
- 'link-monitor-exempt': 'enable',
- 'priority': '15',
- 'seq-num': '16',
- 'src': 'test_value_17',
- 'status': 'enable',
- 'virtual-wan-link': 'enable',
- 'vrf': '20',
- 'weight': '21'
- }
-
- set_method_mock.assert_called_with('router', 'static', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_static_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_static': {
- 'random_attribute_not_valid': 'tag',
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'distance': '7',
- 'dst': 'test_value_8',
- 'dstaddr': 'test_value_9',
- 'dynamic_gateway': 'enable',
- 'gateway': 'test_value_11',
- 'internet_service': '12',
- 'internet_service_custom': 'test_value_13',
- 'link_monitor_exempt': 'enable',
- 'priority': '15',
- 'seq_num': '16',
- 'src': 'test_value_17',
- 'status': 'enable',
- 'virtual_wan_link': 'enable',
- 'vrf': '20',
- 'weight': '21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'distance': '7',
- 'dst': 'test_value_8',
- 'dstaddr': 'test_value_9',
- 'dynamic-gateway': 'enable',
- 'gateway': 'test_value_11',
- 'internet-service': '12',
- 'internet-service-custom': 'test_value_13',
- 'link-monitor-exempt': 'enable',
- 'priority': '15',
- 'seq-num': '16',
- 'src': 'test_value_17',
- 'status': 'enable',
- 'virtual-wan-link': 'enable',
- 'vrf': '20',
- 'weight': '21'
- }
-
- set_method_mock.assert_called_with('router', 'static', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_router_static6.py b/test/units/modules/network/fortios/test_fortios_router_static6.py
deleted file mode 100644
index e9de3df421..0000000000
--- a/test/units/modules/network/fortios/test_fortios_router_static6.py
+++ /dev/null
@@ -1,309 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_router_static6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_router_static6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_router_static6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_static6': {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'devindex': '7',
- 'distance': '8',
- 'dst': 'test_value_9',
- 'gateway': 'test_value_10',
- 'priority': '11',
- 'seq_num': '12',
- 'status': 'enable',
- 'virtual_wan_link': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'devindex': '7',
- 'distance': '8',
- 'dst': 'test_value_9',
- 'gateway': 'test_value_10',
- 'priority': '11',
- 'seq-num': '12',
- 'status': 'enable',
- 'virtual-wan-link': 'enable'
- }
-
- set_method_mock.assert_called_with('router', 'static6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_static6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_static6': {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'devindex': '7',
- 'distance': '8',
- 'dst': 'test_value_9',
- 'gateway': 'test_value_10',
- 'priority': '11',
- 'seq_num': '12',
- 'status': 'enable',
- 'virtual_wan_link': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'devindex': '7',
- 'distance': '8',
- 'dst': 'test_value_9',
- 'gateway': 'test_value_10',
- 'priority': '11',
- 'seq-num': '12',
- 'status': 'enable',
- 'virtual-wan-link': 'enable'
- }
-
- set_method_mock.assert_called_with('router', 'static6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_static6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_static6': {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'devindex': '7',
- 'distance': '8',
- 'dst': 'test_value_9',
- 'gateway': 'test_value_10',
- 'priority': '11',
- 'seq_num': '12',
- 'status': 'enable',
- 'virtual_wan_link': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static6.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'static6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_router_static6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'router_static6': {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'devindex': '7',
- 'distance': '8',
- 'dst': 'test_value_9',
- 'gateway': 'test_value_10',
- 'priority': '11',
- 'seq_num': '12',
- 'status': 'enable',
- 'virtual_wan_link': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static6.fortios_router(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('router', 'static6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_router_static6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_static6': {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'devindex': '7',
- 'distance': '8',
- 'dst': 'test_value_9',
- 'gateway': 'test_value_10',
- 'priority': '11',
- 'seq_num': '12',
- 'status': 'enable',
- 'virtual_wan_link': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'devindex': '7',
- 'distance': '8',
- 'dst': 'test_value_9',
- 'gateway': 'test_value_10',
- 'priority': '11',
- 'seq-num': '12',
- 'status': 'enable',
- 'virtual-wan-link': 'enable'
- }
-
- set_method_mock.assert_called_with('router', 'static6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_router_static6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'router_static6': {
- 'random_attribute_not_valid': 'tag',
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'devindex': '7',
- 'distance': '8',
- 'dst': 'test_value_9',
- 'gateway': 'test_value_10',
- 'priority': '11',
- 'seq_num': '12',
- 'status': 'enable',
- 'virtual_wan_link': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_router_static6.fortios_router(input_data, fos_instance)
-
- expected_data = {
- 'bfd': 'enable',
- 'blackhole': 'enable',
- 'comment': 'Optional comments.',
- 'device': 'test_value_6',
- 'devindex': '7',
- 'distance': '8',
- 'dst': 'test_value_9',
- 'gateway': 'test_value_10',
- 'priority': '11',
- 'seq-num': '12',
- 'status': 'enable',
- 'virtual-wan-link': 'enable'
- }
-
- set_method_mock.assert_called_with('router', 'static6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_spamfilter_bwl.py b/test/units/modules/network/fortios/test_fortios_spamfilter_bwl.py
deleted file mode 100644
index 34a36b73d2..0000000000
--- a/test/units/modules/network/fortios/test_fortios_spamfilter_bwl.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_spamfilter_bwl
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_spamfilter_bwl.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_spamfilter_bwl_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_bwl': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bwl.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'bwl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_bwl_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_bwl': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bwl.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'bwl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_bwl_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_bwl': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bwl.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'bwl', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_bwl_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_bwl': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bwl.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'bwl', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_bwl_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_bwl': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bwl.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'bwl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_spamfilter_bwl_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_bwl': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bwl.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'bwl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_spamfilter_bword.py b/test/units/modules/network/fortios/test_fortios_spamfilter_bword.py
deleted file mode 100644
index 725f901e6e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_spamfilter_bword.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_spamfilter_bword
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_spamfilter_bword.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_spamfilter_bword_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_bword': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bword.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'bword', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_bword_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_bword': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bword.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'bword', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_bword_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_bword': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bword.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'bword', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_bword_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_bword': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bword.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'bword', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_bword_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_bword': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bword.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'bword', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_spamfilter_bword_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_bword': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_bword.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'bword', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_spamfilter_dnsbl.py b/test/units/modules/network/fortios/test_fortios_spamfilter_dnsbl.py
deleted file mode 100644
index 14dcc78ea3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_spamfilter_dnsbl.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_spamfilter_dnsbl
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_spamfilter_dnsbl.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_spamfilter_dnsbl_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_dnsbl': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_dnsbl.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'dnsbl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_dnsbl_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_dnsbl': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_dnsbl.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'dnsbl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_dnsbl_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_dnsbl': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_dnsbl.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'dnsbl', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_dnsbl_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_dnsbl': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_dnsbl.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'dnsbl', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_dnsbl_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_dnsbl': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_dnsbl.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'dnsbl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_spamfilter_dnsbl_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_dnsbl': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_dnsbl.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'dnsbl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_spamfilter_fortishield.py b/test/units/modules/network/fortios/test_fortios_spamfilter_fortishield.py
deleted file mode 100644
index 14947dc3ba..0000000000
--- a/test/units/modules/network/fortios/test_fortios_spamfilter_fortishield.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_spamfilter_fortishield
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_spamfilter_fortishield.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_spamfilter_fortishield_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_fortishield': {
- 'spam_submit_force': 'enable',
- 'spam_submit_srv': 'test_value_4',
- 'spam_submit_txt2htm': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_fortishield.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'spam-submit-force': 'enable',
- 'spam-submit-srv': 'test_value_4',
- 'spam-submit-txt2htm': 'enable'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'fortishield', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_fortishield_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_fortishield': {
- 'spam_submit_force': 'enable',
- 'spam_submit_srv': 'test_value_4',
- 'spam_submit_txt2htm': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_fortishield.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'spam-submit-force': 'enable',
- 'spam-submit-srv': 'test_value_4',
- 'spam-submit-txt2htm': 'enable'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'fortishield', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_fortishield_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_fortishield': {
- 'spam_submit_force': 'enable',
- 'spam_submit_srv': 'test_value_4',
- 'spam_submit_txt2htm': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_fortishield.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'spam-submit-force': 'enable',
- 'spam-submit-srv': 'test_value_4',
- 'spam-submit-txt2htm': 'enable'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'fortishield', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_spamfilter_fortishield_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_fortishield': {
- 'random_attribute_not_valid': 'tag',
- 'spam_submit_force': 'enable',
- 'spam_submit_srv': 'test_value_4',
- 'spam_submit_txt2htm': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_fortishield.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'spam-submit-force': 'enable',
- 'spam-submit-srv': 'test_value_4',
- 'spam-submit-txt2htm': 'enable'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'fortishield', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_spamfilter_iptrust.py b/test/units/modules/network/fortios/test_fortios_spamfilter_iptrust.py
deleted file mode 100644
index c729c6030a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_spamfilter_iptrust.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_spamfilter_iptrust
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_spamfilter_iptrust.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_spamfilter_iptrust_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_iptrust': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_iptrust.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'iptrust', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_iptrust_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_iptrust': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_iptrust.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'iptrust', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_iptrust_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_iptrust': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_iptrust.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'iptrust', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_iptrust_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_iptrust': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_iptrust.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'iptrust', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_iptrust_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_iptrust': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_iptrust.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'iptrust', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_spamfilter_iptrust_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_iptrust': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_iptrust.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'iptrust', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_spamfilter_mheader.py b/test/units/modules/network/fortios/test_fortios_spamfilter_mheader.py
deleted file mode 100644
index fd2b14128e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_spamfilter_mheader.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_spamfilter_mheader
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_spamfilter_mheader.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_spamfilter_mheader_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_mheader': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_mheader.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'mheader', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_mheader_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_mheader': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_mheader.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'mheader', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_mheader_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_mheader': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_mheader.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'mheader', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_mheader_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_mheader': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_mheader.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'mheader', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_mheader_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_mheader': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_mheader.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'mheader', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_spamfilter_mheader_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_mheader': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_mheader.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'mheader', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_spamfilter_options.py b/test/units/modules/network/fortios/test_fortios_spamfilter_options.py
deleted file mode 100644
index 9d2ae4bc54..0000000000
--- a/test/units/modules/network/fortios/test_fortios_spamfilter_options.py
+++ /dev/null
@@ -1,151 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_spamfilter_options
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_spamfilter_options.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_spamfilter_options_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_options': {
- 'dns_timeout': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_options.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'dns-timeout': '3'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'options', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_options_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_options': {
- 'dns_timeout': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_options.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'dns-timeout': '3'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'options', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_options_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_options': {
- 'dns_timeout': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_options.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'dns-timeout': '3'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'options', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_spamfilter_options_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_options': {
- 'random_attribute_not_valid': 'tag',
- 'dns_timeout': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_options.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'dns-timeout': '3'
- }
-
- set_method_mock.assert_called_with('spamfilter', 'options', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_spamfilter_profile.py b/test/units/modules/network/fortios/test_fortios_spamfilter_profile.py
deleted file mode 100644
index 8f5dc59914..0000000000
--- a/test/units/modules/network/fortios/test_fortios_spamfilter_profile.py
+++ /dev/null
@@ -1,339 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_spamfilter_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_spamfilter_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_spamfilter_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_profile': {
- 'comment': 'Comment.',
- 'external': 'enable',
- 'flow_based': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7',
- 'spam_bwl_table': '8',
- 'spam_bword_table': '9',
- 'spam_bword_threshold': '10',
- 'spam_filtering': 'enable',
- 'spam_iptrust_table': '12',
- 'spam_log': 'disable',
- 'spam_log_fortiguard_response': 'disable',
- 'spam_mheader_table': '15',
- 'spam_rbl_table': '16',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_profile.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'external': 'enable',
- 'flow-based': 'enable',
- 'name': 'default_name_6',
- 'replacemsg-group': 'test_value_7',
- 'spam-bwl-table': '8',
- 'spam-bword-table': '9',
- 'spam-bword-threshold': '10',
- 'spam-filtering': 'enable',
- 'spam-iptrust-table': '12',
- 'spam-log': 'disable',
- 'spam-log-fortiguard-response': 'disable',
- 'spam-mheader-table': '15',
- 'spam-rbl-table': '16',
-
- }
-
- set_method_mock.assert_called_with('spamfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_profile': {
- 'comment': 'Comment.',
- 'external': 'enable',
- 'flow_based': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7',
- 'spam_bwl_table': '8',
- 'spam_bword_table': '9',
- 'spam_bword_threshold': '10',
- 'spam_filtering': 'enable',
- 'spam_iptrust_table': '12',
- 'spam_log': 'disable',
- 'spam_log_fortiguard_response': 'disable',
- 'spam_mheader_table': '15',
- 'spam_rbl_table': '16',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_profile.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'external': 'enable',
- 'flow-based': 'enable',
- 'name': 'default_name_6',
- 'replacemsg-group': 'test_value_7',
- 'spam-bwl-table': '8',
- 'spam-bword-table': '9',
- 'spam-bword-threshold': '10',
- 'spam-filtering': 'enable',
- 'spam-iptrust-table': '12',
- 'spam-log': 'disable',
- 'spam-log-fortiguard-response': 'disable',
- 'spam-mheader-table': '15',
- 'spam-rbl-table': '16',
-
- }
-
- set_method_mock.assert_called_with('spamfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_profile': {
- 'comment': 'Comment.',
- 'external': 'enable',
- 'flow_based': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7',
- 'spam_bwl_table': '8',
- 'spam_bword_table': '9',
- 'spam_bword_threshold': '10',
- 'spam_filtering': 'enable',
- 'spam_iptrust_table': '12',
- 'spam_log': 'disable',
- 'spam_log_fortiguard_response': 'disable',
- 'spam_mheader_table': '15',
- 'spam_rbl_table': '16',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_profile.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_spamfilter_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'spamfilter_profile': {
- 'comment': 'Comment.',
- 'external': 'enable',
- 'flow_based': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7',
- 'spam_bwl_table': '8',
- 'spam_bword_table': '9',
- 'spam_bword_threshold': '10',
- 'spam_filtering': 'enable',
- 'spam_iptrust_table': '12',
- 'spam_log': 'disable',
- 'spam_log_fortiguard_response': 'disable',
- 'spam_mheader_table': '15',
- 'spam_rbl_table': '16',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_profile.fortios_spamfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('spamfilter', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_spamfilter_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_profile': {
- 'comment': 'Comment.',
- 'external': 'enable',
- 'flow_based': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7',
- 'spam_bwl_table': '8',
- 'spam_bword_table': '9',
- 'spam_bword_threshold': '10',
- 'spam_filtering': 'enable',
- 'spam_iptrust_table': '12',
- 'spam_log': 'disable',
- 'spam_log_fortiguard_response': 'disable',
- 'spam_mheader_table': '15',
- 'spam_rbl_table': '16',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_profile.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'external': 'enable',
- 'flow-based': 'enable',
- 'name': 'default_name_6',
- 'replacemsg-group': 'test_value_7',
- 'spam-bwl-table': '8',
- 'spam-bword-table': '9',
- 'spam-bword-threshold': '10',
- 'spam-filtering': 'enable',
- 'spam-iptrust-table': '12',
- 'spam-log': 'disable',
- 'spam-log-fortiguard-response': 'disable',
- 'spam-mheader-table': '15',
- 'spam-rbl-table': '16',
-
- }
-
- set_method_mock.assert_called_with('spamfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_spamfilter_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'spamfilter_profile': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'external': 'enable',
- 'flow_based': 'enable',
- 'name': 'default_name_6',
- 'replacemsg_group': 'test_value_7',
- 'spam_bwl_table': '8',
- 'spam_bword_table': '9',
- 'spam_bword_threshold': '10',
- 'spam_filtering': 'enable',
- 'spam_iptrust_table': '12',
- 'spam_log': 'disable',
- 'spam_log_fortiguard_response': 'disable',
- 'spam_mheader_table': '15',
- 'spam_rbl_table': '16',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_spamfilter_profile.fortios_spamfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'external': 'enable',
- 'flow-based': 'enable',
- 'name': 'default_name_6',
- 'replacemsg-group': 'test_value_7',
- 'spam-bwl-table': '8',
- 'spam-bword-table': '9',
- 'spam-bword-threshold': '10',
- 'spam-filtering': 'enable',
- 'spam-iptrust-table': '12',
- 'spam-log': 'disable',
- 'spam-log-fortiguard-response': 'disable',
- 'spam-mheader-table': '15',
- 'spam-rbl-table': '16',
-
- }
-
- set_method_mock.assert_called_with('spamfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_ssh_filter_profile.py b/test/units/modules/network/fortios/test_fortios_ssh_filter_profile.py
deleted file mode 100644
index 80286c1e8c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_ssh_filter_profile.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_ssh_filter_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_ssh_filter_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_ssh_filter_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ssh_filter_profile': {
- 'block': 'x11',
- 'default_command_log': 'enable',
- 'log': 'x11',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ssh_filter_profile.fortios_ssh_filter(input_data, fos_instance)
-
- expected_data = {
- 'block': 'x11',
- 'default-command-log': 'enable',
- 'log': 'x11',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('ssh-filter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ssh_filter_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ssh_filter_profile': {
- 'block': 'x11',
- 'default_command_log': 'enable',
- 'log': 'x11',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ssh_filter_profile.fortios_ssh_filter(input_data, fos_instance)
-
- expected_data = {
- 'block': 'x11',
- 'default-command-log': 'enable',
- 'log': 'x11',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('ssh-filter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ssh_filter_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ssh_filter_profile': {
- 'block': 'x11',
- 'default_command_log': 'enable',
- 'log': 'x11',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ssh_filter_profile.fortios_ssh_filter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ssh-filter', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_ssh_filter_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'ssh_filter_profile': {
- 'block': 'x11',
- 'default_command_log': 'enable',
- 'log': 'x11',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ssh_filter_profile.fortios_ssh_filter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('ssh-filter', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_ssh_filter_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ssh_filter_profile': {
- 'block': 'x11',
- 'default_command_log': 'enable',
- 'log': 'x11',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ssh_filter_profile.fortios_ssh_filter(input_data, fos_instance)
-
- expected_data = {
- 'block': 'x11',
- 'default-command-log': 'enable',
- 'log': 'x11',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('ssh-filter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_ssh_filter_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'ssh_filter_profile': {
- 'random_attribute_not_valid': 'tag',
- 'block': 'x11',
- 'default_command_log': 'enable',
- 'log': 'x11',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_ssh_filter_profile.fortios_ssh_filter(input_data, fos_instance)
-
- expected_data = {
- 'block': 'x11',
- 'default-command-log': 'enable',
- 'log': 'x11',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('ssh-filter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_802_1X_settings.py b/test/units/modules/network/fortios/test_fortios_switch_controller_802_1X_settings.py
deleted file mode 100644
index 65c8f891af..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_802_1X_settings.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_802_1X_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_802_1X_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_802_1X_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_802_1X_settings': {
- 'link_down_auth': 'set-unauth',
- 'max_reauth_attempt': '4',
- 'reauth_period': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_802_1X_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'link-down-auth': 'set-unauth',
- 'max-reauth-attempt': '4',
- 'reauth-period': '5'
- }
-
- set_method_mock.assert_called_with('switch-controller', '802-1X-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_802_1X_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_802_1X_settings': {
- 'link_down_auth': 'set-unauth',
- 'max_reauth_attempt': '4',
- 'reauth_period': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_802_1X_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'link-down-auth': 'set-unauth',
- 'max-reauth-attempt': '4',
- 'reauth-period': '5'
- }
-
- set_method_mock.assert_called_with('switch-controller', '802-1X-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_802_1X_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_802_1X_settings': {
- 'link_down_auth': 'set-unauth',
- 'max_reauth_attempt': '4',
- 'reauth_period': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_802_1X_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'link-down-auth': 'set-unauth',
- 'max-reauth-attempt': '4',
- 'reauth-period': '5'
- }
-
- set_method_mock.assert_called_with('switch-controller', '802-1X-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_802_1X_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_802_1X_settings': {
- 'random_attribute_not_valid': 'tag',
- 'link_down_auth': 'set-unauth',
- 'max_reauth_attempt': '4',
- 'reauth_period': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_802_1X_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'link-down-auth': 'set-unauth',
- 'max-reauth-attempt': '4',
- 'reauth-period': '5'
- }
-
- set_method_mock.assert_called_with('switch-controller', '802-1X-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_custom_command.py b/test/units/modules/network/fortios/test_fortios_switch_controller_custom_command.py
deleted file mode 100644
index 5876b859f7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_custom_command.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_custom_command
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_custom_command.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_custom_command_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_custom_command': {
- 'command': 'test_value_3',
- 'command_name': 'test_value_4',
- 'description': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_custom_command.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'command': 'test_value_3',
- 'command-name': 'test_value_4',
- 'description': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'custom-command', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_custom_command_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_custom_command': {
- 'command': 'test_value_3',
- 'command_name': 'test_value_4',
- 'description': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_custom_command.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'command': 'test_value_3',
- 'command-name': 'test_value_4',
- 'description': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'custom-command', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_custom_command_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_custom_command': {
- 'command': 'test_value_3',
- 'command_name': 'test_value_4',
- 'description': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_custom_command.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'custom-command', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_custom_command_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_custom_command': {
- 'command': 'test_value_3',
- 'command_name': 'test_value_4',
- 'description': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_custom_command.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'custom-command', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_custom_command_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_custom_command': {
- 'command': 'test_value_3',
- 'command_name': 'test_value_4',
- 'description': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_custom_command.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'command': 'test_value_3',
- 'command-name': 'test_value_4',
- 'description': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'custom-command', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_custom_command_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_custom_command': {
- 'random_attribute_not_valid': 'tag',
- 'command': 'test_value_3',
- 'command_name': 'test_value_4',
- 'description': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_custom_command.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'command': 'test_value_3',
- 'command-name': 'test_value_4',
- 'description': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'custom-command', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_global.py b/test/units/modules/network/fortios/test_fortios_switch_controller_global.py
deleted file mode 100644
index 50021093e6..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_global.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_global
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_global.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_global_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_global': {
- 'allow_multiple_interfaces': 'enable',
- 'default_virtual_switch_vlan': 'test_value_4',
- 'https_image_push': 'enable',
- 'log_mac_limit_violations': 'enable',
- 'mac_aging_interval': '7',
- 'mac_retention_period': '8',
- 'mac_violation_timer': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_global.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'allow-multiple-interfaces': 'enable',
- 'default-virtual-switch-vlan': 'test_value_4',
- 'https-image-push': 'enable',
- 'log-mac-limit-violations': 'enable',
- 'mac-aging-interval': '7',
- 'mac-retention-period': '8',
- 'mac-violation-timer': '9'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_global_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_global': {
- 'allow_multiple_interfaces': 'enable',
- 'default_virtual_switch_vlan': 'test_value_4',
- 'https_image_push': 'enable',
- 'log_mac_limit_violations': 'enable',
- 'mac_aging_interval': '7',
- 'mac_retention_period': '8',
- 'mac_violation_timer': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_global.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'allow-multiple-interfaces': 'enable',
- 'default-virtual-switch-vlan': 'test_value_4',
- 'https-image-push': 'enable',
- 'log-mac-limit-violations': 'enable',
- 'mac-aging-interval': '7',
- 'mac-retention-period': '8',
- 'mac-violation-timer': '9'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_global_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_global': {
- 'allow_multiple_interfaces': 'enable',
- 'default_virtual_switch_vlan': 'test_value_4',
- 'https_image_push': 'enable',
- 'log_mac_limit_violations': 'enable',
- 'mac_aging_interval': '7',
- 'mac_retention_period': '8',
- 'mac_violation_timer': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_global.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'allow-multiple-interfaces': 'enable',
- 'default-virtual-switch-vlan': 'test_value_4',
- 'https-image-push': 'enable',
- 'log-mac-limit-violations': 'enable',
- 'mac-aging-interval': '7',
- 'mac-retention-period': '8',
- 'mac-violation-timer': '9'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_global_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_global': {
- 'random_attribute_not_valid': 'tag',
- 'allow_multiple_interfaces': 'enable',
- 'default_virtual_switch_vlan': 'test_value_4',
- 'https_image_push': 'enable',
- 'log_mac_limit_violations': 'enable',
- 'mac_aging_interval': '7',
- 'mac_retention_period': '8',
- 'mac_violation_timer': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_global.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'allow-multiple-interfaces': 'enable',
- 'default-virtual-switch-vlan': 'test_value_4',
- 'https-image-push': 'enable',
- 'log-mac-limit-violations': 'enable',
- 'mac-aging-interval': '7',
- 'mac-retention-period': '8',
- 'mac-violation-timer': '9'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_igmp_snooping.py b/test/units/modules/network/fortios/test_fortios_switch_controller_igmp_snooping.py
deleted file mode 100644
index 51986844d4..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_igmp_snooping.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_igmp_snooping
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_igmp_snooping.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_igmp_snooping_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_igmp_snooping': {
- 'aging_time': '3',
- 'flood_unknown_multicast': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_igmp_snooping.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'aging-time': '3',
- 'flood-unknown-multicast': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'igmp-snooping', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_igmp_snooping_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_igmp_snooping': {
- 'aging_time': '3',
- 'flood_unknown_multicast': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_igmp_snooping.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'aging-time': '3',
- 'flood-unknown-multicast': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'igmp-snooping', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_igmp_snooping_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_igmp_snooping': {
- 'aging_time': '3',
- 'flood_unknown_multicast': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_igmp_snooping.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'aging-time': '3',
- 'flood-unknown-multicast': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'igmp-snooping', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_igmp_snooping_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_igmp_snooping': {
- 'random_attribute_not_valid': 'tag',
- 'aging_time': '3',
- 'flood_unknown_multicast': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_igmp_snooping.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'aging-time': '3',
- 'flood-unknown-multicast': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'igmp-snooping', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_lldp_profile.py b/test/units/modules/network/fortios/test_fortios_switch_controller_lldp_profile.py
deleted file mode 100644
index 783418d6f4..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_lldp_profile.py
+++ /dev/null
@@ -1,269 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_lldp_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_lldp_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_lldp_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_lldp_profile': {
- '802.1_tlvs': 'port-vlan-id',
- '802.3_tlvs': 'max-frame-size',
- 'auto_isl': 'disable',
- 'auto_isl_hello_timer': '6',
- 'auto_isl_port_group': '7',
- 'auto_isl_receive_timeout': '8',
- 'med_tlvs': 'inventory-management',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_lldp_profile.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- '802.1-tlvs': 'port-vlan-id',
- '802.3-tlvs': 'max-frame-size',
- 'auto-isl': 'disable',
- 'auto-isl-hello-timer': '6',
- 'auto-isl-port-group': '7',
- 'auto-isl-receive-timeout': '8',
- 'med-tlvs': 'inventory-management',
- 'name': 'default_name_10'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'lldp-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_lldp_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_lldp_profile': {
- '802.1_tlvs': 'port-vlan-id',
- '802.3_tlvs': 'max-frame-size',
- 'auto_isl': 'disable',
- 'auto_isl_hello_timer': '6',
- 'auto_isl_port_group': '7',
- 'auto_isl_receive_timeout': '8',
- 'med_tlvs': 'inventory-management',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_lldp_profile.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- '802.1-tlvs': 'port-vlan-id',
- '802.3-tlvs': 'max-frame-size',
- 'auto-isl': 'disable',
- 'auto-isl-hello-timer': '6',
- 'auto-isl-port-group': '7',
- 'auto-isl-receive-timeout': '8',
- 'med-tlvs': 'inventory-management',
- 'name': 'default_name_10'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'lldp-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_lldp_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_lldp_profile': {
- '802.1_tlvs': 'port-vlan-id',
- '802.3_tlvs': 'max-frame-size',
- 'auto_isl': 'disable',
- 'auto_isl_hello_timer': '6',
- 'auto_isl_port_group': '7',
- 'auto_isl_receive_timeout': '8',
- 'med_tlvs': 'inventory-management',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_lldp_profile.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'lldp-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_lldp_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_lldp_profile': {
- '802.1_tlvs': 'port-vlan-id',
- '802.3_tlvs': 'max-frame-size',
- 'auto_isl': 'disable',
- 'auto_isl_hello_timer': '6',
- 'auto_isl_port_group': '7',
- 'auto_isl_receive_timeout': '8',
- 'med_tlvs': 'inventory-management',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_lldp_profile.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'lldp-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_lldp_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_lldp_profile': {
- '802.1_tlvs': 'port-vlan-id',
- '802.3_tlvs': 'max-frame-size',
- 'auto_isl': 'disable',
- 'auto_isl_hello_timer': '6',
- 'auto_isl_port_group': '7',
- 'auto_isl_receive_timeout': '8',
- 'med_tlvs': 'inventory-management',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_lldp_profile.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- '802.1-tlvs': 'port-vlan-id',
- '802.3-tlvs': 'max-frame-size',
- 'auto-isl': 'disable',
- 'auto-isl-hello-timer': '6',
- 'auto-isl-port-group': '7',
- 'auto-isl-receive-timeout': '8',
- 'med-tlvs': 'inventory-management',
- 'name': 'default_name_10'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'lldp-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_lldp_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_lldp_profile': {
- 'random_attribute_not_valid': 'tag',
- '802.1_tlvs': 'port-vlan-id',
- '802.3_tlvs': 'max-frame-size',
- 'auto_isl': 'disable',
- 'auto_isl_hello_timer': '6',
- 'auto_isl_port_group': '7',
- 'auto_isl_receive_timeout': '8',
- 'med_tlvs': 'inventory-management',
- 'name': 'default_name_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_lldp_profile.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- '802.1-tlvs': 'port-vlan-id',
- '802.3-tlvs': 'max-frame-size',
- 'auto-isl': 'disable',
- 'auto-isl-hello-timer': '6',
- 'auto-isl-port-group': '7',
- 'auto-isl-receive-timeout': '8',
- 'med-tlvs': 'inventory-management',
- 'name': 'default_name_10'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'lldp-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_lldp_settings.py b/test/units/modules/network/fortios/test_fortios_switch_controller_lldp_settings.py
deleted file mode 100644
index c8e9e8c94c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_lldp_settings.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_lldp_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_lldp_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_lldp_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_lldp_settings': {
- 'fast_start_interval': '3',
- 'management_interface': 'internal',
- 'status': 'enable',
- 'tx_hold': '6',
- 'tx_interval': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_lldp_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'fast-start-interval': '3',
- 'management-interface': 'internal',
- 'status': 'enable',
- 'tx-hold': '6',
- 'tx-interval': '7'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'lldp-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_lldp_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_lldp_settings': {
- 'fast_start_interval': '3',
- 'management_interface': 'internal',
- 'status': 'enable',
- 'tx_hold': '6',
- 'tx_interval': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_lldp_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'fast-start-interval': '3',
- 'management-interface': 'internal',
- 'status': 'enable',
- 'tx-hold': '6',
- 'tx-interval': '7'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'lldp-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_lldp_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_lldp_settings': {
- 'fast_start_interval': '3',
- 'management_interface': 'internal',
- 'status': 'enable',
- 'tx_hold': '6',
- 'tx_interval': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_lldp_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'fast-start-interval': '3',
- 'management-interface': 'internal',
- 'status': 'enable',
- 'tx-hold': '6',
- 'tx-interval': '7'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'lldp-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_lldp_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_lldp_settings': {
- 'random_attribute_not_valid': 'tag',
- 'fast_start_interval': '3',
- 'management_interface': 'internal',
- 'status': 'enable',
- 'tx_hold': '6',
- 'tx_interval': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_lldp_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'fast-start-interval': '3',
- 'management-interface': 'internal',
- 'status': 'enable',
- 'tx-hold': '6',
- 'tx-interval': '7'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'lldp-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_mac_sync_settings.py b/test/units/modules/network/fortios/test_fortios_switch_controller_mac_sync_settings.py
deleted file mode 100644
index 8a41be2c86..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_mac_sync_settings.py
+++ /dev/null
@@ -1,151 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_mac_sync_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_mac_sync_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_mac_sync_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_mac_sync_settings': {
- 'mac_sync_interval': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_mac_sync_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'mac-sync-interval': '3'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'mac-sync-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_mac_sync_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_mac_sync_settings': {
- 'mac_sync_interval': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_mac_sync_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'mac-sync-interval': '3'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'mac-sync-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_mac_sync_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_mac_sync_settings': {
- 'mac_sync_interval': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_mac_sync_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'mac-sync-interval': '3'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'mac-sync-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_mac_sync_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_mac_sync_settings': {
- 'random_attribute_not_valid': 'tag',
- 'mac_sync_interval': '3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_mac_sync_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'mac-sync-interval': '3'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'mac-sync-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_managed_switch.py b/test/units/modules/network/fortios/test_fortios_switch_controller_managed_switch.py
deleted file mode 100644
index 1670347064..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_managed_switch.py
+++ /dev/null
@@ -1,389 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_managed_switch
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_managed_switch.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_managed_switch_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_managed_switch': {'delayed_restart_trigger': '3',
- 'description': 'test_value_4',
- 'directly_connected': '5',
- 'dynamic_capability': '6',
- 'dynamically_discovered': '7',
- 'fsw_wan1_admin': 'discovered',
- 'fsw_wan1_peer': 'test_value_9',
- 'fsw_wan2_admin': 'discovered',
- 'fsw_wan2_peer': 'test_value_11',
- 'max_allowed_trunk_members': '12',
- 'name': 'default_name_13',
- 'owner_vdom': 'test_value_14',
- 'poe_detection_type': '15',
- 'poe_pre_standard_detection': 'enable',
- 'pre_provisioned': '17',
- 'staged_image_version': 'test_value_18',
- 'switch_device_tag': 'test_value_19',
- 'switch_id': 'test_value_20',
- 'switch_profile': 'test_value_21',
- 'type': 'virtual',
- 'version': '23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_managed_switch.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {'delayed-restart-trigger': '3',
- 'description': 'test_value_4',
- 'directly-connected': '5',
- 'dynamic-capability': '6',
- 'dynamically-discovered': '7',
- 'fsw-wan1-admin': 'discovered',
- 'fsw-wan1-peer': 'test_value_9',
- 'fsw-wan2-admin': 'discovered',
- 'fsw-wan2-peer': 'test_value_11',
- 'max-allowed-trunk-members': '12',
- 'name': 'default_name_13',
- 'owner-vdom': 'test_value_14',
- 'poe-detection-type': '15',
- 'poe-pre-standard-detection': 'enable',
- 'pre-provisioned': '17',
- 'staged-image-version': 'test_value_18',
- 'switch-device-tag': 'test_value_19',
- 'switch-id': 'test_value_20',
- 'switch-profile': 'test_value_21',
- 'type': 'virtual',
- 'version': '23'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'managed-switch', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_managed_switch_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_managed_switch': {'delayed_restart_trigger': '3',
- 'description': 'test_value_4',
- 'directly_connected': '5',
- 'dynamic_capability': '6',
- 'dynamically_discovered': '7',
- 'fsw_wan1_admin': 'discovered',
- 'fsw_wan1_peer': 'test_value_9',
- 'fsw_wan2_admin': 'discovered',
- 'fsw_wan2_peer': 'test_value_11',
- 'max_allowed_trunk_members': '12',
- 'name': 'default_name_13',
- 'owner_vdom': 'test_value_14',
- 'poe_detection_type': '15',
- 'poe_pre_standard_detection': 'enable',
- 'pre_provisioned': '17',
- 'staged_image_version': 'test_value_18',
- 'switch_device_tag': 'test_value_19',
- 'switch_id': 'test_value_20',
- 'switch_profile': 'test_value_21',
- 'type': 'virtual',
- 'version': '23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_managed_switch.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {'delayed-restart-trigger': '3',
- 'description': 'test_value_4',
- 'directly-connected': '5',
- 'dynamic-capability': '6',
- 'dynamically-discovered': '7',
- 'fsw-wan1-admin': 'discovered',
- 'fsw-wan1-peer': 'test_value_9',
- 'fsw-wan2-admin': 'discovered',
- 'fsw-wan2-peer': 'test_value_11',
- 'max-allowed-trunk-members': '12',
- 'name': 'default_name_13',
- 'owner-vdom': 'test_value_14',
- 'poe-detection-type': '15',
- 'poe-pre-standard-detection': 'enable',
- 'pre-provisioned': '17',
- 'staged-image-version': 'test_value_18',
- 'switch-device-tag': 'test_value_19',
- 'switch-id': 'test_value_20',
- 'switch-profile': 'test_value_21',
- 'type': 'virtual',
- 'version': '23'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'managed-switch', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_managed_switch_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_managed_switch': {'delayed_restart_trigger': '3',
- 'description': 'test_value_4',
- 'directly_connected': '5',
- 'dynamic_capability': '6',
- 'dynamically_discovered': '7',
- 'fsw_wan1_admin': 'discovered',
- 'fsw_wan1_peer': 'test_value_9',
- 'fsw_wan2_admin': 'discovered',
- 'fsw_wan2_peer': 'test_value_11',
- 'max_allowed_trunk_members': '12',
- 'name': 'default_name_13',
- 'owner_vdom': 'test_value_14',
- 'poe_detection_type': '15',
- 'poe_pre_standard_detection': 'enable',
- 'pre_provisioned': '17',
- 'staged_image_version': 'test_value_18',
- 'switch_device_tag': 'test_value_19',
- 'switch_id': 'test_value_20',
- 'switch_profile': 'test_value_21',
- 'type': 'virtual',
- 'version': '23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_managed_switch.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'managed-switch', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_managed_switch_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_managed_switch': {'delayed_restart_trigger': '3',
- 'description': 'test_value_4',
- 'directly_connected': '5',
- 'dynamic_capability': '6',
- 'dynamically_discovered': '7',
- 'fsw_wan1_admin': 'discovered',
- 'fsw_wan1_peer': 'test_value_9',
- 'fsw_wan2_admin': 'discovered',
- 'fsw_wan2_peer': 'test_value_11',
- 'max_allowed_trunk_members': '12',
- 'name': 'default_name_13',
- 'owner_vdom': 'test_value_14',
- 'poe_detection_type': '15',
- 'poe_pre_standard_detection': 'enable',
- 'pre_provisioned': '17',
- 'staged_image_version': 'test_value_18',
- 'switch_device_tag': 'test_value_19',
- 'switch_id': 'test_value_20',
- 'switch_profile': 'test_value_21',
- 'type': 'virtual',
- 'version': '23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_managed_switch.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'managed-switch', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_managed_switch_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_managed_switch': {'delayed_restart_trigger': '3',
- 'description': 'test_value_4',
- 'directly_connected': '5',
- 'dynamic_capability': '6',
- 'dynamically_discovered': '7',
- 'fsw_wan1_admin': 'discovered',
- 'fsw_wan1_peer': 'test_value_9',
- 'fsw_wan2_admin': 'discovered',
- 'fsw_wan2_peer': 'test_value_11',
- 'max_allowed_trunk_members': '12',
- 'name': 'default_name_13',
- 'owner_vdom': 'test_value_14',
- 'poe_detection_type': '15',
- 'poe_pre_standard_detection': 'enable',
- 'pre_provisioned': '17',
- 'staged_image_version': 'test_value_18',
- 'switch_device_tag': 'test_value_19',
- 'switch_id': 'test_value_20',
- 'switch_profile': 'test_value_21',
- 'type': 'virtual',
- 'version': '23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_managed_switch.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {'delayed-restart-trigger': '3',
- 'description': 'test_value_4',
- 'directly-connected': '5',
- 'dynamic-capability': '6',
- 'dynamically-discovered': '7',
- 'fsw-wan1-admin': 'discovered',
- 'fsw-wan1-peer': 'test_value_9',
- 'fsw-wan2-admin': 'discovered',
- 'fsw-wan2-peer': 'test_value_11',
- 'max-allowed-trunk-members': '12',
- 'name': 'default_name_13',
- 'owner-vdom': 'test_value_14',
- 'poe-detection-type': '15',
- 'poe-pre-standard-detection': 'enable',
- 'pre-provisioned': '17',
- 'staged-image-version': 'test_value_18',
- 'switch-device-tag': 'test_value_19',
- 'switch-id': 'test_value_20',
- 'switch-profile': 'test_value_21',
- 'type': 'virtual',
- 'version': '23'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'managed-switch', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_managed_switch_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_managed_switch': {
- 'random_attribute_not_valid': 'tag', 'delayed_restart_trigger': '3',
- 'description': 'test_value_4',
- 'directly_connected': '5',
- 'dynamic_capability': '6',
- 'dynamically_discovered': '7',
- 'fsw_wan1_admin': 'discovered',
- 'fsw_wan1_peer': 'test_value_9',
- 'fsw_wan2_admin': 'discovered',
- 'fsw_wan2_peer': 'test_value_11',
- 'max_allowed_trunk_members': '12',
- 'name': 'default_name_13',
- 'owner_vdom': 'test_value_14',
- 'poe_detection_type': '15',
- 'poe_pre_standard_detection': 'enable',
- 'pre_provisioned': '17',
- 'staged_image_version': 'test_value_18',
- 'switch_device_tag': 'test_value_19',
- 'switch_id': 'test_value_20',
- 'switch_profile': 'test_value_21',
- 'type': 'virtual',
- 'version': '23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_managed_switch.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {'delayed-restart-trigger': '3',
- 'description': 'test_value_4',
- 'directly-connected': '5',
- 'dynamic-capability': '6',
- 'dynamically-discovered': '7',
- 'fsw-wan1-admin': 'discovered',
- 'fsw-wan1-peer': 'test_value_9',
- 'fsw-wan2-admin': 'discovered',
- 'fsw-wan2-peer': 'test_value_11',
- 'max-allowed-trunk-members': '12',
- 'name': 'default_name_13',
- 'owner-vdom': 'test_value_14',
- 'poe-detection-type': '15',
- 'poe-pre-standard-detection': 'enable',
- 'pre-provisioned': '17',
- 'staged-image-version': 'test_value_18',
- 'switch-device-tag': 'test_value_19',
- 'switch-id': 'test_value_20',
- 'switch-profile': 'test_value_21',
- 'type': 'virtual',
- 'version': '23'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'managed-switch', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_network_monitor_settings.py b/test/units/modules/network/fortios/test_fortios_switch_controller_network_monitor_settings.py
deleted file mode 100644
index 50255f41c6..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_network_monitor_settings.py
+++ /dev/null
@@ -1,151 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_network_monitor_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_network_monitor_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_network_monitor_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_network_monitor_settings': {
- 'network_monitoring': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_network_monitor_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'network-monitoring': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'network-monitor-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_network_monitor_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_network_monitor_settings': {
- 'network_monitoring': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_network_monitor_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'network-monitoring': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'network-monitor-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_network_monitor_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_network_monitor_settings': {
- 'network_monitoring': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_network_monitor_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'network-monitoring': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'network-monitor-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_network_monitor_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_network_monitor_settings': {
- 'random_attribute_not_valid': 'tag',
- 'network_monitoring': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_network_monitor_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'network-monitoring': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'network-monitor-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_qos_dot1p_map.py b/test/units/modules/network/fortios/test_fortios_switch_controller_qos_dot1p_map.py
deleted file mode 100644
index 2af320b601..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_qos_dot1p_map.py
+++ /dev/null
@@ -1,289 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_qos_dot1p_map
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_qos_dot1p_map.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_qos_dot1p_map_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_dot1p_map': {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
- 'priority_0': 'queue-0',
- 'priority_1': 'queue-0',
- 'priority_2': 'queue-0',
- 'priority_3': 'queue-0',
- 'priority_4': 'queue-0',
- 'priority_5': 'queue-0',
- 'priority_6': 'queue-0',
- 'priority_7': 'queue-0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_dot1p_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
- 'priority-0': 'queue-0',
- 'priority-1': 'queue-0',
- 'priority-2': 'queue-0',
- 'priority-3': 'queue-0',
- 'priority-4': 'queue-0',
- 'priority-5': 'queue-0',
- 'priority-6': 'queue-0',
- 'priority-7': 'queue-0'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'dot1p-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_qos_dot1p_map_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_dot1p_map': {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
- 'priority_0': 'queue-0',
- 'priority_1': 'queue-0',
- 'priority_2': 'queue-0',
- 'priority_3': 'queue-0',
- 'priority_4': 'queue-0',
- 'priority_5': 'queue-0',
- 'priority_6': 'queue-0',
- 'priority_7': 'queue-0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_dot1p_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
- 'priority-0': 'queue-0',
- 'priority-1': 'queue-0',
- 'priority-2': 'queue-0',
- 'priority-3': 'queue-0',
- 'priority-4': 'queue-0',
- 'priority-5': 'queue-0',
- 'priority-6': 'queue-0',
- 'priority-7': 'queue-0'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'dot1p-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_qos_dot1p_map_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_qos_dot1p_map': {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
- 'priority_0': 'queue-0',
- 'priority_1': 'queue-0',
- 'priority_2': 'queue-0',
- 'priority_3': 'queue-0',
- 'priority_4': 'queue-0',
- 'priority_5': 'queue-0',
- 'priority_6': 'queue-0',
- 'priority_7': 'queue-0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_dot1p_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.qos', 'dot1p-map', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_qos_dot1p_map_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_qos_dot1p_map': {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
- 'priority_0': 'queue-0',
- 'priority_1': 'queue-0',
- 'priority_2': 'queue-0',
- 'priority_3': 'queue-0',
- 'priority_4': 'queue-0',
- 'priority_5': 'queue-0',
- 'priority_6': 'queue-0',
- 'priority_7': 'queue-0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_dot1p_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.qos', 'dot1p-map', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_qos_dot1p_map_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_dot1p_map': {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
- 'priority_0': 'queue-0',
- 'priority_1': 'queue-0',
- 'priority_2': 'queue-0',
- 'priority_3': 'queue-0',
- 'priority_4': 'queue-0',
- 'priority_5': 'queue-0',
- 'priority_6': 'queue-0',
- 'priority_7': 'queue-0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_dot1p_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
- 'priority-0': 'queue-0',
- 'priority-1': 'queue-0',
- 'priority-2': 'queue-0',
- 'priority-3': 'queue-0',
- 'priority-4': 'queue-0',
- 'priority-5': 'queue-0',
- 'priority-6': 'queue-0',
- 'priority-7': 'queue-0'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'dot1p-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_qos_dot1p_map_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_dot1p_map': {
- 'random_attribute_not_valid': 'tag',
- 'description': 'test_value_3',
- 'name': 'default_name_4',
- 'priority_0': 'queue-0',
- 'priority_1': 'queue-0',
- 'priority_2': 'queue-0',
- 'priority_3': 'queue-0',
- 'priority_4': 'queue-0',
- 'priority_5': 'queue-0',
- 'priority_6': 'queue-0',
- 'priority_7': 'queue-0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_dot1p_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
- 'priority-0': 'queue-0',
- 'priority-1': 'queue-0',
- 'priority-2': 'queue-0',
- 'priority-3': 'queue-0',
- 'priority-4': 'queue-0',
- 'priority-5': 'queue-0',
- 'priority-6': 'queue-0',
- 'priority-7': 'queue-0'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'dot1p-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_qos_ip_dscp_map.py b/test/units/modules/network/fortios/test_fortios_switch_controller_qos_ip_dscp_map.py
deleted file mode 100644
index cf703cfb7f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_qos_ip_dscp_map.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_qos_ip_dscp_map
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_qos_ip_dscp_map.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_qos_ip_dscp_map_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_ip_dscp_map': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_ip_dscp_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'ip-dscp-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_qos_ip_dscp_map_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_ip_dscp_map': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_ip_dscp_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'ip-dscp-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_qos_ip_dscp_map_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_qos_ip_dscp_map': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_ip_dscp_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.qos', 'ip-dscp-map', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_qos_ip_dscp_map_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_qos_ip_dscp_map': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_ip_dscp_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.qos', 'ip-dscp-map', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_qos_ip_dscp_map_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_ip_dscp_map': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_ip_dscp_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'ip-dscp-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_qos_ip_dscp_map_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_ip_dscp_map': {
- 'random_attribute_not_valid': 'tag',
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_ip_dscp_map.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'ip-dscp-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_qos_qos_policy.py b/test/units/modules/network/fortios/test_fortios_switch_controller_qos_qos_policy.py
deleted file mode 100644
index 9dd17f2847..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_qos_qos_policy.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_qos_qos_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_qos_qos_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_qos_qos_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_qos_policy': {
- 'default_cos': '3',
- 'name': 'default_name_4',
- 'queue_policy': 'test_value_5',
- 'trust_dot1p_map': 'test_value_6',
- 'trust_ip_dscp_map': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_qos_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'default-cos': '3',
- 'name': 'default_name_4',
- 'queue-policy': 'test_value_5',
- 'trust-dot1p-map': 'test_value_6',
- 'trust-ip-dscp-map': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'qos-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_qos_qos_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_qos_policy': {
- 'default_cos': '3',
- 'name': 'default_name_4',
- 'queue_policy': 'test_value_5',
- 'trust_dot1p_map': 'test_value_6',
- 'trust_ip_dscp_map': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_qos_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'default-cos': '3',
- 'name': 'default_name_4',
- 'queue-policy': 'test_value_5',
- 'trust-dot1p-map': 'test_value_6',
- 'trust-ip-dscp-map': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'qos-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_qos_qos_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_qos_qos_policy': {
- 'default_cos': '3',
- 'name': 'default_name_4',
- 'queue_policy': 'test_value_5',
- 'trust_dot1p_map': 'test_value_6',
- 'trust_ip_dscp_map': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_qos_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.qos', 'qos-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_qos_qos_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_qos_qos_policy': {
- 'default_cos': '3',
- 'name': 'default_name_4',
- 'queue_policy': 'test_value_5',
- 'trust_dot1p_map': 'test_value_6',
- 'trust_ip_dscp_map': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_qos_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.qos', 'qos-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_qos_qos_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_qos_policy': {
- 'default_cos': '3',
- 'name': 'default_name_4',
- 'queue_policy': 'test_value_5',
- 'trust_dot1p_map': 'test_value_6',
- 'trust_ip_dscp_map': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_qos_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'default-cos': '3',
- 'name': 'default_name_4',
- 'queue-policy': 'test_value_5',
- 'trust-dot1p-map': 'test_value_6',
- 'trust-ip-dscp-map': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'qos-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_qos_qos_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_qos_policy': {
- 'random_attribute_not_valid': 'tag',
- 'default_cos': '3',
- 'name': 'default_name_4',
- 'queue_policy': 'test_value_5',
- 'trust_dot1p_map': 'test_value_6',
- 'trust_ip_dscp_map': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_qos_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {
- 'default-cos': '3',
- 'name': 'default_name_4',
- 'queue-policy': 'test_value_5',
- 'trust-dot1p-map': 'test_value_6',
- 'trust-ip-dscp-map': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'qos-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_qos_queue_policy.py b/test/units/modules/network/fortios/test_fortios_switch_controller_qos_queue_policy.py
deleted file mode 100644
index 4d20239644..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_qos_queue_policy.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_qos_queue_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_qos_queue_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_qos_queue_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_queue_policy': {'name': 'default_name_3',
- 'schedule': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_queue_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'schedule': 'strict'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'queue-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_qos_queue_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_queue_policy': {'name': 'default_name_3',
- 'schedule': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_queue_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'schedule': 'strict'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'queue-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_qos_queue_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_qos_queue_policy': {'name': 'default_name_3',
- 'schedule': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_queue_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.qos', 'queue-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_qos_queue_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_qos_queue_policy': {'name': 'default_name_3',
- 'schedule': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_queue_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.qos', 'queue-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_qos_queue_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_queue_policy': {'name': 'default_name_3',
- 'schedule': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_queue_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'schedule': 'strict'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'queue-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_qos_queue_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_qos_queue_policy': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3',
- 'schedule': 'strict'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_qos_queue_policy.fortios_switch_controller_qos(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'schedule': 'strict'
- }
-
- set_method_mock.assert_called_with('switch-controller.qos', 'queue-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_quarantine.py b/test/units/modules/network/fortios/test_fortios_switch_controller_quarantine.py
deleted file mode 100644
index c40bcec36c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_quarantine.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_quarantine
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_quarantine.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_quarantine_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_quarantine': {
- 'quarantine': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_quarantine.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'quarantine': 'enable',
-
- }
-
- set_method_mock.assert_called_with('switch-controller', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_quarantine_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_quarantine': {
- 'quarantine': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_quarantine.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'quarantine': 'enable',
-
- }
-
- set_method_mock.assert_called_with('switch-controller', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_quarantine_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_quarantine': {
- 'quarantine': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_quarantine.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'quarantine': 'enable',
-
- }
-
- set_method_mock.assert_called_with('switch-controller', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_quarantine_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_quarantine': {
- 'random_attribute_not_valid': 'tag',
- 'quarantine': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_quarantine.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'quarantine': 'enable',
-
- }
-
- set_method_mock.assert_called_with('switch-controller', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_security_policy_802_1X.py b/test/units/modules/network/fortios/test_fortios_switch_controller_security_policy_802_1X.py
deleted file mode 100644
index a2c91c49c4..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_security_policy_802_1X.py
+++ /dev/null
@@ -1,339 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_security_policy_802_1X
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_security_policy_802_1X.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_security_policy_802_1X_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_security_policy_802_1X': {
- 'auth_fail_vlan': 'disable',
- 'auth_fail_vlan_id': 'test_value_4',
- 'auth_fail_vlanid': '5',
- 'eap_passthru': 'disable',
- 'guest_auth_delay': '7',
- 'guest_vlan': 'disable',
- 'guest_vlan_id': 'test_value_9',
- 'guest_vlanid': '10',
- 'mac_auth_bypass': 'disable',
- 'name': 'default_name_12',
- 'open_auth': 'disable',
- 'policy_type': '802.1X',
- 'radius_timeout_overwrite': 'disable',
- 'security_mode': '802.1X',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_802_1X.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- expected_data = {
- 'auth-fail-vlan': 'disable',
- 'auth-fail-vlan-id': 'test_value_4',
- 'auth-fail-vlanid': '5',
- 'eap-passthru': 'disable',
- 'guest-auth-delay': '7',
- 'guest-vlan': 'disable',
- 'guest-vlan-id': 'test_value_9',
- 'guest-vlanid': '10',
- 'mac-auth-bypass': 'disable',
- 'name': 'default_name_12',
- 'open-auth': 'disable',
- 'policy-type': '802.1X',
- 'radius-timeout-overwrite': 'disable',
- 'security-mode': '802.1X',
-
- }
-
- set_method_mock.assert_called_with('switch-controller.security-policy', '802-1X', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_security_policy_802_1X_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_security_policy_802_1X': {
- 'auth_fail_vlan': 'disable',
- 'auth_fail_vlan_id': 'test_value_4',
- 'auth_fail_vlanid': '5',
- 'eap_passthru': 'disable',
- 'guest_auth_delay': '7',
- 'guest_vlan': 'disable',
- 'guest_vlan_id': 'test_value_9',
- 'guest_vlanid': '10',
- 'mac_auth_bypass': 'disable',
- 'name': 'default_name_12',
- 'open_auth': 'disable',
- 'policy_type': '802.1X',
- 'radius_timeout_overwrite': 'disable',
- 'security_mode': '802.1X',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_802_1X.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- expected_data = {
- 'auth-fail-vlan': 'disable',
- 'auth-fail-vlan-id': 'test_value_4',
- 'auth-fail-vlanid': '5',
- 'eap-passthru': 'disable',
- 'guest-auth-delay': '7',
- 'guest-vlan': 'disable',
- 'guest-vlan-id': 'test_value_9',
- 'guest-vlanid': '10',
- 'mac-auth-bypass': 'disable',
- 'name': 'default_name_12',
- 'open-auth': 'disable',
- 'policy-type': '802.1X',
- 'radius-timeout-overwrite': 'disable',
- 'security-mode': '802.1X',
-
- }
-
- set_method_mock.assert_called_with('switch-controller.security-policy', '802-1X', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_security_policy_802_1X_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_security_policy_802_1X': {
- 'auth_fail_vlan': 'disable',
- 'auth_fail_vlan_id': 'test_value_4',
- 'auth_fail_vlanid': '5',
- 'eap_passthru': 'disable',
- 'guest_auth_delay': '7',
- 'guest_vlan': 'disable',
- 'guest_vlan_id': 'test_value_9',
- 'guest_vlanid': '10',
- 'mac_auth_bypass': 'disable',
- 'name': 'default_name_12',
- 'open_auth': 'disable',
- 'policy_type': '802.1X',
- 'radius_timeout_overwrite': 'disable',
- 'security_mode': '802.1X',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_802_1X.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.security-policy', '802-1X', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_security_policy_802_1X_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_security_policy_802_1X': {
- 'auth_fail_vlan': 'disable',
- 'auth_fail_vlan_id': 'test_value_4',
- 'auth_fail_vlanid': '5',
- 'eap_passthru': 'disable',
- 'guest_auth_delay': '7',
- 'guest_vlan': 'disable',
- 'guest_vlan_id': 'test_value_9',
- 'guest_vlanid': '10',
- 'mac_auth_bypass': 'disable',
- 'name': 'default_name_12',
- 'open_auth': 'disable',
- 'policy_type': '802.1X',
- 'radius_timeout_overwrite': 'disable',
- 'security_mode': '802.1X',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_802_1X.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.security-policy', '802-1X', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_security_policy_802_1X_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_security_policy_802_1X': {
- 'auth_fail_vlan': 'disable',
- 'auth_fail_vlan_id': 'test_value_4',
- 'auth_fail_vlanid': '5',
- 'eap_passthru': 'disable',
- 'guest_auth_delay': '7',
- 'guest_vlan': 'disable',
- 'guest_vlan_id': 'test_value_9',
- 'guest_vlanid': '10',
- 'mac_auth_bypass': 'disable',
- 'name': 'default_name_12',
- 'open_auth': 'disable',
- 'policy_type': '802.1X',
- 'radius_timeout_overwrite': 'disable',
- 'security_mode': '802.1X',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_802_1X.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- expected_data = {
- 'auth-fail-vlan': 'disable',
- 'auth-fail-vlan-id': 'test_value_4',
- 'auth-fail-vlanid': '5',
- 'eap-passthru': 'disable',
- 'guest-auth-delay': '7',
- 'guest-vlan': 'disable',
- 'guest-vlan-id': 'test_value_9',
- 'guest-vlanid': '10',
- 'mac-auth-bypass': 'disable',
- 'name': 'default_name_12',
- 'open-auth': 'disable',
- 'policy-type': '802.1X',
- 'radius-timeout-overwrite': 'disable',
- 'security-mode': '802.1X',
-
- }
-
- set_method_mock.assert_called_with('switch-controller.security-policy', '802-1X', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_security_policy_802_1X_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_security_policy_802_1X': {
- 'random_attribute_not_valid': 'tag',
- 'auth_fail_vlan': 'disable',
- 'auth_fail_vlan_id': 'test_value_4',
- 'auth_fail_vlanid': '5',
- 'eap_passthru': 'disable',
- 'guest_auth_delay': '7',
- 'guest_vlan': 'disable',
- 'guest_vlan_id': 'test_value_9',
- 'guest_vlanid': '10',
- 'mac_auth_bypass': 'disable',
- 'name': 'default_name_12',
- 'open_auth': 'disable',
- 'policy_type': '802.1X',
- 'radius_timeout_overwrite': 'disable',
- 'security_mode': '802.1X',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_802_1X.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- expected_data = {
- 'auth-fail-vlan': 'disable',
- 'auth-fail-vlan-id': 'test_value_4',
- 'auth-fail-vlanid': '5',
- 'eap-passthru': 'disable',
- 'guest-auth-delay': '7',
- 'guest-vlan': 'disable',
- 'guest-vlan-id': 'test_value_9',
- 'guest-vlanid': '10',
- 'mac-auth-bypass': 'disable',
- 'name': 'default_name_12',
- 'open-auth': 'disable',
- 'policy-type': '802.1X',
- 'radius-timeout-overwrite': 'disable',
- 'security-mode': '802.1X',
-
- }
-
- set_method_mock.assert_called_with('switch-controller.security-policy', '802-1X', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_security_policy_captive_portal.py b/test/units/modules/network/fortios/test_fortios_switch_controller_security_policy_captive_portal.py
deleted file mode 100644
index e1ff460624..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_security_policy_captive_portal.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_security_policy_captive_portal
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_security_policy_captive_portal.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_security_policy_captive_portal_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_security_policy_captive_portal': {
- 'name': 'default_name_3',
- 'policy_type': 'captive-portal',
- 'vlan': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_captive_portal.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'policy-type': 'captive-portal',
- 'vlan': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('switch-controller.security-policy', 'captive-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_security_policy_captive_portal_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_security_policy_captive_portal': {
- 'name': 'default_name_3',
- 'policy_type': 'captive-portal',
- 'vlan': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_captive_portal.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'policy-type': 'captive-portal',
- 'vlan': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('switch-controller.security-policy', 'captive-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_security_policy_captive_portal_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_security_policy_captive_portal': {
- 'name': 'default_name_3',
- 'policy_type': 'captive-portal',
- 'vlan': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_captive_portal.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.security-policy', 'captive-portal', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_security_policy_captive_portal_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_security_policy_captive_portal': {
- 'name': 'default_name_3',
- 'policy_type': 'captive-portal',
- 'vlan': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_captive_portal.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller.security-policy', 'captive-portal', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_security_policy_captive_portal_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_security_policy_captive_portal': {
- 'name': 'default_name_3',
- 'policy_type': 'captive-portal',
- 'vlan': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_captive_portal.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'policy-type': 'captive-portal',
- 'vlan': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('switch-controller.security-policy', 'captive-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_security_policy_captive_portal_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_security_policy_captive_portal': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
- 'policy_type': 'captive-portal',
- 'vlan': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_security_policy_captive_portal.fortios_switch_controller_security_policy(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'policy-type': 'captive-portal',
- 'vlan': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('switch-controller.security-policy', 'captive-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_sflow.py b/test/units/modules/network/fortios/test_fortios_switch_controller_sflow.py
deleted file mode 100644
index 85b1edb4c8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_sflow.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_sflow
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_sflow.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_sflow_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_sflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_sflow.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_sflow_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_sflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_sflow.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_sflow_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_sflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_sflow.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_sflow_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_sflow': {
- 'random_attribute_not_valid': 'tag',
- 'collector_ip': 'test_value_3',
- 'collector_port': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_sflow.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_storm_control.py b/test/units/modules/network/fortios/test_fortios_switch_controller_storm_control.py
deleted file mode 100644
index 76d92c9dcb..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_storm_control.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_storm_control
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_storm_control.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_storm_control_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_storm_control': {
- 'broadcast': 'enable',
- 'rate': '4',
- 'unknown_multicast': 'enable',
- 'unknown_unicast': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_storm_control.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'broadcast': 'enable',
- 'rate': '4',
- 'unknown-multicast': 'enable',
- 'unknown-unicast': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'storm-control', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_storm_control_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_storm_control': {
- 'broadcast': 'enable',
- 'rate': '4',
- 'unknown_multicast': 'enable',
- 'unknown_unicast': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_storm_control.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'broadcast': 'enable',
- 'rate': '4',
- 'unknown-multicast': 'enable',
- 'unknown-unicast': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'storm-control', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_storm_control_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_storm_control': {
- 'broadcast': 'enable',
- 'rate': '4',
- 'unknown_multicast': 'enable',
- 'unknown_unicast': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_storm_control.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'broadcast': 'enable',
- 'rate': '4',
- 'unknown-multicast': 'enable',
- 'unknown-unicast': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'storm-control', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_storm_control_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_storm_control': {
- 'random_attribute_not_valid': 'tag',
- 'broadcast': 'enable',
- 'rate': '4',
- 'unknown_multicast': 'enable',
- 'unknown_unicast': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_storm_control.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'broadcast': 'enable',
- 'rate': '4',
- 'unknown-multicast': 'enable',
- 'unknown-unicast': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'storm-control', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_stp_settings.py b/test/units/modules/network/fortios/test_fortios_switch_controller_stp_settings.py
deleted file mode 100644
index 9b2a28c609..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_stp_settings.py
+++ /dev/null
@@ -1,207 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_stp_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_stp_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_stp_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_stp_settings': {
- 'forward_time': '3',
- 'hello_time': '4',
- 'max_age': '5',
- 'max_hops': '6',
- 'name': 'default_name_7',
- 'pending_timer': '8',
- 'revision': '9',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_stp_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'forward-time': '3',
- 'hello-time': '4',
- 'max-age': '5',
- 'max-hops': '6',
- 'name': 'default_name_7',
- 'pending-timer': '8',
- 'revision': '9',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'stp-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_stp_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_stp_settings': {
- 'forward_time': '3',
- 'hello_time': '4',
- 'max_age': '5',
- 'max_hops': '6',
- 'name': 'default_name_7',
- 'pending_timer': '8',
- 'revision': '9',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_stp_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'forward-time': '3',
- 'hello-time': '4',
- 'max-age': '5',
- 'max-hops': '6',
- 'name': 'default_name_7',
- 'pending-timer': '8',
- 'revision': '9',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'stp-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_stp_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_stp_settings': {
- 'forward_time': '3',
- 'hello_time': '4',
- 'max_age': '5',
- 'max_hops': '6',
- 'name': 'default_name_7',
- 'pending_timer': '8',
- 'revision': '9',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_stp_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'forward-time': '3',
- 'hello-time': '4',
- 'max-age': '5',
- 'max-hops': '6',
- 'name': 'default_name_7',
- 'pending-timer': '8',
- 'revision': '9',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'stp-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_stp_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_stp_settings': {
- 'random_attribute_not_valid': 'tag',
- 'forward_time': '3',
- 'hello_time': '4',
- 'max_age': '5',
- 'max_hops': '6',
- 'name': 'default_name_7',
- 'pending_timer': '8',
- 'revision': '9',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_stp_settings.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'forward-time': '3',
- 'hello-time': '4',
- 'max-age': '5',
- 'max-hops': '6',
- 'name': 'default_name_7',
- 'pending-timer': '8',
- 'revision': '9',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'stp-settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_switch_group.py b/test/units/modules/network/fortios/test_fortios_switch_controller_switch_group.py
deleted file mode 100644
index 226d71cefa..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_switch_group.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_switch_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_switch_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_switch_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_group': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_group.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_switch_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_group': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_group.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_switch_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_switch_group': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_group.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'switch-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_switch_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_switch_group': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_group.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'switch-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_switch_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_group': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_group.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_switch_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_group': {
- 'random_attribute_not_valid': 'tag',
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_group.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_switch_interface_tag.py b/test/units/modules/network/fortios/test_fortios_switch_controller_switch_interface_tag.py
deleted file mode 100644
index 1a234ad9a0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_switch_interface_tag.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_switch_interface_tag
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_switch_interface_tag.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_switch_interface_tag_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_interface_tag': {
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_interface_tag.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-interface-tag', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_switch_interface_tag_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_interface_tag': {
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_interface_tag.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-interface-tag', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_switch_interface_tag_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_switch_interface_tag': {
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_interface_tag.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'switch-interface-tag', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_switch_interface_tag_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_switch_interface_tag': {
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_interface_tag.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'switch-interface-tag', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_switch_interface_tag_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_interface_tag': {
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_interface_tag.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-interface-tag', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_switch_interface_tag_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_interface_tag': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_interface_tag.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-interface-tag', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_switch_log.py b/test/units/modules/network/fortios/test_fortios_switch_controller_switch_log.py
deleted file mode 100644
index 543fa0a9d7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_switch_log.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_switch_log
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_switch_log.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_switch_log_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_log': {
- 'severity': 'emergency',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_log.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'severity': 'emergency',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-log', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_switch_log_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_log': {
- 'severity': 'emergency',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_log.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'severity': 'emergency',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-log', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_switch_log_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_log': {
- 'severity': 'emergency',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_log.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'severity': 'emergency',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-log', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_switch_log_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_log': {
- 'random_attribute_not_valid': 'tag',
- 'severity': 'emergency',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_log.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'severity': 'emergency',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-log', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_switch_profile.py b/test/units/modules/network/fortios/test_fortios_switch_controller_switch_profile.py
deleted file mode 100644
index 5704b55d66..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_switch_profile.py
+++ /dev/null
@@ -1,217 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_switch_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_switch_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_switch_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_profile': {
- 'login_passwd': 'test_value_3',
- 'login_passwd_override': 'enable',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_profile.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'login-passwd': 'test_value_3',
- 'login-passwd-override': 'enable',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_switch_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_profile': {
- 'login_passwd': 'test_value_3',
- 'login_passwd_override': 'enable',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_profile.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'login-passwd': 'test_value_3',
- 'login-passwd-override': 'enable',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_switch_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_switch_profile': {
- 'login_passwd': 'test_value_3',
- 'login_passwd_override': 'enable',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_profile.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'switch-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_switch_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_switch_profile': {
- 'login_passwd': 'test_value_3',
- 'login_passwd_override': 'enable',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_profile.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'switch-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_switch_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_profile': {
- 'login_passwd': 'test_value_3',
- 'login_passwd_override': 'enable',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_profile.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'login-passwd': 'test_value_3',
- 'login-passwd-override': 'enable',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_switch_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_switch_profile': {
- 'random_attribute_not_valid': 'tag',
- 'login_passwd': 'test_value_3',
- 'login_passwd_override': 'enable',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_switch_profile.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'login-passwd': 'test_value_3',
- 'login-passwd-override': 'enable',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'switch-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_system.py b/test/units/modules/network/fortios/test_fortios_switch_controller_system.py
deleted file mode 100644
index 2f14a259f5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_system.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_system
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_system.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_system_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_system': {
- 'parallel_process': '3',
- 'parallel_process_override': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_system.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'parallel-process': '3',
- 'parallel-process-override': 'disable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'system', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_system_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_system': {
- 'parallel_process': '3',
- 'parallel_process_override': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_system.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'parallel-process': '3',
- 'parallel-process-override': 'disable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'system', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_system_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_system': {
- 'parallel_process': '3',
- 'parallel_process_override': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_system.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'parallel-process': '3',
- 'parallel-process-override': 'disable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'system', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_system_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_system': {
- 'random_attribute_not_valid': 'tag',
- 'parallel_process': '3',
- 'parallel_process_override': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_system.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'parallel-process': '3',
- 'parallel-process-override': 'disable'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'system', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_virtual_port_pool.py b/test/units/modules/network/fortios/test_fortios_switch_controller_virtual_port_pool.py
deleted file mode 100644
index 175c27aa18..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_virtual_port_pool.py
+++ /dev/null
@@ -1,207 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_virtual_port_pool
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_virtual_port_pool.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_virtual_port_pool_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_virtual_port_pool': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_virtual_port_pool.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'virtual-port-pool', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_virtual_port_pool_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_virtual_port_pool': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_virtual_port_pool.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'virtual-port-pool', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_virtual_port_pool_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_virtual_port_pool': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_virtual_port_pool.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'virtual-port-pool', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_virtual_port_pool_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_virtual_port_pool': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_virtual_port_pool.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'virtual-port-pool', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_virtual_port_pool_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_virtual_port_pool': {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_virtual_port_pool.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'virtual-port-pool', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_virtual_port_pool_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_virtual_port_pool': {
- 'random_attribute_not_valid': 'tag',
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_virtual_port_pool.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'virtual-port-pool', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_switch_controller_vlan.py b/test/units/modules/network/fortios/test_fortios_switch_controller_vlan.py
deleted file mode 100644
index 695e15a101..0000000000
--- a/test/units/modules/network/fortios/test_fortios_switch_controller_vlan.py
+++ /dev/null
@@ -1,287 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_switch_controller_vlan
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_switch_controller_vlan.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_switch_controller_vlan_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_vlan': {
- 'auth': 'radius',
- 'color': '4',
- 'comments': 'test_value_5',
- 'name': 'default_name_6',
- 'portal_message_override_group': 'test_value_7',
- 'radius_server': 'test_value_8',
- 'security': 'open',
- 'usergroup': 'test_value_10',
- 'vdom': 'test_value_11',
- 'vlanid': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'auth': 'radius',
- 'color': '4',
- 'comments': 'test_value_5',
- 'name': 'default_name_6',
- 'portal-message-override-group': 'test_value_7',
- 'radius-server': 'test_value_8',
- 'security': 'open',
- 'usergroup': 'test_value_10',
- 'vdom': 'test_value_11',
- 'vlanid': '12'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'vlan', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_vlan_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_vlan': {
- 'auth': 'radius',
- 'color': '4',
- 'comments': 'test_value_5',
- 'name': 'default_name_6',
- 'portal_message_override_group': 'test_value_7',
- 'radius_server': 'test_value_8',
- 'security': 'open',
- 'usergroup': 'test_value_10',
- 'vdom': 'test_value_11',
- 'vlanid': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'auth': 'radius',
- 'color': '4',
- 'comments': 'test_value_5',
- 'name': 'default_name_6',
- 'portal-message-override-group': 'test_value_7',
- 'radius-server': 'test_value_8',
- 'security': 'open',
- 'usergroup': 'test_value_10',
- 'vdom': 'test_value_11',
- 'vlanid': '12'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'vlan', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_vlan_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_vlan': {
- 'auth': 'radius',
- 'color': '4',
- 'comments': 'test_value_5',
- 'name': 'default_name_6',
- 'portal_message_override_group': 'test_value_7',
- 'radius_server': 'test_value_8',
- 'security': 'open',
- 'usergroup': 'test_value_10',
- 'vdom': 'test_value_11',
- 'vlanid': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'vlan', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_switch_controller_vlan_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'switch_controller_vlan': {
- 'auth': 'radius',
- 'color': '4',
- 'comments': 'test_value_5',
- 'name': 'default_name_6',
- 'portal_message_override_group': 'test_value_7',
- 'radius_server': 'test_value_8',
- 'security': 'open',
- 'usergroup': 'test_value_10',
- 'vdom': 'test_value_11',
- 'vlanid': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('switch-controller', 'vlan', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_switch_controller_vlan_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_vlan': {
- 'auth': 'radius',
- 'color': '4',
- 'comments': 'test_value_5',
- 'name': 'default_name_6',
- 'portal_message_override_group': 'test_value_7',
- 'radius_server': 'test_value_8',
- 'security': 'open',
- 'usergroup': 'test_value_10',
- 'vdom': 'test_value_11',
- 'vlanid': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'auth': 'radius',
- 'color': '4',
- 'comments': 'test_value_5',
- 'name': 'default_name_6',
- 'portal-message-override-group': 'test_value_7',
- 'radius-server': 'test_value_8',
- 'security': 'open',
- 'usergroup': 'test_value_10',
- 'vdom': 'test_value_11',
- 'vlanid': '12'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'vlan', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_switch_controller_vlan_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'switch_controller_vlan': {
- 'random_attribute_not_valid': 'tag',
- 'auth': 'radius',
- 'color': '4',
- 'comments': 'test_value_5',
- 'name': 'default_name_6',
- 'portal_message_override_group': 'test_value_7',
- 'radius_server': 'test_value_8',
- 'security': 'open',
- 'usergroup': 'test_value_10',
- 'vdom': 'test_value_11',
- 'vlanid': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_switch_controller_vlan.fortios_switch_controller(input_data, fos_instance)
-
- expected_data = {
- 'auth': 'radius',
- 'color': '4',
- 'comments': 'test_value_5',
- 'name': 'default_name_6',
- 'portal-message-override-group': 'test_value_7',
- 'radius-server': 'test_value_8',
- 'security': 'open',
- 'usergroup': 'test_value_10',
- 'vdom': 'test_value_11',
- 'vlanid': '12'
- }
-
- set_method_mock.assert_called_with('switch-controller', 'vlan', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_accprofile.py b/test/units/modules/network/fortios/test_fortios_system_accprofile.py
deleted file mode 100644
index c0479fc614..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_accprofile.py
+++ /dev/null
@@ -1,349 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_accprofile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_accprofile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_accprofile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_accprofile': {
- 'admintimeout': '3',
- 'admintimeout_override': 'enable',
- 'authgrp': 'none',
- 'comments': 'test_value_6',
- 'ftviewgrp': 'none',
- 'fwgrp': 'none',
- 'loggrp': 'none',
- 'name': 'default_name_10',
- 'netgrp': 'none',
- 'scope': 'vdom',
- 'secfabgrp': 'none',
- 'sysgrp': 'none',
- 'utmgrp': 'none',
- 'vpngrp': 'none',
- 'wanoptgrp': 'none',
- 'wifi': 'none'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_accprofile.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'admintimeout': '3',
- 'admintimeout-override': 'enable',
- 'authgrp': 'none',
- 'comments': 'test_value_6',
- 'ftviewgrp': 'none',
- 'fwgrp': 'none',
- 'loggrp': 'none',
- 'name': 'default_name_10',
- 'netgrp': 'none',
- 'scope': 'vdom',
- 'secfabgrp': 'none',
- 'sysgrp': 'none',
- 'utmgrp': 'none',
- 'vpngrp': 'none',
- 'wanoptgrp': 'none',
- 'wifi': 'none'
- }
-
- set_method_mock.assert_called_with('system', 'accprofile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_accprofile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_accprofile': {
- 'admintimeout': '3',
- 'admintimeout_override': 'enable',
- 'authgrp': 'none',
- 'comments': 'test_value_6',
- 'ftviewgrp': 'none',
- 'fwgrp': 'none',
- 'loggrp': 'none',
- 'name': 'default_name_10',
- 'netgrp': 'none',
- 'scope': 'vdom',
- 'secfabgrp': 'none',
- 'sysgrp': 'none',
- 'utmgrp': 'none',
- 'vpngrp': 'none',
- 'wanoptgrp': 'none',
- 'wifi': 'none'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_accprofile.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'admintimeout': '3',
- 'admintimeout-override': 'enable',
- 'authgrp': 'none',
- 'comments': 'test_value_6',
- 'ftviewgrp': 'none',
- 'fwgrp': 'none',
- 'loggrp': 'none',
- 'name': 'default_name_10',
- 'netgrp': 'none',
- 'scope': 'vdom',
- 'secfabgrp': 'none',
- 'sysgrp': 'none',
- 'utmgrp': 'none',
- 'vpngrp': 'none',
- 'wanoptgrp': 'none',
- 'wifi': 'none'
- }
-
- set_method_mock.assert_called_with('system', 'accprofile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_accprofile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_accprofile': {
- 'admintimeout': '3',
- 'admintimeout_override': 'enable',
- 'authgrp': 'none',
- 'comments': 'test_value_6',
- 'ftviewgrp': 'none',
- 'fwgrp': 'none',
- 'loggrp': 'none',
- 'name': 'default_name_10',
- 'netgrp': 'none',
- 'scope': 'vdom',
- 'secfabgrp': 'none',
- 'sysgrp': 'none',
- 'utmgrp': 'none',
- 'vpngrp': 'none',
- 'wanoptgrp': 'none',
- 'wifi': 'none'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_accprofile.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'accprofile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_accprofile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_accprofile': {
- 'admintimeout': '3',
- 'admintimeout_override': 'enable',
- 'authgrp': 'none',
- 'comments': 'test_value_6',
- 'ftviewgrp': 'none',
- 'fwgrp': 'none',
- 'loggrp': 'none',
- 'name': 'default_name_10',
- 'netgrp': 'none',
- 'scope': 'vdom',
- 'secfabgrp': 'none',
- 'sysgrp': 'none',
- 'utmgrp': 'none',
- 'vpngrp': 'none',
- 'wanoptgrp': 'none',
- 'wifi': 'none'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_accprofile.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'accprofile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_accprofile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_accprofile': {
- 'admintimeout': '3',
- 'admintimeout_override': 'enable',
- 'authgrp': 'none',
- 'comments': 'test_value_6',
- 'ftviewgrp': 'none',
- 'fwgrp': 'none',
- 'loggrp': 'none',
- 'name': 'default_name_10',
- 'netgrp': 'none',
- 'scope': 'vdom',
- 'secfabgrp': 'none',
- 'sysgrp': 'none',
- 'utmgrp': 'none',
- 'vpngrp': 'none',
- 'wanoptgrp': 'none',
- 'wifi': 'none'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_accprofile.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'admintimeout': '3',
- 'admintimeout-override': 'enable',
- 'authgrp': 'none',
- 'comments': 'test_value_6',
- 'ftviewgrp': 'none',
- 'fwgrp': 'none',
- 'loggrp': 'none',
- 'name': 'default_name_10',
- 'netgrp': 'none',
- 'scope': 'vdom',
- 'secfabgrp': 'none',
- 'sysgrp': 'none',
- 'utmgrp': 'none',
- 'vpngrp': 'none',
- 'wanoptgrp': 'none',
- 'wifi': 'none'
- }
-
- set_method_mock.assert_called_with('system', 'accprofile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_accprofile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_accprofile': {
- 'random_attribute_not_valid': 'tag',
- 'admintimeout': '3',
- 'admintimeout_override': 'enable',
- 'authgrp': 'none',
- 'comments': 'test_value_6',
- 'ftviewgrp': 'none',
- 'fwgrp': 'none',
- 'loggrp': 'none',
- 'name': 'default_name_10',
- 'netgrp': 'none',
- 'scope': 'vdom',
- 'secfabgrp': 'none',
- 'sysgrp': 'none',
- 'utmgrp': 'none',
- 'vpngrp': 'none',
- 'wanoptgrp': 'none',
- 'wifi': 'none'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_accprofile.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'admintimeout': '3',
- 'admintimeout-override': 'enable',
- 'authgrp': 'none',
- 'comments': 'test_value_6',
- 'ftviewgrp': 'none',
- 'fwgrp': 'none',
- 'loggrp': 'none',
- 'name': 'default_name_10',
- 'netgrp': 'none',
- 'scope': 'vdom',
- 'secfabgrp': 'none',
- 'sysgrp': 'none',
- 'utmgrp': 'none',
- 'vpngrp': 'none',
- 'wanoptgrp': 'none',
- 'wifi': 'none'
- }
-
- set_method_mock.assert_called_with('system', 'accprofile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_admin.py b/test/units/modules/network/fortios/test_fortios_system_admin.py
deleted file mode 100644
index bf5445dcf5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_admin.py
+++ /dev/null
@@ -1,689 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_admin
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_admin.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_admin_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_admin': {
- 'accprofile': 'test_value_3',
- 'accprofile_override': 'enable',
- 'allow_remove_admin_session': 'enable',
- 'comments': 'test_value_6',
- 'email_to': 'test_value_7',
- 'force_password_change': 'enable',
- 'fortitoken': 'test_value_9',
- 'guest_auth': 'disable',
- 'guest_lang': 'test_value_11',
- 'hidden': '12',
- 'history0': 'test_value_13',
- 'history1': 'test_value_14',
- 'ip6_trusthost1': 'test_value_15',
- 'ip6_trusthost10': 'test_value_16',
- 'ip6_trusthost2': 'test_value_17',
- 'ip6_trusthost3': 'test_value_18',
- 'ip6_trusthost4': 'test_value_19',
- 'ip6_trusthost5': 'test_value_20',
- 'ip6_trusthost6': 'test_value_21',
- 'ip6_trusthost7': 'test_value_22',
- 'ip6_trusthost8': 'test_value_23',
- 'ip6_trusthost9': 'test_value_24',
- 'name': 'default_name_25',
- 'password': 'test_value_26',
- 'password_expire': 'test_value_27',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_29',
- 'radius_vdom_override': 'enable',
- 'remote_auth': 'enable',
- 'remote_group': 'test_value_32',
- 'schedule': 'test_value_33',
- 'sms_custom_server': 'test_value_34',
- 'sms_phone': 'test_value_35',
- 'sms_server': 'fortiguard',
- 'ssh_certificate': 'test_value_37',
- 'ssh_public_key1': 'test_value_38',
- 'ssh_public_key2': 'test_value_39',
- 'ssh_public_key3': 'test_value_40',
- 'trusthost1': 'test_value_41',
- 'trusthost10': 'test_value_42',
- 'trusthost2': 'test_value_43',
- 'trusthost3': 'test_value_44',
- 'trusthost4': 'test_value_45',
- 'trusthost5': 'test_value_46',
- 'trusthost6': 'test_value_47',
- 'trusthost7': 'test_value_48',
- 'trusthost8': 'test_value_49',
- 'trusthost9': 'test_value_50',
- 'two_factor': 'disable',
- 'wildcard': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_admin.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'accprofile': 'test_value_3',
- 'accprofile-override': 'enable',
- 'allow-remove-admin-session': 'enable',
- 'comments': 'test_value_6',
- 'email-to': 'test_value_7',
- 'force-password-change': 'enable',
- 'fortitoken': 'test_value_9',
- 'guest-auth': 'disable',
- 'guest-lang': 'test_value_11',
- 'hidden': '12',
- 'history0': 'test_value_13',
- 'history1': 'test_value_14',
- 'ip6-trusthost1': 'test_value_15',
- 'ip6-trusthost10': 'test_value_16',
- 'ip6-trusthost2': 'test_value_17',
- 'ip6-trusthost3': 'test_value_18',
- 'ip6-trusthost4': 'test_value_19',
- 'ip6-trusthost5': 'test_value_20',
- 'ip6-trusthost6': 'test_value_21',
- 'ip6-trusthost7': 'test_value_22',
- 'ip6-trusthost8': 'test_value_23',
- 'ip6-trusthost9': 'test_value_24',
- 'name': 'default_name_25',
- 'password': 'test_value_26',
- 'password-expire': 'test_value_27',
- 'peer-auth': 'enable',
- 'peer-group': 'test_value_29',
- 'radius-vdom-override': 'enable',
- 'remote-auth': 'enable',
- 'remote-group': 'test_value_32',
- 'schedule': 'test_value_33',
- 'sms-custom-server': 'test_value_34',
- 'sms-phone': 'test_value_35',
- 'sms-server': 'fortiguard',
- 'ssh-certificate': 'test_value_37',
- 'ssh-public-key1': 'test_value_38',
- 'ssh-public-key2': 'test_value_39',
- 'ssh-public-key3': 'test_value_40',
- 'trusthost1': 'test_value_41',
- 'trusthost10': 'test_value_42',
- 'trusthost2': 'test_value_43',
- 'trusthost3': 'test_value_44',
- 'trusthost4': 'test_value_45',
- 'trusthost5': 'test_value_46',
- 'trusthost6': 'test_value_47',
- 'trusthost7': 'test_value_48',
- 'trusthost8': 'test_value_49',
- 'trusthost9': 'test_value_50',
- 'two-factor': 'disable',
- 'wildcard': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_admin_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_admin': {
- 'accprofile': 'test_value_3',
- 'accprofile_override': 'enable',
- 'allow_remove_admin_session': 'enable',
- 'comments': 'test_value_6',
- 'email_to': 'test_value_7',
- 'force_password_change': 'enable',
- 'fortitoken': 'test_value_9',
- 'guest_auth': 'disable',
- 'guest_lang': 'test_value_11',
- 'hidden': '12',
- 'history0': 'test_value_13',
- 'history1': 'test_value_14',
- 'ip6_trusthost1': 'test_value_15',
- 'ip6_trusthost10': 'test_value_16',
- 'ip6_trusthost2': 'test_value_17',
- 'ip6_trusthost3': 'test_value_18',
- 'ip6_trusthost4': 'test_value_19',
- 'ip6_trusthost5': 'test_value_20',
- 'ip6_trusthost6': 'test_value_21',
- 'ip6_trusthost7': 'test_value_22',
- 'ip6_trusthost8': 'test_value_23',
- 'ip6_trusthost9': 'test_value_24',
- 'name': 'default_name_25',
- 'password': 'test_value_26',
- 'password_expire': 'test_value_27',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_29',
- 'radius_vdom_override': 'enable',
- 'remote_auth': 'enable',
- 'remote_group': 'test_value_32',
- 'schedule': 'test_value_33',
- 'sms_custom_server': 'test_value_34',
- 'sms_phone': 'test_value_35',
- 'sms_server': 'fortiguard',
- 'ssh_certificate': 'test_value_37',
- 'ssh_public_key1': 'test_value_38',
- 'ssh_public_key2': 'test_value_39',
- 'ssh_public_key3': 'test_value_40',
- 'trusthost1': 'test_value_41',
- 'trusthost10': 'test_value_42',
- 'trusthost2': 'test_value_43',
- 'trusthost3': 'test_value_44',
- 'trusthost4': 'test_value_45',
- 'trusthost5': 'test_value_46',
- 'trusthost6': 'test_value_47',
- 'trusthost7': 'test_value_48',
- 'trusthost8': 'test_value_49',
- 'trusthost9': 'test_value_50',
- 'two_factor': 'disable',
- 'wildcard': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_admin.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'accprofile': 'test_value_3',
- 'accprofile-override': 'enable',
- 'allow-remove-admin-session': 'enable',
- 'comments': 'test_value_6',
- 'email-to': 'test_value_7',
- 'force-password-change': 'enable',
- 'fortitoken': 'test_value_9',
- 'guest-auth': 'disable',
- 'guest-lang': 'test_value_11',
- 'hidden': '12',
- 'history0': 'test_value_13',
- 'history1': 'test_value_14',
- 'ip6-trusthost1': 'test_value_15',
- 'ip6-trusthost10': 'test_value_16',
- 'ip6-trusthost2': 'test_value_17',
- 'ip6-trusthost3': 'test_value_18',
- 'ip6-trusthost4': 'test_value_19',
- 'ip6-trusthost5': 'test_value_20',
- 'ip6-trusthost6': 'test_value_21',
- 'ip6-trusthost7': 'test_value_22',
- 'ip6-trusthost8': 'test_value_23',
- 'ip6-trusthost9': 'test_value_24',
- 'name': 'default_name_25',
- 'password': 'test_value_26',
- 'password-expire': 'test_value_27',
- 'peer-auth': 'enable',
- 'peer-group': 'test_value_29',
- 'radius-vdom-override': 'enable',
- 'remote-auth': 'enable',
- 'remote-group': 'test_value_32',
- 'schedule': 'test_value_33',
- 'sms-custom-server': 'test_value_34',
- 'sms-phone': 'test_value_35',
- 'sms-server': 'fortiguard',
- 'ssh-certificate': 'test_value_37',
- 'ssh-public-key1': 'test_value_38',
- 'ssh-public-key2': 'test_value_39',
- 'ssh-public-key3': 'test_value_40',
- 'trusthost1': 'test_value_41',
- 'trusthost10': 'test_value_42',
- 'trusthost2': 'test_value_43',
- 'trusthost3': 'test_value_44',
- 'trusthost4': 'test_value_45',
- 'trusthost5': 'test_value_46',
- 'trusthost6': 'test_value_47',
- 'trusthost7': 'test_value_48',
- 'trusthost8': 'test_value_49',
- 'trusthost9': 'test_value_50',
- 'two-factor': 'disable',
- 'wildcard': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_admin_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_admin': {
- 'accprofile': 'test_value_3',
- 'accprofile_override': 'enable',
- 'allow_remove_admin_session': 'enable',
- 'comments': 'test_value_6',
- 'email_to': 'test_value_7',
- 'force_password_change': 'enable',
- 'fortitoken': 'test_value_9',
- 'guest_auth': 'disable',
- 'guest_lang': 'test_value_11',
- 'hidden': '12',
- 'history0': 'test_value_13',
- 'history1': 'test_value_14',
- 'ip6_trusthost1': 'test_value_15',
- 'ip6_trusthost10': 'test_value_16',
- 'ip6_trusthost2': 'test_value_17',
- 'ip6_trusthost3': 'test_value_18',
- 'ip6_trusthost4': 'test_value_19',
- 'ip6_trusthost5': 'test_value_20',
- 'ip6_trusthost6': 'test_value_21',
- 'ip6_trusthost7': 'test_value_22',
- 'ip6_trusthost8': 'test_value_23',
- 'ip6_trusthost9': 'test_value_24',
- 'name': 'default_name_25',
- 'password': 'test_value_26',
- 'password_expire': 'test_value_27',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_29',
- 'radius_vdom_override': 'enable',
- 'remote_auth': 'enable',
- 'remote_group': 'test_value_32',
- 'schedule': 'test_value_33',
- 'sms_custom_server': 'test_value_34',
- 'sms_phone': 'test_value_35',
- 'sms_server': 'fortiguard',
- 'ssh_certificate': 'test_value_37',
- 'ssh_public_key1': 'test_value_38',
- 'ssh_public_key2': 'test_value_39',
- 'ssh_public_key3': 'test_value_40',
- 'trusthost1': 'test_value_41',
- 'trusthost10': 'test_value_42',
- 'trusthost2': 'test_value_43',
- 'trusthost3': 'test_value_44',
- 'trusthost4': 'test_value_45',
- 'trusthost5': 'test_value_46',
- 'trusthost6': 'test_value_47',
- 'trusthost7': 'test_value_48',
- 'trusthost8': 'test_value_49',
- 'trusthost9': 'test_value_50',
- 'two_factor': 'disable',
- 'wildcard': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_admin.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'admin', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_admin_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_admin': {
- 'accprofile': 'test_value_3',
- 'accprofile_override': 'enable',
- 'allow_remove_admin_session': 'enable',
- 'comments': 'test_value_6',
- 'email_to': 'test_value_7',
- 'force_password_change': 'enable',
- 'fortitoken': 'test_value_9',
- 'guest_auth': 'disable',
- 'guest_lang': 'test_value_11',
- 'hidden': '12',
- 'history0': 'test_value_13',
- 'history1': 'test_value_14',
- 'ip6_trusthost1': 'test_value_15',
- 'ip6_trusthost10': 'test_value_16',
- 'ip6_trusthost2': 'test_value_17',
- 'ip6_trusthost3': 'test_value_18',
- 'ip6_trusthost4': 'test_value_19',
- 'ip6_trusthost5': 'test_value_20',
- 'ip6_trusthost6': 'test_value_21',
- 'ip6_trusthost7': 'test_value_22',
- 'ip6_trusthost8': 'test_value_23',
- 'ip6_trusthost9': 'test_value_24',
- 'name': 'default_name_25',
- 'password': 'test_value_26',
- 'password_expire': 'test_value_27',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_29',
- 'radius_vdom_override': 'enable',
- 'remote_auth': 'enable',
- 'remote_group': 'test_value_32',
- 'schedule': 'test_value_33',
- 'sms_custom_server': 'test_value_34',
- 'sms_phone': 'test_value_35',
- 'sms_server': 'fortiguard',
- 'ssh_certificate': 'test_value_37',
- 'ssh_public_key1': 'test_value_38',
- 'ssh_public_key2': 'test_value_39',
- 'ssh_public_key3': 'test_value_40',
- 'trusthost1': 'test_value_41',
- 'trusthost10': 'test_value_42',
- 'trusthost2': 'test_value_43',
- 'trusthost3': 'test_value_44',
- 'trusthost4': 'test_value_45',
- 'trusthost5': 'test_value_46',
- 'trusthost6': 'test_value_47',
- 'trusthost7': 'test_value_48',
- 'trusthost8': 'test_value_49',
- 'trusthost9': 'test_value_50',
- 'two_factor': 'disable',
- 'wildcard': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_admin.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'admin', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_admin_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_admin': {
- 'accprofile': 'test_value_3',
- 'accprofile_override': 'enable',
- 'allow_remove_admin_session': 'enable',
- 'comments': 'test_value_6',
- 'email_to': 'test_value_7',
- 'force_password_change': 'enable',
- 'fortitoken': 'test_value_9',
- 'guest_auth': 'disable',
- 'guest_lang': 'test_value_11',
- 'hidden': '12',
- 'history0': 'test_value_13',
- 'history1': 'test_value_14',
- 'ip6_trusthost1': 'test_value_15',
- 'ip6_trusthost10': 'test_value_16',
- 'ip6_trusthost2': 'test_value_17',
- 'ip6_trusthost3': 'test_value_18',
- 'ip6_trusthost4': 'test_value_19',
- 'ip6_trusthost5': 'test_value_20',
- 'ip6_trusthost6': 'test_value_21',
- 'ip6_trusthost7': 'test_value_22',
- 'ip6_trusthost8': 'test_value_23',
- 'ip6_trusthost9': 'test_value_24',
- 'name': 'default_name_25',
- 'password': 'test_value_26',
- 'password_expire': 'test_value_27',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_29',
- 'radius_vdom_override': 'enable',
- 'remote_auth': 'enable',
- 'remote_group': 'test_value_32',
- 'schedule': 'test_value_33',
- 'sms_custom_server': 'test_value_34',
- 'sms_phone': 'test_value_35',
- 'sms_server': 'fortiguard',
- 'ssh_certificate': 'test_value_37',
- 'ssh_public_key1': 'test_value_38',
- 'ssh_public_key2': 'test_value_39',
- 'ssh_public_key3': 'test_value_40',
- 'trusthost1': 'test_value_41',
- 'trusthost10': 'test_value_42',
- 'trusthost2': 'test_value_43',
- 'trusthost3': 'test_value_44',
- 'trusthost4': 'test_value_45',
- 'trusthost5': 'test_value_46',
- 'trusthost6': 'test_value_47',
- 'trusthost7': 'test_value_48',
- 'trusthost8': 'test_value_49',
- 'trusthost9': 'test_value_50',
- 'two_factor': 'disable',
- 'wildcard': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_admin.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'accprofile': 'test_value_3',
- 'accprofile-override': 'enable',
- 'allow-remove-admin-session': 'enable',
- 'comments': 'test_value_6',
- 'email-to': 'test_value_7',
- 'force-password-change': 'enable',
- 'fortitoken': 'test_value_9',
- 'guest-auth': 'disable',
- 'guest-lang': 'test_value_11',
- 'hidden': '12',
- 'history0': 'test_value_13',
- 'history1': 'test_value_14',
- 'ip6-trusthost1': 'test_value_15',
- 'ip6-trusthost10': 'test_value_16',
- 'ip6-trusthost2': 'test_value_17',
- 'ip6-trusthost3': 'test_value_18',
- 'ip6-trusthost4': 'test_value_19',
- 'ip6-trusthost5': 'test_value_20',
- 'ip6-trusthost6': 'test_value_21',
- 'ip6-trusthost7': 'test_value_22',
- 'ip6-trusthost8': 'test_value_23',
- 'ip6-trusthost9': 'test_value_24',
- 'name': 'default_name_25',
- 'password': 'test_value_26',
- 'password-expire': 'test_value_27',
- 'peer-auth': 'enable',
- 'peer-group': 'test_value_29',
- 'radius-vdom-override': 'enable',
- 'remote-auth': 'enable',
- 'remote-group': 'test_value_32',
- 'schedule': 'test_value_33',
- 'sms-custom-server': 'test_value_34',
- 'sms-phone': 'test_value_35',
- 'sms-server': 'fortiguard',
- 'ssh-certificate': 'test_value_37',
- 'ssh-public-key1': 'test_value_38',
- 'ssh-public-key2': 'test_value_39',
- 'ssh-public-key3': 'test_value_40',
- 'trusthost1': 'test_value_41',
- 'trusthost10': 'test_value_42',
- 'trusthost2': 'test_value_43',
- 'trusthost3': 'test_value_44',
- 'trusthost4': 'test_value_45',
- 'trusthost5': 'test_value_46',
- 'trusthost6': 'test_value_47',
- 'trusthost7': 'test_value_48',
- 'trusthost8': 'test_value_49',
- 'trusthost9': 'test_value_50',
- 'two-factor': 'disable',
- 'wildcard': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_admin_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_admin': {
- 'random_attribute_not_valid': 'tag',
- 'accprofile': 'test_value_3',
- 'accprofile_override': 'enable',
- 'allow_remove_admin_session': 'enable',
- 'comments': 'test_value_6',
- 'email_to': 'test_value_7',
- 'force_password_change': 'enable',
- 'fortitoken': 'test_value_9',
- 'guest_auth': 'disable',
- 'guest_lang': 'test_value_11',
- 'hidden': '12',
- 'history0': 'test_value_13',
- 'history1': 'test_value_14',
- 'ip6_trusthost1': 'test_value_15',
- 'ip6_trusthost10': 'test_value_16',
- 'ip6_trusthost2': 'test_value_17',
- 'ip6_trusthost3': 'test_value_18',
- 'ip6_trusthost4': 'test_value_19',
- 'ip6_trusthost5': 'test_value_20',
- 'ip6_trusthost6': 'test_value_21',
- 'ip6_trusthost7': 'test_value_22',
- 'ip6_trusthost8': 'test_value_23',
- 'ip6_trusthost9': 'test_value_24',
- 'name': 'default_name_25',
- 'password': 'test_value_26',
- 'password_expire': 'test_value_27',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_29',
- 'radius_vdom_override': 'enable',
- 'remote_auth': 'enable',
- 'remote_group': 'test_value_32',
- 'schedule': 'test_value_33',
- 'sms_custom_server': 'test_value_34',
- 'sms_phone': 'test_value_35',
- 'sms_server': 'fortiguard',
- 'ssh_certificate': 'test_value_37',
- 'ssh_public_key1': 'test_value_38',
- 'ssh_public_key2': 'test_value_39',
- 'ssh_public_key3': 'test_value_40',
- 'trusthost1': 'test_value_41',
- 'trusthost10': 'test_value_42',
- 'trusthost2': 'test_value_43',
- 'trusthost3': 'test_value_44',
- 'trusthost4': 'test_value_45',
- 'trusthost5': 'test_value_46',
- 'trusthost6': 'test_value_47',
- 'trusthost7': 'test_value_48',
- 'trusthost8': 'test_value_49',
- 'trusthost9': 'test_value_50',
- 'two_factor': 'disable',
- 'wildcard': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_admin.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'accprofile': 'test_value_3',
- 'accprofile-override': 'enable',
- 'allow-remove-admin-session': 'enable',
- 'comments': 'test_value_6',
- 'email-to': 'test_value_7',
- 'force-password-change': 'enable',
- 'fortitoken': 'test_value_9',
- 'guest-auth': 'disable',
- 'guest-lang': 'test_value_11',
- 'hidden': '12',
- 'history0': 'test_value_13',
- 'history1': 'test_value_14',
- 'ip6-trusthost1': 'test_value_15',
- 'ip6-trusthost10': 'test_value_16',
- 'ip6-trusthost2': 'test_value_17',
- 'ip6-trusthost3': 'test_value_18',
- 'ip6-trusthost4': 'test_value_19',
- 'ip6-trusthost5': 'test_value_20',
- 'ip6-trusthost6': 'test_value_21',
- 'ip6-trusthost7': 'test_value_22',
- 'ip6-trusthost8': 'test_value_23',
- 'ip6-trusthost9': 'test_value_24',
- 'name': 'default_name_25',
- 'password': 'test_value_26',
- 'password-expire': 'test_value_27',
- 'peer-auth': 'enable',
- 'peer-group': 'test_value_29',
- 'radius-vdom-override': 'enable',
- 'remote-auth': 'enable',
- 'remote-group': 'test_value_32',
- 'schedule': 'test_value_33',
- 'sms-custom-server': 'test_value_34',
- 'sms-phone': 'test_value_35',
- 'sms-server': 'fortiguard',
- 'ssh-certificate': 'test_value_37',
- 'ssh-public-key1': 'test_value_38',
- 'ssh-public-key2': 'test_value_39',
- 'ssh-public-key3': 'test_value_40',
- 'trusthost1': 'test_value_41',
- 'trusthost10': 'test_value_42',
- 'trusthost2': 'test_value_43',
- 'trusthost3': 'test_value_44',
- 'trusthost4': 'test_value_45',
- 'trusthost5': 'test_value_46',
- 'trusthost6': 'test_value_47',
- 'trusthost7': 'test_value_48',
- 'trusthost8': 'test_value_49',
- 'trusthost9': 'test_value_50',
- 'two-factor': 'disable',
- 'wildcard': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_affinity_interrupt.py b/test/units/modules/network/fortios/test_fortios_system_affinity_interrupt.py
deleted file mode 100644
index fcc44861b0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_affinity_interrupt.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_affinity_interrupt
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_affinity_interrupt.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_affinity_interrupt_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_affinity_interrupt': {
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interrupt': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_interrupt.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'affinity-cpumask': 'test_value_3',
- 'id': '4',
- 'interrupt': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'affinity-interrupt', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_affinity_interrupt_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_affinity_interrupt': {
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interrupt': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_interrupt.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'affinity-cpumask': 'test_value_3',
- 'id': '4',
- 'interrupt': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'affinity-interrupt', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_affinity_interrupt_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_affinity_interrupt': {
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interrupt': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_interrupt.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'affinity-interrupt', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_affinity_interrupt_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_affinity_interrupt': {
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interrupt': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_interrupt.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'affinity-interrupt', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_affinity_interrupt_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_affinity_interrupt': {
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interrupt': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_interrupt.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'affinity-cpumask': 'test_value_3',
- 'id': '4',
- 'interrupt': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'affinity-interrupt', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_affinity_interrupt_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_affinity_interrupt': {
- 'random_attribute_not_valid': 'tag',
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interrupt': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_interrupt.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'affinity-cpumask': 'test_value_3',
- 'id': '4',
- 'interrupt': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'affinity-interrupt', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_affinity_packet_redistribution.py b/test/units/modules/network/fortios/test_fortios_system_affinity_packet_redistribution.py
deleted file mode 100644
index b84547fd0d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_affinity_packet_redistribution.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_affinity_packet_redistribution
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_affinity_packet_redistribution.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_affinity_packet_redistribution_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_affinity_packet_redistribution': {
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'rxqid': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_packet_redistribution.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'affinity-cpumask': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'rxqid': '6'
- }
-
- set_method_mock.assert_called_with('system', 'affinity-packet-redistribution', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_affinity_packet_redistribution_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_affinity_packet_redistribution': {
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'rxqid': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_packet_redistribution.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'affinity-cpumask': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'rxqid': '6'
- }
-
- set_method_mock.assert_called_with('system', 'affinity-packet-redistribution', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_affinity_packet_redistribution_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_affinity_packet_redistribution': {
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'rxqid': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_packet_redistribution.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'affinity-packet-redistribution', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_affinity_packet_redistribution_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_affinity_packet_redistribution': {
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'rxqid': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_packet_redistribution.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'affinity-packet-redistribution', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_affinity_packet_redistribution_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_affinity_packet_redistribution': {
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'rxqid': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_packet_redistribution.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'affinity-cpumask': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'rxqid': '6'
- }
-
- set_method_mock.assert_called_with('system', 'affinity-packet-redistribution', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_affinity_packet_redistribution_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_affinity_packet_redistribution': {
- 'random_attribute_not_valid': 'tag',
- 'affinity_cpumask': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'rxqid': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_affinity_packet_redistribution.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'affinity-cpumask': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'rxqid': '6'
- }
-
- set_method_mock.assert_called_with('system', 'affinity-packet-redistribution', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_alarm.py b/test/units/modules/network/fortios/test_fortios_system_alarm.py
deleted file mode 100644
index e77dd752a0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_alarm.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_alarm
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_alarm.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_alarm_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_alarm': {
- 'audible': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_alarm.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'audible': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'alarm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_alarm_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_alarm': {
- 'audible': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_alarm.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'audible': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'alarm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_alarm_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_alarm': {
- 'audible': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_alarm.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'audible': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'alarm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_alarm_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_alarm': {
- 'random_attribute_not_valid': 'tag',
- 'audible': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_alarm.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'audible': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'alarm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_alias.py b/test/units/modules/network/fortios/test_fortios_system_alias.py
deleted file mode 100644
index 6297845501..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_alias.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_alias
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_alias.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_alias_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_alias': {
- 'command': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_alias.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'command': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('system', 'alias', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_alias_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_alias': {
- 'command': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_alias.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'command': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('system', 'alias', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_alias_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_alias': {
- 'command': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_alias.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'alias', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_alias_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_alias': {
- 'command': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_alias.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'alias', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_alias_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_alias': {
- 'command': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_alias.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'command': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('system', 'alias', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_alias_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_alias': {
- 'random_attribute_not_valid': 'tag',
- 'command': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_alias.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'command': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('system', 'alias', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_api_user.py b/test/units/modules/network/fortios/test_fortios_system_api_user.py
deleted file mode 100644
index c127c9c465..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_api_user.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_api_user
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_api_user.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_api_user_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_api_user': {
- 'accprofile': 'test_value_3',
- 'api_key': 'test_value_4',
- 'comments': 'test_value_5',
- 'cors_allow_origin': 'test_value_6',
- 'name': 'default_name_7',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_9',
- 'schedule': 'test_value_10',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_api_user.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'accprofile': 'test_value_3',
- 'api-key': 'test_value_4',
- 'comments': 'test_value_5',
- 'cors-allow-origin': 'test_value_6',
- 'name': 'default_name_7',
- 'peer-auth': 'enable',
- 'peer-group': 'test_value_9',
- 'schedule': 'test_value_10',
-
- }
-
- set_method_mock.assert_called_with('system', 'api-user', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_api_user_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_api_user': {
- 'accprofile': 'test_value_3',
- 'api_key': 'test_value_4',
- 'comments': 'test_value_5',
- 'cors_allow_origin': 'test_value_6',
- 'name': 'default_name_7',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_9',
- 'schedule': 'test_value_10',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_api_user.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'accprofile': 'test_value_3',
- 'api-key': 'test_value_4',
- 'comments': 'test_value_5',
- 'cors-allow-origin': 'test_value_6',
- 'name': 'default_name_7',
- 'peer-auth': 'enable',
- 'peer-group': 'test_value_9',
- 'schedule': 'test_value_10',
-
- }
-
- set_method_mock.assert_called_with('system', 'api-user', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_api_user_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_api_user': {
- 'accprofile': 'test_value_3',
- 'api_key': 'test_value_4',
- 'comments': 'test_value_5',
- 'cors_allow_origin': 'test_value_6',
- 'name': 'default_name_7',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_9',
- 'schedule': 'test_value_10',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_api_user.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'api-user', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_api_user_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_api_user': {
- 'accprofile': 'test_value_3',
- 'api_key': 'test_value_4',
- 'comments': 'test_value_5',
- 'cors_allow_origin': 'test_value_6',
- 'name': 'default_name_7',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_9',
- 'schedule': 'test_value_10',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_api_user.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'api-user', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_api_user_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_api_user': {
- 'accprofile': 'test_value_3',
- 'api_key': 'test_value_4',
- 'comments': 'test_value_5',
- 'cors_allow_origin': 'test_value_6',
- 'name': 'default_name_7',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_9',
- 'schedule': 'test_value_10',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_api_user.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'accprofile': 'test_value_3',
- 'api-key': 'test_value_4',
- 'comments': 'test_value_5',
- 'cors-allow-origin': 'test_value_6',
- 'name': 'default_name_7',
- 'peer-auth': 'enable',
- 'peer-group': 'test_value_9',
- 'schedule': 'test_value_10',
-
- }
-
- set_method_mock.assert_called_with('system', 'api-user', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_api_user_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_api_user': {
- 'random_attribute_not_valid': 'tag',
- 'accprofile': 'test_value_3',
- 'api_key': 'test_value_4',
- 'comments': 'test_value_5',
- 'cors_allow_origin': 'test_value_6',
- 'name': 'default_name_7',
- 'peer_auth': 'enable',
- 'peer_group': 'test_value_9',
- 'schedule': 'test_value_10',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_api_user.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'accprofile': 'test_value_3',
- 'api-key': 'test_value_4',
- 'comments': 'test_value_5',
- 'cors-allow-origin': 'test_value_6',
- 'name': 'default_name_7',
- 'peer-auth': 'enable',
- 'peer-group': 'test_value_9',
- 'schedule': 'test_value_10',
-
- }
-
- set_method_mock.assert_called_with('system', 'api-user', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_arp_table.py b/test/units/modules/network/fortios/test_fortios_system_arp_table.py
deleted file mode 100644
index ffd6acfdc9..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_arp_table.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_arp_table
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_arp_table.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_arp_table_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_arp_table': {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ip': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_arp_table.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ip': 'test_value_5',
- 'mac': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'arp-table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_arp_table_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_arp_table': {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ip': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_arp_table.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ip': 'test_value_5',
- 'mac': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'arp-table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_arp_table_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_arp_table': {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ip': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_arp_table.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'arp-table', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_arp_table_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_arp_table': {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ip': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_arp_table.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'arp-table', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_arp_table_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_arp_table': {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ip': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_arp_table.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ip': 'test_value_5',
- 'mac': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'arp-table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_arp_table_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_arp_table': {
- 'random_attribute_not_valid': 'tag',
- 'id': '3',
- 'interface': 'test_value_4',
- 'ip': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_arp_table.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ip': 'test_value_5',
- 'mac': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'arp-table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_auto_install.py b/test/units/modules/network/fortios/test_fortios_system_auto_install.py
deleted file mode 100644
index d4549e7279..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_auto_install.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_auto_install
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_auto_install.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_auto_install_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_auto_install': {
- 'auto_install_config': 'enable',
- 'auto_install_image': 'enable',
- 'default_config_file': 'test_value_5',
- 'default_image_file': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_auto_install.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auto-install-config': 'enable',
- 'auto-install-image': 'enable',
- 'default-config-file': 'test_value_5',
- 'default-image-file': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'auto-install', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_auto_install_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_auto_install': {
- 'auto_install_config': 'enable',
- 'auto_install_image': 'enable',
- 'default_config_file': 'test_value_5',
- 'default_image_file': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_auto_install.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auto-install-config': 'enable',
- 'auto-install-image': 'enable',
- 'default-config-file': 'test_value_5',
- 'default-image-file': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'auto-install', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_auto_install_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_auto_install': {
- 'auto_install_config': 'enable',
- 'auto_install_image': 'enable',
- 'default_config_file': 'test_value_5',
- 'default_image_file': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_auto_install.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auto-install-config': 'enable',
- 'auto-install-image': 'enable',
- 'default-config-file': 'test_value_5',
- 'default-image-file': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'auto-install', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_auto_install_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_auto_install': {
- 'random_attribute_not_valid': 'tag',
- 'auto_install_config': 'enable',
- 'auto_install_image': 'enable',
- 'default_config_file': 'test_value_5',
- 'default_image_file': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_auto_install.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auto-install-config': 'enable',
- 'auto-install-image': 'enable',
- 'default-config-file': 'test_value_5',
- 'default-image-file': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'auto-install', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_auto_script.py b/test/units/modules/network/fortios/test_fortios_system_auto_script.py
deleted file mode 100644
index aa49d26075..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_auto_script.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_auto_script
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_auto_script.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_auto_script_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_auto_script': {
- 'interval': '3',
- 'name': 'default_name_4',
- 'output_size': '5',
- 'repeat': '6',
- 'script': 'test_value_7',
- 'start': 'manual'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_auto_script.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interval': '3',
- 'name': 'default_name_4',
- 'output-size': '5',
- 'repeat': '6',
- 'script': 'test_value_7',
- 'start': 'manual'
- }
-
- set_method_mock.assert_called_with('system', 'auto-script', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_auto_script_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_auto_script': {
- 'interval': '3',
- 'name': 'default_name_4',
- 'output_size': '5',
- 'repeat': '6',
- 'script': 'test_value_7',
- 'start': 'manual'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_auto_script.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interval': '3',
- 'name': 'default_name_4',
- 'output-size': '5',
- 'repeat': '6',
- 'script': 'test_value_7',
- 'start': 'manual'
- }
-
- set_method_mock.assert_called_with('system', 'auto-script', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_auto_script_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_auto_script': {
- 'interval': '3',
- 'name': 'default_name_4',
- 'output_size': '5',
- 'repeat': '6',
- 'script': 'test_value_7',
- 'start': 'manual'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_auto_script.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'auto-script', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_auto_script_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_auto_script': {
- 'interval': '3',
- 'name': 'default_name_4',
- 'output_size': '5',
- 'repeat': '6',
- 'script': 'test_value_7',
- 'start': 'manual'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_auto_script.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'auto-script', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_auto_script_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_auto_script': {
- 'interval': '3',
- 'name': 'default_name_4',
- 'output_size': '5',
- 'repeat': '6',
- 'script': 'test_value_7',
- 'start': 'manual'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_auto_script.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interval': '3',
- 'name': 'default_name_4',
- 'output-size': '5',
- 'repeat': '6',
- 'script': 'test_value_7',
- 'start': 'manual'
- }
-
- set_method_mock.assert_called_with('system', 'auto-script', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_auto_script_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_auto_script': {
- 'random_attribute_not_valid': 'tag',
- 'interval': '3',
- 'name': 'default_name_4',
- 'output_size': '5',
- 'repeat': '6',
- 'script': 'test_value_7',
- 'start': 'manual'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_auto_script.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interval': '3',
- 'name': 'default_name_4',
- 'output-size': '5',
- 'repeat': '6',
- 'script': 'test_value_7',
- 'start': 'manual'
- }
-
- set_method_mock.assert_called_with('system', 'auto-script', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_automation_action.py b/test/units/modules/network/fortios/test_fortios_system_automation_action.py
deleted file mode 100644
index 3edb76f717..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_automation_action.py
+++ /dev/null
@@ -1,359 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_automation_action
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_automation_action.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_automation_action_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_action': {
- 'action_type': 'email',
- 'aws_api_id': 'test_value_4',
- 'aws_api_key': 'test_value_5',
- 'aws_api_path': 'test_value_6',
- 'aws_api_stage': 'test_value_7',
- 'aws_domain': 'test_value_8',
- 'aws_region': 'test_value_9',
- 'delay': '10',
- 'email_subject': 'test_value_11',
- 'http_body': 'test_value_12',
- 'method': 'post',
- 'minimum_interval': '14',
- 'name': 'default_name_15',
- 'port': '16',
- 'protocol': 'http',
- 'required': 'enable',
- 'uri': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_action.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'action-type': 'email',
- 'aws-api-id': 'test_value_4',
- 'aws-api-key': 'test_value_5',
- 'aws-api-path': 'test_value_6',
- 'aws-api-stage': 'test_value_7',
- 'aws-domain': 'test_value_8',
- 'aws-region': 'test_value_9',
- 'delay': '10',
- 'email-subject': 'test_value_11',
- 'http-body': 'test_value_12',
- 'method': 'post',
- 'minimum-interval': '14',
- 'name': 'default_name_15',
- 'port': '16',
- 'protocol': 'http',
- 'required': 'enable',
- 'uri': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('system', 'automation-action', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_automation_action_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_action': {
- 'action_type': 'email',
- 'aws_api_id': 'test_value_4',
- 'aws_api_key': 'test_value_5',
- 'aws_api_path': 'test_value_6',
- 'aws_api_stage': 'test_value_7',
- 'aws_domain': 'test_value_8',
- 'aws_region': 'test_value_9',
- 'delay': '10',
- 'email_subject': 'test_value_11',
- 'http_body': 'test_value_12',
- 'method': 'post',
- 'minimum_interval': '14',
- 'name': 'default_name_15',
- 'port': '16',
- 'protocol': 'http',
- 'required': 'enable',
- 'uri': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_action.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'action-type': 'email',
- 'aws-api-id': 'test_value_4',
- 'aws-api-key': 'test_value_5',
- 'aws-api-path': 'test_value_6',
- 'aws-api-stage': 'test_value_7',
- 'aws-domain': 'test_value_8',
- 'aws-region': 'test_value_9',
- 'delay': '10',
- 'email-subject': 'test_value_11',
- 'http-body': 'test_value_12',
- 'method': 'post',
- 'minimum-interval': '14',
- 'name': 'default_name_15',
- 'port': '16',
- 'protocol': 'http',
- 'required': 'enable',
- 'uri': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('system', 'automation-action', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_automation_action_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_automation_action': {
- 'action_type': 'email',
- 'aws_api_id': 'test_value_4',
- 'aws_api_key': 'test_value_5',
- 'aws_api_path': 'test_value_6',
- 'aws_api_stage': 'test_value_7',
- 'aws_domain': 'test_value_8',
- 'aws_region': 'test_value_9',
- 'delay': '10',
- 'email_subject': 'test_value_11',
- 'http_body': 'test_value_12',
- 'method': 'post',
- 'minimum_interval': '14',
- 'name': 'default_name_15',
- 'port': '16',
- 'protocol': 'http',
- 'required': 'enable',
- 'uri': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_action.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'automation-action', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_automation_action_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_automation_action': {
- 'action_type': 'email',
- 'aws_api_id': 'test_value_4',
- 'aws_api_key': 'test_value_5',
- 'aws_api_path': 'test_value_6',
- 'aws_api_stage': 'test_value_7',
- 'aws_domain': 'test_value_8',
- 'aws_region': 'test_value_9',
- 'delay': '10',
- 'email_subject': 'test_value_11',
- 'http_body': 'test_value_12',
- 'method': 'post',
- 'minimum_interval': '14',
- 'name': 'default_name_15',
- 'port': '16',
- 'protocol': 'http',
- 'required': 'enable',
- 'uri': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_action.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'automation-action', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_automation_action_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_action': {
- 'action_type': 'email',
- 'aws_api_id': 'test_value_4',
- 'aws_api_key': 'test_value_5',
- 'aws_api_path': 'test_value_6',
- 'aws_api_stage': 'test_value_7',
- 'aws_domain': 'test_value_8',
- 'aws_region': 'test_value_9',
- 'delay': '10',
- 'email_subject': 'test_value_11',
- 'http_body': 'test_value_12',
- 'method': 'post',
- 'minimum_interval': '14',
- 'name': 'default_name_15',
- 'port': '16',
- 'protocol': 'http',
- 'required': 'enable',
- 'uri': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_action.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'action-type': 'email',
- 'aws-api-id': 'test_value_4',
- 'aws-api-key': 'test_value_5',
- 'aws-api-path': 'test_value_6',
- 'aws-api-stage': 'test_value_7',
- 'aws-domain': 'test_value_8',
- 'aws-region': 'test_value_9',
- 'delay': '10',
- 'email-subject': 'test_value_11',
- 'http-body': 'test_value_12',
- 'method': 'post',
- 'minimum-interval': '14',
- 'name': 'default_name_15',
- 'port': '16',
- 'protocol': 'http',
- 'required': 'enable',
- 'uri': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('system', 'automation-action', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_automation_action_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_action': {
- 'random_attribute_not_valid': 'tag',
- 'action_type': 'email',
- 'aws_api_id': 'test_value_4',
- 'aws_api_key': 'test_value_5',
- 'aws_api_path': 'test_value_6',
- 'aws_api_stage': 'test_value_7',
- 'aws_domain': 'test_value_8',
- 'aws_region': 'test_value_9',
- 'delay': '10',
- 'email_subject': 'test_value_11',
- 'http_body': 'test_value_12',
- 'method': 'post',
- 'minimum_interval': '14',
- 'name': 'default_name_15',
- 'port': '16',
- 'protocol': 'http',
- 'required': 'enable',
- 'uri': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_action.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'action-type': 'email',
- 'aws-api-id': 'test_value_4',
- 'aws-api-key': 'test_value_5',
- 'aws-api-path': 'test_value_6',
- 'aws-api-stage': 'test_value_7',
- 'aws-domain': 'test_value_8',
- 'aws-region': 'test_value_9',
- 'delay': '10',
- 'email-subject': 'test_value_11',
- 'http-body': 'test_value_12',
- 'method': 'post',
- 'minimum-interval': '14',
- 'name': 'default_name_15',
- 'port': '16',
- 'protocol': 'http',
- 'required': 'enable',
- 'uri': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('system', 'automation-action', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_automation_destination.py b/test/units/modules/network/fortios/test_fortios_system_automation_destination.py
deleted file mode 100644
index 77277d71c7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_automation_destination.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_automation_destination
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_automation_destination.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_automation_destination_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_destination': {'ha_group_id': '3',
- 'name': 'default_name_4',
- 'type': 'fortigate'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_destination.fortios_system(input_data, fos_instance)
-
- expected_data = {'ha-group-id': '3',
- 'name': 'default_name_4',
- 'type': 'fortigate'
- }
-
- set_method_mock.assert_called_with('system', 'automation-destination', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_automation_destination_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_destination': {'ha_group_id': '3',
- 'name': 'default_name_4',
- 'type': 'fortigate'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_destination.fortios_system(input_data, fos_instance)
-
- expected_data = {'ha-group-id': '3',
- 'name': 'default_name_4',
- 'type': 'fortigate'
- }
-
- set_method_mock.assert_called_with('system', 'automation-destination', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_automation_destination_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_automation_destination': {'ha_group_id': '3',
- 'name': 'default_name_4',
- 'type': 'fortigate'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_destination.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'automation-destination', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_automation_destination_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_automation_destination': {'ha_group_id': '3',
- 'name': 'default_name_4',
- 'type': 'fortigate'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_destination.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'automation-destination', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_automation_destination_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_destination': {'ha_group_id': '3',
- 'name': 'default_name_4',
- 'type': 'fortigate'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_destination.fortios_system(input_data, fos_instance)
-
- expected_data = {'ha-group-id': '3',
- 'name': 'default_name_4',
- 'type': 'fortigate'
- }
-
- set_method_mock.assert_called_with('system', 'automation-destination', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_automation_destination_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_destination': {
- 'random_attribute_not_valid': 'tag', 'ha_group_id': '3',
- 'name': 'default_name_4',
- 'type': 'fortigate'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_destination.fortios_system(input_data, fos_instance)
-
- expected_data = {'ha-group-id': '3',
- 'name': 'default_name_4',
- 'type': 'fortigate'
- }
-
- set_method_mock.assert_called_with('system', 'automation-destination', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_automation_stitch.py b/test/units/modules/network/fortios/test_fortios_system_automation_stitch.py
deleted file mode 100644
index 9de0e563ea..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_automation_stitch.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_automation_stitch
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_automation_stitch.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_automation_stitch_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_stitch': {'name': 'default_name_3',
- 'status': 'enable',
- 'trigger': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_stitch.fortios_system(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'status': 'enable',
- 'trigger': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'automation-stitch', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_automation_stitch_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_stitch': {'name': 'default_name_3',
- 'status': 'enable',
- 'trigger': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_stitch.fortios_system(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'status': 'enable',
- 'trigger': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'automation-stitch', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_automation_stitch_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_automation_stitch': {'name': 'default_name_3',
- 'status': 'enable',
- 'trigger': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_stitch.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'automation-stitch', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_automation_stitch_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_automation_stitch': {'name': 'default_name_3',
- 'status': 'enable',
- 'trigger': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_stitch.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'automation-stitch', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_automation_stitch_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_stitch': {'name': 'default_name_3',
- 'status': 'enable',
- 'trigger': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_stitch.fortios_system(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'status': 'enable',
- 'trigger': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'automation-stitch', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_automation_stitch_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_stitch': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3',
- 'status': 'enable',
- 'trigger': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_stitch.fortios_system(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'status': 'enable',
- 'trigger': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'automation-stitch', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_automation_trigger.py b/test/units/modules/network/fortios/test_fortios_system_automation_trigger.py
deleted file mode 100644
index 18e3c6f051..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_automation_trigger.py
+++ /dev/null
@@ -1,299 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_automation_trigger
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_automation_trigger.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_automation_trigger_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_trigger': {
- 'event_type': 'ioc',
- 'ioc_level': 'medium',
- 'license_type': 'forticare-support',
- 'logid': '6',
- 'name': 'default_name_7',
- 'trigger_day': '8',
- 'trigger_frequency': 'hourly',
- 'trigger_hour': '10',
- 'trigger_minute': '11',
- 'trigger_type': 'event-based',
- 'trigger_weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_trigger.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'event-type': 'ioc',
- 'ioc-level': 'medium',
- 'license-type': 'forticare-support',
- 'logid': '6',
- 'name': 'default_name_7',
- 'trigger-day': '8',
- 'trigger-frequency': 'hourly',
- 'trigger-hour': '10',
- 'trigger-minute': '11',
- 'trigger-type': 'event-based',
- 'trigger-weekday': 'sunday'
- }
-
- set_method_mock.assert_called_with('system', 'automation-trigger', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_automation_trigger_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_trigger': {
- 'event_type': 'ioc',
- 'ioc_level': 'medium',
- 'license_type': 'forticare-support',
- 'logid': '6',
- 'name': 'default_name_7',
- 'trigger_day': '8',
- 'trigger_frequency': 'hourly',
- 'trigger_hour': '10',
- 'trigger_minute': '11',
- 'trigger_type': 'event-based',
- 'trigger_weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_trigger.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'event-type': 'ioc',
- 'ioc-level': 'medium',
- 'license-type': 'forticare-support',
- 'logid': '6',
- 'name': 'default_name_7',
- 'trigger-day': '8',
- 'trigger-frequency': 'hourly',
- 'trigger-hour': '10',
- 'trigger-minute': '11',
- 'trigger-type': 'event-based',
- 'trigger-weekday': 'sunday'
- }
-
- set_method_mock.assert_called_with('system', 'automation-trigger', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_automation_trigger_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_automation_trigger': {
- 'event_type': 'ioc',
- 'ioc_level': 'medium',
- 'license_type': 'forticare-support',
- 'logid': '6',
- 'name': 'default_name_7',
- 'trigger_day': '8',
- 'trigger_frequency': 'hourly',
- 'trigger_hour': '10',
- 'trigger_minute': '11',
- 'trigger_type': 'event-based',
- 'trigger_weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_trigger.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'automation-trigger', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_automation_trigger_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_automation_trigger': {
- 'event_type': 'ioc',
- 'ioc_level': 'medium',
- 'license_type': 'forticare-support',
- 'logid': '6',
- 'name': 'default_name_7',
- 'trigger_day': '8',
- 'trigger_frequency': 'hourly',
- 'trigger_hour': '10',
- 'trigger_minute': '11',
- 'trigger_type': 'event-based',
- 'trigger_weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_trigger.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'automation-trigger', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_automation_trigger_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_trigger': {
- 'event_type': 'ioc',
- 'ioc_level': 'medium',
- 'license_type': 'forticare-support',
- 'logid': '6',
- 'name': 'default_name_7',
- 'trigger_day': '8',
- 'trigger_frequency': 'hourly',
- 'trigger_hour': '10',
- 'trigger_minute': '11',
- 'trigger_type': 'event-based',
- 'trigger_weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_trigger.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'event-type': 'ioc',
- 'ioc-level': 'medium',
- 'license-type': 'forticare-support',
- 'logid': '6',
- 'name': 'default_name_7',
- 'trigger-day': '8',
- 'trigger-frequency': 'hourly',
- 'trigger-hour': '10',
- 'trigger-minute': '11',
- 'trigger-type': 'event-based',
- 'trigger-weekday': 'sunday'
- }
-
- set_method_mock.assert_called_with('system', 'automation-trigger', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_automation_trigger_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_automation_trigger': {
- 'random_attribute_not_valid': 'tag',
- 'event_type': 'ioc',
- 'ioc_level': 'medium',
- 'license_type': 'forticare-support',
- 'logid': '6',
- 'name': 'default_name_7',
- 'trigger_day': '8',
- 'trigger_frequency': 'hourly',
- 'trigger_hour': '10',
- 'trigger_minute': '11',
- 'trigger_type': 'event-based',
- 'trigger_weekday': 'sunday'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_automation_trigger.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'event-type': 'ioc',
- 'ioc-level': 'medium',
- 'license-type': 'forticare-support',
- 'logid': '6',
- 'name': 'default_name_7',
- 'trigger-day': '8',
- 'trigger-frequency': 'hourly',
- 'trigger-hour': '10',
- 'trigger-minute': '11',
- 'trigger-type': 'event-based',
- 'trigger-weekday': 'sunday'
- }
-
- set_method_mock.assert_called_with('system', 'automation-trigger', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_autoupdate_push_update.py b/test/units/modules/network/fortios/test_fortios_system_autoupdate_push_update.py
deleted file mode 100644
index 8ba937751c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_autoupdate_push_update.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_autoupdate_push_update
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_autoupdate_push_update.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_autoupdate_push_update_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_push_update': {
- 'address': 'test_value_3',
- 'override': 'enable',
- 'port': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_push_update.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'override': 'enable',
- 'port': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'push-update', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_autoupdate_push_update_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_push_update': {
- 'address': 'test_value_3',
- 'override': 'enable',
- 'port': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_push_update.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'override': 'enable',
- 'port': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'push-update', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_autoupdate_push_update_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_push_update': {
- 'address': 'test_value_3',
- 'override': 'enable',
- 'port': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_push_update.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'override': 'enable',
- 'port': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'push-update', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_autoupdate_push_update_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_push_update': {
- 'random_attribute_not_valid': 'tag',
- 'address': 'test_value_3',
- 'override': 'enable',
- 'port': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_push_update.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'override': 'enable',
- 'port': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'push-update', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_autoupdate_schedule.py b/test/units/modules/network/fortios/test_fortios_system_autoupdate_schedule.py
deleted file mode 100644
index c15e17c61c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_autoupdate_schedule.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_autoupdate_schedule
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_autoupdate_schedule.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_autoupdate_schedule_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_schedule': {
- 'day': 'Sunday',
- 'frequency': 'every',
- 'status': 'enable',
- 'time': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_schedule.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'day': 'Sunday',
- 'frequency': 'every',
- 'status': 'enable',
- 'time': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'schedule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_autoupdate_schedule_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_schedule': {
- 'day': 'Sunday',
- 'frequency': 'every',
- 'status': 'enable',
- 'time': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_schedule.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'day': 'Sunday',
- 'frequency': 'every',
- 'status': 'enable',
- 'time': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'schedule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_autoupdate_schedule_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_schedule': {
- 'day': 'Sunday',
- 'frequency': 'every',
- 'status': 'enable',
- 'time': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_schedule.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'day': 'Sunday',
- 'frequency': 'every',
- 'status': 'enable',
- 'time': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'schedule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_autoupdate_schedule_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_schedule': {
- 'random_attribute_not_valid': 'tag',
- 'day': 'Sunday',
- 'frequency': 'every',
- 'status': 'enable',
- 'time': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_schedule.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'day': 'Sunday',
- 'frequency': 'every',
- 'status': 'enable',
- 'time': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'schedule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_autoupdate_tunneling.py b/test/units/modules/network/fortios/test_fortios_system_autoupdate_tunneling.py
deleted file mode 100644
index 442f3061f5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_autoupdate_tunneling.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_autoupdate_tunneling
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_autoupdate_tunneling.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_autoupdate_tunneling_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_tunneling': {
- 'address': 'test_value_3',
- 'password': 'test_value_4',
- 'port': '5',
- 'status': 'enable',
- 'username': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_tunneling.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'password': 'test_value_4',
- 'port': '5',
- 'status': 'enable',
- 'username': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'tunneling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_autoupdate_tunneling_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_tunneling': {
- 'address': 'test_value_3',
- 'password': 'test_value_4',
- 'port': '5',
- 'status': 'enable',
- 'username': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_tunneling.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'password': 'test_value_4',
- 'port': '5',
- 'status': 'enable',
- 'username': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'tunneling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_autoupdate_tunneling_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_tunneling': {
- 'address': 'test_value_3',
- 'password': 'test_value_4',
- 'port': '5',
- 'status': 'enable',
- 'username': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_tunneling.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'password': 'test_value_4',
- 'port': '5',
- 'status': 'enable',
- 'username': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'tunneling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_autoupdate_tunneling_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_autoupdate_tunneling': {
- 'random_attribute_not_valid': 'tag',
- 'address': 'test_value_3',
- 'password': 'test_value_4',
- 'port': '5',
- 'status': 'enable',
- 'username': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_autoupdate_tunneling.fortios_system_autoupdate(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'password': 'test_value_4',
- 'port': '5',
- 'status': 'enable',
- 'username': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('system.autoupdate', 'tunneling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_central_management.py b/test/units/modules/network/fortios/test_fortios_system_central_management.py
deleted file mode 100644
index 149effdc6d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_central_management.py
+++ /dev/null
@@ -1,263 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_central_management
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_central_management.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_central_management_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_central_management': {
- 'allow_monitor': 'enable',
- 'allow_push_configuration': 'enable',
- 'allow_push_firmware': 'enable',
- 'allow_remote_firmware_upgrade': 'enable',
- 'enc_algorithm': 'default',
- 'fmg': 'test_value_8',
- 'fmg_source_ip': 'test_value_9',
- 'fmg_source_ip6': 'test_value_10',
- 'include_default_servers': 'enable',
- 'mode': 'normal',
- 'schedule_config_restore': 'enable',
- 'schedule_script_restore': 'enable',
- 'serial_number': 'test_value_15',
- 'type': 'fortimanager',
- 'vdom': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_central_management.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-monitor': 'enable',
- 'allow-push-configuration': 'enable',
- 'allow-push-firmware': 'enable',
- 'allow-remote-firmware-upgrade': 'enable',
- 'enc-algorithm': 'default',
- 'fmg': 'test_value_8',
- 'fmg-source-ip': 'test_value_9',
- 'fmg-source-ip6': 'test_value_10',
- 'include-default-servers': 'enable',
- 'mode': 'normal',
- 'schedule-config-restore': 'enable',
- 'schedule-script-restore': 'enable',
- 'serial-number': 'test_value_15',
- 'type': 'fortimanager',
- 'vdom': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('system', 'central-management', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_central_management_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_central_management': {
- 'allow_monitor': 'enable',
- 'allow_push_configuration': 'enable',
- 'allow_push_firmware': 'enable',
- 'allow_remote_firmware_upgrade': 'enable',
- 'enc_algorithm': 'default',
- 'fmg': 'test_value_8',
- 'fmg_source_ip': 'test_value_9',
- 'fmg_source_ip6': 'test_value_10',
- 'include_default_servers': 'enable',
- 'mode': 'normal',
- 'schedule_config_restore': 'enable',
- 'schedule_script_restore': 'enable',
- 'serial_number': 'test_value_15',
- 'type': 'fortimanager',
- 'vdom': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_central_management.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-monitor': 'enable',
- 'allow-push-configuration': 'enable',
- 'allow-push-firmware': 'enable',
- 'allow-remote-firmware-upgrade': 'enable',
- 'enc-algorithm': 'default',
- 'fmg': 'test_value_8',
- 'fmg-source-ip': 'test_value_9',
- 'fmg-source-ip6': 'test_value_10',
- 'include-default-servers': 'enable',
- 'mode': 'normal',
- 'schedule-config-restore': 'enable',
- 'schedule-script-restore': 'enable',
- 'serial-number': 'test_value_15',
- 'type': 'fortimanager',
- 'vdom': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('system', 'central-management', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_central_management_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_central_management': {
- 'allow_monitor': 'enable',
- 'allow_push_configuration': 'enable',
- 'allow_push_firmware': 'enable',
- 'allow_remote_firmware_upgrade': 'enable',
- 'enc_algorithm': 'default',
- 'fmg': 'test_value_8',
- 'fmg_source_ip': 'test_value_9',
- 'fmg_source_ip6': 'test_value_10',
- 'include_default_servers': 'enable',
- 'mode': 'normal',
- 'schedule_config_restore': 'enable',
- 'schedule_script_restore': 'enable',
- 'serial_number': 'test_value_15',
- 'type': 'fortimanager',
- 'vdom': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_central_management.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-monitor': 'enable',
- 'allow-push-configuration': 'enable',
- 'allow-push-firmware': 'enable',
- 'allow-remote-firmware-upgrade': 'enable',
- 'enc-algorithm': 'default',
- 'fmg': 'test_value_8',
- 'fmg-source-ip': 'test_value_9',
- 'fmg-source-ip6': 'test_value_10',
- 'include-default-servers': 'enable',
- 'mode': 'normal',
- 'schedule-config-restore': 'enable',
- 'schedule-script-restore': 'enable',
- 'serial-number': 'test_value_15',
- 'type': 'fortimanager',
- 'vdom': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('system', 'central-management', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_central_management_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_central_management': {
- 'random_attribute_not_valid': 'tag',
- 'allow_monitor': 'enable',
- 'allow_push_configuration': 'enable',
- 'allow_push_firmware': 'enable',
- 'allow_remote_firmware_upgrade': 'enable',
- 'enc_algorithm': 'default',
- 'fmg': 'test_value_8',
- 'fmg_source_ip': 'test_value_9',
- 'fmg_source_ip6': 'test_value_10',
- 'include_default_servers': 'enable',
- 'mode': 'normal',
- 'schedule_config_restore': 'enable',
- 'schedule_script_restore': 'enable',
- 'serial_number': 'test_value_15',
- 'type': 'fortimanager',
- 'vdom': 'test_value_17'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_central_management.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-monitor': 'enable',
- 'allow-push-configuration': 'enable',
- 'allow-push-firmware': 'enable',
- 'allow-remote-firmware-upgrade': 'enable',
- 'enc-algorithm': 'default',
- 'fmg': 'test_value_8',
- 'fmg-source-ip': 'test_value_9',
- 'fmg-source-ip6': 'test_value_10',
- 'include-default-servers': 'enable',
- 'mode': 'normal',
- 'schedule-config-restore': 'enable',
- 'schedule-script-restore': 'enable',
- 'serial-number': 'test_value_15',
- 'type': 'fortimanager',
- 'vdom': 'test_value_17'
- }
-
- set_method_mock.assert_called_with('system', 'central-management', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_cluster_sync.py b/test/units/modules/network/fortios/test_fortios_system_cluster_sync.py
deleted file mode 100644
index 346626d60a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_cluster_sync.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_cluster_sync
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_cluster_sync.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_cluster_sync_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_cluster_sync': {'hb_interval': '3',
- 'hb_lost_threshold': '4',
- 'peerip': 'test_value_5',
- 'peervd': 'test_value_6',
- 'slave_add_ike_routes': 'enable',
- 'sync_id': '8',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_cluster_sync.fortios_system(input_data, fos_instance)
-
- expected_data = {'hb-interval': '3',
- 'hb-lost-threshold': '4',
- 'peerip': 'test_value_5',
- 'peervd': 'test_value_6',
- 'slave-add-ike-routes': 'enable',
- 'sync-id': '8',
-
- }
-
- set_method_mock.assert_called_with('system', 'cluster-sync', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_cluster_sync_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_cluster_sync': {'hb_interval': '3',
- 'hb_lost_threshold': '4',
- 'peerip': 'test_value_5',
- 'peervd': 'test_value_6',
- 'slave_add_ike_routes': 'enable',
- 'sync_id': '8',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_cluster_sync.fortios_system(input_data, fos_instance)
-
- expected_data = {'hb-interval': '3',
- 'hb-lost-threshold': '4',
- 'peerip': 'test_value_5',
- 'peervd': 'test_value_6',
- 'slave-add-ike-routes': 'enable',
- 'sync-id': '8',
-
- }
-
- set_method_mock.assert_called_with('system', 'cluster-sync', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_cluster_sync_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_cluster_sync': {'hb_interval': '3',
- 'hb_lost_threshold': '4',
- 'peerip': 'test_value_5',
- 'peervd': 'test_value_6',
- 'slave_add_ike_routes': 'enable',
- 'sync_id': '8',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_cluster_sync.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'cluster-sync', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_cluster_sync_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_cluster_sync': {'hb_interval': '3',
- 'hb_lost_threshold': '4',
- 'peerip': 'test_value_5',
- 'peervd': 'test_value_6',
- 'slave_add_ike_routes': 'enable',
- 'sync_id': '8',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_cluster_sync.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'cluster-sync', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_cluster_sync_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_cluster_sync': {'hb_interval': '3',
- 'hb_lost_threshold': '4',
- 'peerip': 'test_value_5',
- 'peervd': 'test_value_6',
- 'slave_add_ike_routes': 'enable',
- 'sync_id': '8',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_cluster_sync.fortios_system(input_data, fos_instance)
-
- expected_data = {'hb-interval': '3',
- 'hb-lost-threshold': '4',
- 'peerip': 'test_value_5',
- 'peervd': 'test_value_6',
- 'slave-add-ike-routes': 'enable',
- 'sync-id': '8',
-
- }
-
- set_method_mock.assert_called_with('system', 'cluster-sync', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_cluster_sync_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_cluster_sync': {
- 'random_attribute_not_valid': 'tag', 'hb_interval': '3',
- 'hb_lost_threshold': '4',
- 'peerip': 'test_value_5',
- 'peervd': 'test_value_6',
- 'slave_add_ike_routes': 'enable',
- 'sync_id': '8',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_cluster_sync.fortios_system(input_data, fos_instance)
-
- expected_data = {'hb-interval': '3',
- 'hb-lost-threshold': '4',
- 'peerip': 'test_value_5',
- 'peervd': 'test_value_6',
- 'slave-add-ike-routes': 'enable',
- 'sync-id': '8',
-
- }
-
- set_method_mock.assert_called_with('system', 'cluster-sync', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_console.py b/test/units/modules/network/fortios/test_fortios_system_console.py
deleted file mode 100644
index 01aa49e670..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_console.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_console
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_console.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_console_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_console': {
- 'baudrate': '9600',
- 'login': 'enable',
- 'mode': 'batch',
- 'output': 'standard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_console.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'baudrate': '9600',
- 'login': 'enable',
- 'mode': 'batch',
- 'output': 'standard'
- }
-
- set_method_mock.assert_called_with('system', 'console', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_console_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_console': {
- 'baudrate': '9600',
- 'login': 'enable',
- 'mode': 'batch',
- 'output': 'standard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_console.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'baudrate': '9600',
- 'login': 'enable',
- 'mode': 'batch',
- 'output': 'standard'
- }
-
- set_method_mock.assert_called_with('system', 'console', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_console_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_console': {
- 'baudrate': '9600',
- 'login': 'enable',
- 'mode': 'batch',
- 'output': 'standard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_console.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'baudrate': '9600',
- 'login': 'enable',
- 'mode': 'batch',
- 'output': 'standard'
- }
-
- set_method_mock.assert_called_with('system', 'console', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_console_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_console': {
- 'random_attribute_not_valid': 'tag',
- 'baudrate': '9600',
- 'login': 'enable',
- 'mode': 'batch',
- 'output': 'standard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_console.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'baudrate': '9600',
- 'login': 'enable',
- 'mode': 'batch',
- 'output': 'standard'
- }
-
- set_method_mock.assert_called_with('system', 'console', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_csf.py b/test/units/modules/network/fortios/test_fortios_system_csf.py
deleted file mode 100644
index 0052966758..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_csf.py
+++ /dev/null
@@ -1,215 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_csf
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_csf.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_csf_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_csf': {
- 'configuration_sync': 'default',
- 'fixed_key': 'test_value_4',
- 'group_name': 'test_value_5',
- 'group_password': 'test_value_6',
- 'management_ip': 'test_value_7',
- 'management_port': '8',
- 'status': 'enable',
- 'upstream_ip': 'test_value_10',
- 'upstream_port': '11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_csf.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'configuration-sync': 'default',
- 'fixed-key': 'test_value_4',
- 'group-name': 'test_value_5',
- 'group-password': 'test_value_6',
- 'management-ip': 'test_value_7',
- 'management-port': '8',
- 'status': 'enable',
- 'upstream-ip': 'test_value_10',
- 'upstream-port': '11'
- }
-
- set_method_mock.assert_called_with('system', 'csf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_csf_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_csf': {
- 'configuration_sync': 'default',
- 'fixed_key': 'test_value_4',
- 'group_name': 'test_value_5',
- 'group_password': 'test_value_6',
- 'management_ip': 'test_value_7',
- 'management_port': '8',
- 'status': 'enable',
- 'upstream_ip': 'test_value_10',
- 'upstream_port': '11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_csf.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'configuration-sync': 'default',
- 'fixed-key': 'test_value_4',
- 'group-name': 'test_value_5',
- 'group-password': 'test_value_6',
- 'management-ip': 'test_value_7',
- 'management-port': '8',
- 'status': 'enable',
- 'upstream-ip': 'test_value_10',
- 'upstream-port': '11'
- }
-
- set_method_mock.assert_called_with('system', 'csf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_csf_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_csf': {
- 'configuration_sync': 'default',
- 'fixed_key': 'test_value_4',
- 'group_name': 'test_value_5',
- 'group_password': 'test_value_6',
- 'management_ip': 'test_value_7',
- 'management_port': '8',
- 'status': 'enable',
- 'upstream_ip': 'test_value_10',
- 'upstream_port': '11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_csf.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'configuration-sync': 'default',
- 'fixed-key': 'test_value_4',
- 'group-name': 'test_value_5',
- 'group-password': 'test_value_6',
- 'management-ip': 'test_value_7',
- 'management-port': '8',
- 'status': 'enable',
- 'upstream-ip': 'test_value_10',
- 'upstream-port': '11'
- }
-
- set_method_mock.assert_called_with('system', 'csf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_csf_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_csf': {
- 'random_attribute_not_valid': 'tag',
- 'configuration_sync': 'default',
- 'fixed_key': 'test_value_4',
- 'group_name': 'test_value_5',
- 'group_password': 'test_value_6',
- 'management_ip': 'test_value_7',
- 'management_port': '8',
- 'status': 'enable',
- 'upstream_ip': 'test_value_10',
- 'upstream_port': '11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_csf.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'configuration-sync': 'default',
- 'fixed-key': 'test_value_4',
- 'group-name': 'test_value_5',
- 'group-password': 'test_value_6',
- 'management-ip': 'test_value_7',
- 'management-port': '8',
- 'status': 'enable',
- 'upstream-ip': 'test_value_10',
- 'upstream-port': '11'
- }
-
- set_method_mock.assert_called_with('system', 'csf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_custom_language.py b/test/units/modules/network/fortios/test_fortios_system_custom_language.py
deleted file mode 100644
index b28d841b1c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_custom_language.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_custom_language
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_custom_language.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_custom_language_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_custom_language': {
- 'comments': 'test_value_3',
- 'filename': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_custom_language.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'filename': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'custom-language', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_custom_language_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_custom_language': {
- 'comments': 'test_value_3',
- 'filename': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_custom_language.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'filename': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'custom-language', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_custom_language_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_custom_language': {
- 'comments': 'test_value_3',
- 'filename': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_custom_language.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'custom-language', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_custom_language_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_custom_language': {
- 'comments': 'test_value_3',
- 'filename': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_custom_language.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'custom-language', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_custom_language_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_custom_language': {
- 'comments': 'test_value_3',
- 'filename': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_custom_language.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'filename': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'custom-language', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_custom_language_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_custom_language': {
- 'random_attribute_not_valid': 'tag',
- 'comments': 'test_value_3',
- 'filename': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_custom_language.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'comments': 'test_value_3',
- 'filename': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'custom-language', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_ddns.py b/test/units/modules/network/fortios/test_fortios_system_ddns.py
deleted file mode 100644
index de36ef9af3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_ddns.py
+++ /dev/null
@@ -1,359 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_ddns
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_ddns.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_ddns_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ddns': {
- 'bound_ip': 'test_value_3',
- 'clear_text': 'disable',
- 'ddns_auth': 'disable',
- 'ddns_domain': 'test_value_6',
- 'ddns_key': 'test_value_7',
- 'ddns_keyname': 'test_value_8',
- 'ddns_password': 'test_value_9',
- 'ddns_server': 'dyndns.org',
- 'ddns_server_ip': 'test_value_11',
- 'ddns_sn': 'test_value_12',
- 'ddns_ttl': '13',
- 'ddns_username': 'test_value_14',
- 'ddns_zone': 'test_value_15',
- 'ddnsid': '16',
- 'ssl_certificate': 'test_value_17',
- 'update_interval': '18',
- 'use_public_ip': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ddns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'bound-ip': 'test_value_3',
- 'clear-text': 'disable',
- 'ddns-auth': 'disable',
- 'ddns-domain': 'test_value_6',
- 'ddns-key': 'test_value_7',
- 'ddns-keyname': 'test_value_8',
- 'ddns-password': 'test_value_9',
- 'ddns-server': 'dyndns.org',
- 'ddns-server-ip': 'test_value_11',
- 'ddns-sn': 'test_value_12',
- 'ddns-ttl': '13',
- 'ddns-username': 'test_value_14',
- 'ddns-zone': 'test_value_15',
- 'ddnsid': '16',
- 'ssl-certificate': 'test_value_17',
- 'update-interval': '18',
- 'use-public-ip': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'ddns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ddns_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ddns': {
- 'bound_ip': 'test_value_3',
- 'clear_text': 'disable',
- 'ddns_auth': 'disable',
- 'ddns_domain': 'test_value_6',
- 'ddns_key': 'test_value_7',
- 'ddns_keyname': 'test_value_8',
- 'ddns_password': 'test_value_9',
- 'ddns_server': 'dyndns.org',
- 'ddns_server_ip': 'test_value_11',
- 'ddns_sn': 'test_value_12',
- 'ddns_ttl': '13',
- 'ddns_username': 'test_value_14',
- 'ddns_zone': 'test_value_15',
- 'ddnsid': '16',
- 'ssl_certificate': 'test_value_17',
- 'update_interval': '18',
- 'use_public_ip': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ddns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'bound-ip': 'test_value_3',
- 'clear-text': 'disable',
- 'ddns-auth': 'disable',
- 'ddns-domain': 'test_value_6',
- 'ddns-key': 'test_value_7',
- 'ddns-keyname': 'test_value_8',
- 'ddns-password': 'test_value_9',
- 'ddns-server': 'dyndns.org',
- 'ddns-server-ip': 'test_value_11',
- 'ddns-sn': 'test_value_12',
- 'ddns-ttl': '13',
- 'ddns-username': 'test_value_14',
- 'ddns-zone': 'test_value_15',
- 'ddnsid': '16',
- 'ssl-certificate': 'test_value_17',
- 'update-interval': '18',
- 'use-public-ip': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'ddns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ddns_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ddns': {
- 'bound_ip': 'test_value_3',
- 'clear_text': 'disable',
- 'ddns_auth': 'disable',
- 'ddns_domain': 'test_value_6',
- 'ddns_key': 'test_value_7',
- 'ddns_keyname': 'test_value_8',
- 'ddns_password': 'test_value_9',
- 'ddns_server': 'dyndns.org',
- 'ddns_server_ip': 'test_value_11',
- 'ddns_sn': 'test_value_12',
- 'ddns_ttl': '13',
- 'ddns_username': 'test_value_14',
- 'ddns_zone': 'test_value_15',
- 'ddnsid': '16',
- 'ssl_certificate': 'test_value_17',
- 'update_interval': '18',
- 'use_public_ip': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ddns.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ddns', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ddns_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ddns': {
- 'bound_ip': 'test_value_3',
- 'clear_text': 'disable',
- 'ddns_auth': 'disable',
- 'ddns_domain': 'test_value_6',
- 'ddns_key': 'test_value_7',
- 'ddns_keyname': 'test_value_8',
- 'ddns_password': 'test_value_9',
- 'ddns_server': 'dyndns.org',
- 'ddns_server_ip': 'test_value_11',
- 'ddns_sn': 'test_value_12',
- 'ddns_ttl': '13',
- 'ddns_username': 'test_value_14',
- 'ddns_zone': 'test_value_15',
- 'ddnsid': '16',
- 'ssl_certificate': 'test_value_17',
- 'update_interval': '18',
- 'use_public_ip': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ddns.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ddns', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ddns_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ddns': {
- 'bound_ip': 'test_value_3',
- 'clear_text': 'disable',
- 'ddns_auth': 'disable',
- 'ddns_domain': 'test_value_6',
- 'ddns_key': 'test_value_7',
- 'ddns_keyname': 'test_value_8',
- 'ddns_password': 'test_value_9',
- 'ddns_server': 'dyndns.org',
- 'ddns_server_ip': 'test_value_11',
- 'ddns_sn': 'test_value_12',
- 'ddns_ttl': '13',
- 'ddns_username': 'test_value_14',
- 'ddns_zone': 'test_value_15',
- 'ddnsid': '16',
- 'ssl_certificate': 'test_value_17',
- 'update_interval': '18',
- 'use_public_ip': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ddns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'bound-ip': 'test_value_3',
- 'clear-text': 'disable',
- 'ddns-auth': 'disable',
- 'ddns-domain': 'test_value_6',
- 'ddns-key': 'test_value_7',
- 'ddns-keyname': 'test_value_8',
- 'ddns-password': 'test_value_9',
- 'ddns-server': 'dyndns.org',
- 'ddns-server-ip': 'test_value_11',
- 'ddns-sn': 'test_value_12',
- 'ddns-ttl': '13',
- 'ddns-username': 'test_value_14',
- 'ddns-zone': 'test_value_15',
- 'ddnsid': '16',
- 'ssl-certificate': 'test_value_17',
- 'update-interval': '18',
- 'use-public-ip': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'ddns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_ddns_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ddns': {
- 'random_attribute_not_valid': 'tag',
- 'bound_ip': 'test_value_3',
- 'clear_text': 'disable',
- 'ddns_auth': 'disable',
- 'ddns_domain': 'test_value_6',
- 'ddns_key': 'test_value_7',
- 'ddns_keyname': 'test_value_8',
- 'ddns_password': 'test_value_9',
- 'ddns_server': 'dyndns.org',
- 'ddns_server_ip': 'test_value_11',
- 'ddns_sn': 'test_value_12',
- 'ddns_ttl': '13',
- 'ddns_username': 'test_value_14',
- 'ddns_zone': 'test_value_15',
- 'ddnsid': '16',
- 'ssl_certificate': 'test_value_17',
- 'update_interval': '18',
- 'use_public_ip': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ddns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'bound-ip': 'test_value_3',
- 'clear-text': 'disable',
- 'ddns-auth': 'disable',
- 'ddns-domain': 'test_value_6',
- 'ddns-key': 'test_value_7',
- 'ddns-keyname': 'test_value_8',
- 'ddns-password': 'test_value_9',
- 'ddns-server': 'dyndns.org',
- 'ddns-server-ip': 'test_value_11',
- 'ddns-sn': 'test_value_12',
- 'ddns-ttl': '13',
- 'ddns-username': 'test_value_14',
- 'ddns-zone': 'test_value_15',
- 'ddnsid': '16',
- 'ssl-certificate': 'test_value_17',
- 'update-interval': '18',
- 'use-public-ip': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'ddns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_dedicated_mgmt.py b/test/units/modules/network/fortios/test_fortios_system_dedicated_mgmt.py
deleted file mode 100644
index 59a1b1c9a3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_dedicated_mgmt.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_dedicated_mgmt
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_dedicated_mgmt.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_dedicated_mgmt_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dedicated_mgmt': {
- 'default_gateway': 'test_value_3',
- 'dhcp_end_ip': 'test_value_4',
- 'dhcp_netmask': 'test_value_5',
- 'dhcp_server': 'enable',
- 'dhcp_start_ip': 'test_value_7',
- 'interface': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dedicated_mgmt.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'default-gateway': 'test_value_3',
- 'dhcp-end-ip': 'test_value_4',
- 'dhcp-netmask': 'test_value_5',
- 'dhcp-server': 'enable',
- 'dhcp-start-ip': 'test_value_7',
- 'interface': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'dedicated-mgmt', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dedicated_mgmt_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dedicated_mgmt': {
- 'default_gateway': 'test_value_3',
- 'dhcp_end_ip': 'test_value_4',
- 'dhcp_netmask': 'test_value_5',
- 'dhcp_server': 'enable',
- 'dhcp_start_ip': 'test_value_7',
- 'interface': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dedicated_mgmt.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'default-gateway': 'test_value_3',
- 'dhcp-end-ip': 'test_value_4',
- 'dhcp-netmask': 'test_value_5',
- 'dhcp-server': 'enable',
- 'dhcp-start-ip': 'test_value_7',
- 'interface': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'dedicated-mgmt', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dedicated_mgmt_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dedicated_mgmt': {
- 'default_gateway': 'test_value_3',
- 'dhcp_end_ip': 'test_value_4',
- 'dhcp_netmask': 'test_value_5',
- 'dhcp_server': 'enable',
- 'dhcp_start_ip': 'test_value_7',
- 'interface': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dedicated_mgmt.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'default-gateway': 'test_value_3',
- 'dhcp-end-ip': 'test_value_4',
- 'dhcp-netmask': 'test_value_5',
- 'dhcp-server': 'enable',
- 'dhcp-start-ip': 'test_value_7',
- 'interface': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'dedicated-mgmt', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_dedicated_mgmt_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dedicated_mgmt': {
- 'random_attribute_not_valid': 'tag',
- 'default_gateway': 'test_value_3',
- 'dhcp_end_ip': 'test_value_4',
- 'dhcp_netmask': 'test_value_5',
- 'dhcp_server': 'enable',
- 'dhcp_start_ip': 'test_value_7',
- 'interface': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dedicated_mgmt.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'default-gateway': 'test_value_3',
- 'dhcp-end-ip': 'test_value_4',
- 'dhcp-netmask': 'test_value_5',
- 'dhcp-server': 'enable',
- 'dhcp-start-ip': 'test_value_7',
- 'interface': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'dedicated-mgmt', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_dhcp6_server.py b/test/units/modules/network/fortios/test_fortios_system_dhcp6_server.py
deleted file mode 100644
index 3ce46e1ccd..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_dhcp6_server.py
+++ /dev/null
@@ -1,359 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_dhcp6_server
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_dhcp6_server.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_dhcp6_server_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dhcp6_server': {
- 'dns_search_list': 'delegated',
- 'dns_server1': 'test_value_4',
- 'dns_server2': 'test_value_5',
- 'dns_server3': 'test_value_6',
- 'dns_service': 'delegated',
- 'domain': 'test_value_8',
- 'id': '9',
- 'interface': 'test_value_10',
- 'ip_mode': 'range',
- 'lease_time': '12',
- 'option1': 'test_value_13',
- 'option2': 'test_value_14',
- 'option3': 'test_value_15',
- 'rapid_commit': 'disable',
- 'status': 'disable',
- 'subnet': 'test_value_18',
- 'upstream_interface': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp6_server.fortios_system_dhcp6(input_data, fos_instance)
-
- expected_data = {
- 'dns-search-list': 'delegated',
- 'dns-server1': 'test_value_4',
- 'dns-server2': 'test_value_5',
- 'dns-server3': 'test_value_6',
- 'dns-service': 'delegated',
- 'domain': 'test_value_8',
- 'id': '9',
- 'interface': 'test_value_10',
- 'ip-mode': 'range',
- 'lease-time': '12',
- 'option1': 'test_value_13',
- 'option2': 'test_value_14',
- 'option3': 'test_value_15',
- 'rapid-commit': 'disable',
- 'status': 'disable',
- 'subnet': 'test_value_18',
- 'upstream-interface': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('system.dhcp6', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dhcp6_server_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dhcp6_server': {
- 'dns_search_list': 'delegated',
- 'dns_server1': 'test_value_4',
- 'dns_server2': 'test_value_5',
- 'dns_server3': 'test_value_6',
- 'dns_service': 'delegated',
- 'domain': 'test_value_8',
- 'id': '9',
- 'interface': 'test_value_10',
- 'ip_mode': 'range',
- 'lease_time': '12',
- 'option1': 'test_value_13',
- 'option2': 'test_value_14',
- 'option3': 'test_value_15',
- 'rapid_commit': 'disable',
- 'status': 'disable',
- 'subnet': 'test_value_18',
- 'upstream_interface': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp6_server.fortios_system_dhcp6(input_data, fos_instance)
-
- expected_data = {
- 'dns-search-list': 'delegated',
- 'dns-server1': 'test_value_4',
- 'dns-server2': 'test_value_5',
- 'dns-server3': 'test_value_6',
- 'dns-service': 'delegated',
- 'domain': 'test_value_8',
- 'id': '9',
- 'interface': 'test_value_10',
- 'ip-mode': 'range',
- 'lease-time': '12',
- 'option1': 'test_value_13',
- 'option2': 'test_value_14',
- 'option3': 'test_value_15',
- 'rapid-commit': 'disable',
- 'status': 'disable',
- 'subnet': 'test_value_18',
- 'upstream-interface': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('system.dhcp6', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dhcp6_server_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_dhcp6_server': {
- 'dns_search_list': 'delegated',
- 'dns_server1': 'test_value_4',
- 'dns_server2': 'test_value_5',
- 'dns_server3': 'test_value_6',
- 'dns_service': 'delegated',
- 'domain': 'test_value_8',
- 'id': '9',
- 'interface': 'test_value_10',
- 'ip_mode': 'range',
- 'lease_time': '12',
- 'option1': 'test_value_13',
- 'option2': 'test_value_14',
- 'option3': 'test_value_15',
- 'rapid_commit': 'disable',
- 'status': 'disable',
- 'subnet': 'test_value_18',
- 'upstream_interface': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp6_server.fortios_system_dhcp6(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.dhcp6', 'server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dhcp6_server_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_dhcp6_server': {
- 'dns_search_list': 'delegated',
- 'dns_server1': 'test_value_4',
- 'dns_server2': 'test_value_5',
- 'dns_server3': 'test_value_6',
- 'dns_service': 'delegated',
- 'domain': 'test_value_8',
- 'id': '9',
- 'interface': 'test_value_10',
- 'ip_mode': 'range',
- 'lease_time': '12',
- 'option1': 'test_value_13',
- 'option2': 'test_value_14',
- 'option3': 'test_value_15',
- 'rapid_commit': 'disable',
- 'status': 'disable',
- 'subnet': 'test_value_18',
- 'upstream_interface': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp6_server.fortios_system_dhcp6(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.dhcp6', 'server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dhcp6_server_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dhcp6_server': {
- 'dns_search_list': 'delegated',
- 'dns_server1': 'test_value_4',
- 'dns_server2': 'test_value_5',
- 'dns_server3': 'test_value_6',
- 'dns_service': 'delegated',
- 'domain': 'test_value_8',
- 'id': '9',
- 'interface': 'test_value_10',
- 'ip_mode': 'range',
- 'lease_time': '12',
- 'option1': 'test_value_13',
- 'option2': 'test_value_14',
- 'option3': 'test_value_15',
- 'rapid_commit': 'disable',
- 'status': 'disable',
- 'subnet': 'test_value_18',
- 'upstream_interface': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp6_server.fortios_system_dhcp6(input_data, fos_instance)
-
- expected_data = {
- 'dns-search-list': 'delegated',
- 'dns-server1': 'test_value_4',
- 'dns-server2': 'test_value_5',
- 'dns-server3': 'test_value_6',
- 'dns-service': 'delegated',
- 'domain': 'test_value_8',
- 'id': '9',
- 'interface': 'test_value_10',
- 'ip-mode': 'range',
- 'lease-time': '12',
- 'option1': 'test_value_13',
- 'option2': 'test_value_14',
- 'option3': 'test_value_15',
- 'rapid-commit': 'disable',
- 'status': 'disable',
- 'subnet': 'test_value_18',
- 'upstream-interface': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('system.dhcp6', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_dhcp6_server_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dhcp6_server': {
- 'random_attribute_not_valid': 'tag',
- 'dns_search_list': 'delegated',
- 'dns_server1': 'test_value_4',
- 'dns_server2': 'test_value_5',
- 'dns_server3': 'test_value_6',
- 'dns_service': 'delegated',
- 'domain': 'test_value_8',
- 'id': '9',
- 'interface': 'test_value_10',
- 'ip_mode': 'range',
- 'lease_time': '12',
- 'option1': 'test_value_13',
- 'option2': 'test_value_14',
- 'option3': 'test_value_15',
- 'rapid_commit': 'disable',
- 'status': 'disable',
- 'subnet': 'test_value_18',
- 'upstream_interface': 'test_value_19'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp6_server.fortios_system_dhcp6(input_data, fos_instance)
-
- expected_data = {
- 'dns-search-list': 'delegated',
- 'dns-server1': 'test_value_4',
- 'dns-server2': 'test_value_5',
- 'dns-server3': 'test_value_6',
- 'dns-service': 'delegated',
- 'domain': 'test_value_8',
- 'id': '9',
- 'interface': 'test_value_10',
- 'ip-mode': 'range',
- 'lease-time': '12',
- 'option1': 'test_value_13',
- 'option2': 'test_value_14',
- 'option3': 'test_value_15',
- 'rapid-commit': 'disable',
- 'status': 'disable',
- 'subnet': 'test_value_18',
- 'upstream-interface': 'test_value_19'
- }
-
- set_method_mock.assert_called_with('system.dhcp6', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_dhcp_server.py b/test/units/modules/network/fortios/test_fortios_system_dhcp_server.py
deleted file mode 100644
index 8c97fcdfe7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_dhcp_server.py
+++ /dev/null
@@ -1,589 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_dhcp_server
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_dhcp_server.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_dhcp_server_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dhcp_server': {
- 'auto_configuration': 'disable',
- 'conflicted_ip_timeout': '4',
- 'ddns_auth': 'disable',
- 'ddns_key': 'test_value_6',
- 'ddns_keyname': 'test_value_7',
- 'ddns_server_ip': 'test_value_8',
- 'ddns_ttl': '9',
- 'ddns_update': 'disable',
- 'ddns_update_override': 'disable',
- 'ddns_zone': 'test_value_12',
- 'default_gateway': 'test_value_13',
- 'dns_server1': 'test_value_14',
- 'dns_server2': 'test_value_15',
- 'dns_server3': 'test_value_16',
- 'dns_service': 'local',
- 'domain': 'test_value_18',
- 'filename': 'test_value_19',
- 'forticlient_on_net_status': 'disable',
- 'id': '21',
- 'interface': 'test_value_22',
- 'ip_mode': 'range',
- 'ipsec_lease_hold': '24',
- 'lease_time': '25',
- 'mac_acl_default_action': 'assign',
- 'netmask': 'test_value_27',
- 'next_server': 'test_value_28',
- 'ntp_server1': 'test_value_29',
- 'ntp_server2': 'test_value_30',
- 'ntp_server3': 'test_value_31',
- 'ntp_service': 'local',
- 'server_type': 'regular',
- 'status': 'disable',
- 'timezone': '01',
- 'timezone_option': 'disable',
- 'vci_match': 'disable',
- 'wifi_ac1': 'test_value_38',
- 'wifi_ac2': 'test_value_39',
- 'wifi_ac3': 'test_value_40',
- 'wins_server1': 'test_value_41',
- 'wins_server2': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp_server.fortios_system_dhcp(input_data, fos_instance)
-
- expected_data = {
- 'auto-configuration': 'disable',
- 'conflicted-ip-timeout': '4',
- 'ddns-auth': 'disable',
- 'ddns-key': 'test_value_6',
- 'ddns-keyname': 'test_value_7',
- 'ddns-server-ip': 'test_value_8',
- 'ddns-ttl': '9',
- 'ddns-update': 'disable',
- 'ddns-update-override': 'disable',
- 'ddns-zone': 'test_value_12',
- 'default-gateway': 'test_value_13',
- 'dns-server1': 'test_value_14',
- 'dns-server2': 'test_value_15',
- 'dns-server3': 'test_value_16',
- 'dns-service': 'local',
- 'domain': 'test_value_18',
- 'filename': 'test_value_19',
- 'forticlient-on-net-status': 'disable',
- 'id': '21',
- 'interface': 'test_value_22',
- 'ip-mode': 'range',
- 'ipsec-lease-hold': '24',
- 'lease-time': '25',
- 'mac-acl-default-action': 'assign',
- 'netmask': 'test_value_27',
- 'next-server': 'test_value_28',
- 'ntp-server1': 'test_value_29',
- 'ntp-server2': 'test_value_30',
- 'ntp-server3': 'test_value_31',
- 'ntp-service': 'local',
- 'server-type': 'regular',
- 'status': 'disable',
- 'timezone': '01',
- 'timezone-option': 'disable',
- 'vci-match': 'disable',
- 'wifi-ac1': 'test_value_38',
- 'wifi-ac2': 'test_value_39',
- 'wifi-ac3': 'test_value_40',
- 'wins-server1': 'test_value_41',
- 'wins-server2': 'test_value_42'
- }
-
- set_method_mock.assert_called_with('system.dhcp', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dhcp_server_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dhcp_server': {
- 'auto_configuration': 'disable',
- 'conflicted_ip_timeout': '4',
- 'ddns_auth': 'disable',
- 'ddns_key': 'test_value_6',
- 'ddns_keyname': 'test_value_7',
- 'ddns_server_ip': 'test_value_8',
- 'ddns_ttl': '9',
- 'ddns_update': 'disable',
- 'ddns_update_override': 'disable',
- 'ddns_zone': 'test_value_12',
- 'default_gateway': 'test_value_13',
- 'dns_server1': 'test_value_14',
- 'dns_server2': 'test_value_15',
- 'dns_server3': 'test_value_16',
- 'dns_service': 'local',
- 'domain': 'test_value_18',
- 'filename': 'test_value_19',
- 'forticlient_on_net_status': 'disable',
- 'id': '21',
- 'interface': 'test_value_22',
- 'ip_mode': 'range',
- 'ipsec_lease_hold': '24',
- 'lease_time': '25',
- 'mac_acl_default_action': 'assign',
- 'netmask': 'test_value_27',
- 'next_server': 'test_value_28',
- 'ntp_server1': 'test_value_29',
- 'ntp_server2': 'test_value_30',
- 'ntp_server3': 'test_value_31',
- 'ntp_service': 'local',
- 'server_type': 'regular',
- 'status': 'disable',
- 'timezone': '01',
- 'timezone_option': 'disable',
- 'vci_match': 'disable',
- 'wifi_ac1': 'test_value_38',
- 'wifi_ac2': 'test_value_39',
- 'wifi_ac3': 'test_value_40',
- 'wins_server1': 'test_value_41',
- 'wins_server2': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp_server.fortios_system_dhcp(input_data, fos_instance)
-
- expected_data = {
- 'auto-configuration': 'disable',
- 'conflicted-ip-timeout': '4',
- 'ddns-auth': 'disable',
- 'ddns-key': 'test_value_6',
- 'ddns-keyname': 'test_value_7',
- 'ddns-server-ip': 'test_value_8',
- 'ddns-ttl': '9',
- 'ddns-update': 'disable',
- 'ddns-update-override': 'disable',
- 'ddns-zone': 'test_value_12',
- 'default-gateway': 'test_value_13',
- 'dns-server1': 'test_value_14',
- 'dns-server2': 'test_value_15',
- 'dns-server3': 'test_value_16',
- 'dns-service': 'local',
- 'domain': 'test_value_18',
- 'filename': 'test_value_19',
- 'forticlient-on-net-status': 'disable',
- 'id': '21',
- 'interface': 'test_value_22',
- 'ip-mode': 'range',
- 'ipsec-lease-hold': '24',
- 'lease-time': '25',
- 'mac-acl-default-action': 'assign',
- 'netmask': 'test_value_27',
- 'next-server': 'test_value_28',
- 'ntp-server1': 'test_value_29',
- 'ntp-server2': 'test_value_30',
- 'ntp-server3': 'test_value_31',
- 'ntp-service': 'local',
- 'server-type': 'regular',
- 'status': 'disable',
- 'timezone': '01',
- 'timezone-option': 'disable',
- 'vci-match': 'disable',
- 'wifi-ac1': 'test_value_38',
- 'wifi-ac2': 'test_value_39',
- 'wifi-ac3': 'test_value_40',
- 'wins-server1': 'test_value_41',
- 'wins-server2': 'test_value_42'
- }
-
- set_method_mock.assert_called_with('system.dhcp', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dhcp_server_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_dhcp_server': {
- 'auto_configuration': 'disable',
- 'conflicted_ip_timeout': '4',
- 'ddns_auth': 'disable',
- 'ddns_key': 'test_value_6',
- 'ddns_keyname': 'test_value_7',
- 'ddns_server_ip': 'test_value_8',
- 'ddns_ttl': '9',
- 'ddns_update': 'disable',
- 'ddns_update_override': 'disable',
- 'ddns_zone': 'test_value_12',
- 'default_gateway': 'test_value_13',
- 'dns_server1': 'test_value_14',
- 'dns_server2': 'test_value_15',
- 'dns_server3': 'test_value_16',
- 'dns_service': 'local',
- 'domain': 'test_value_18',
- 'filename': 'test_value_19',
- 'forticlient_on_net_status': 'disable',
- 'id': '21',
- 'interface': 'test_value_22',
- 'ip_mode': 'range',
- 'ipsec_lease_hold': '24',
- 'lease_time': '25',
- 'mac_acl_default_action': 'assign',
- 'netmask': 'test_value_27',
- 'next_server': 'test_value_28',
- 'ntp_server1': 'test_value_29',
- 'ntp_server2': 'test_value_30',
- 'ntp_server3': 'test_value_31',
- 'ntp_service': 'local',
- 'server_type': 'regular',
- 'status': 'disable',
- 'timezone': '01',
- 'timezone_option': 'disable',
- 'vci_match': 'disable',
- 'wifi_ac1': 'test_value_38',
- 'wifi_ac2': 'test_value_39',
- 'wifi_ac3': 'test_value_40',
- 'wins_server1': 'test_value_41',
- 'wins_server2': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp_server.fortios_system_dhcp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.dhcp', 'server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dhcp_server_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_dhcp_server': {
- 'auto_configuration': 'disable',
- 'conflicted_ip_timeout': '4',
- 'ddns_auth': 'disable',
- 'ddns_key': 'test_value_6',
- 'ddns_keyname': 'test_value_7',
- 'ddns_server_ip': 'test_value_8',
- 'ddns_ttl': '9',
- 'ddns_update': 'disable',
- 'ddns_update_override': 'disable',
- 'ddns_zone': 'test_value_12',
- 'default_gateway': 'test_value_13',
- 'dns_server1': 'test_value_14',
- 'dns_server2': 'test_value_15',
- 'dns_server3': 'test_value_16',
- 'dns_service': 'local',
- 'domain': 'test_value_18',
- 'filename': 'test_value_19',
- 'forticlient_on_net_status': 'disable',
- 'id': '21',
- 'interface': 'test_value_22',
- 'ip_mode': 'range',
- 'ipsec_lease_hold': '24',
- 'lease_time': '25',
- 'mac_acl_default_action': 'assign',
- 'netmask': 'test_value_27',
- 'next_server': 'test_value_28',
- 'ntp_server1': 'test_value_29',
- 'ntp_server2': 'test_value_30',
- 'ntp_server3': 'test_value_31',
- 'ntp_service': 'local',
- 'server_type': 'regular',
- 'status': 'disable',
- 'timezone': '01',
- 'timezone_option': 'disable',
- 'vci_match': 'disable',
- 'wifi_ac1': 'test_value_38',
- 'wifi_ac2': 'test_value_39',
- 'wifi_ac3': 'test_value_40',
- 'wins_server1': 'test_value_41',
- 'wins_server2': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp_server.fortios_system_dhcp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.dhcp', 'server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dhcp_server_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dhcp_server': {
- 'auto_configuration': 'disable',
- 'conflicted_ip_timeout': '4',
- 'ddns_auth': 'disable',
- 'ddns_key': 'test_value_6',
- 'ddns_keyname': 'test_value_7',
- 'ddns_server_ip': 'test_value_8',
- 'ddns_ttl': '9',
- 'ddns_update': 'disable',
- 'ddns_update_override': 'disable',
- 'ddns_zone': 'test_value_12',
- 'default_gateway': 'test_value_13',
- 'dns_server1': 'test_value_14',
- 'dns_server2': 'test_value_15',
- 'dns_server3': 'test_value_16',
- 'dns_service': 'local',
- 'domain': 'test_value_18',
- 'filename': 'test_value_19',
- 'forticlient_on_net_status': 'disable',
- 'id': '21',
- 'interface': 'test_value_22',
- 'ip_mode': 'range',
- 'ipsec_lease_hold': '24',
- 'lease_time': '25',
- 'mac_acl_default_action': 'assign',
- 'netmask': 'test_value_27',
- 'next_server': 'test_value_28',
- 'ntp_server1': 'test_value_29',
- 'ntp_server2': 'test_value_30',
- 'ntp_server3': 'test_value_31',
- 'ntp_service': 'local',
- 'server_type': 'regular',
- 'status': 'disable',
- 'timezone': '01',
- 'timezone_option': 'disable',
- 'vci_match': 'disable',
- 'wifi_ac1': 'test_value_38',
- 'wifi_ac2': 'test_value_39',
- 'wifi_ac3': 'test_value_40',
- 'wins_server1': 'test_value_41',
- 'wins_server2': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp_server.fortios_system_dhcp(input_data, fos_instance)
-
- expected_data = {
- 'auto-configuration': 'disable',
- 'conflicted-ip-timeout': '4',
- 'ddns-auth': 'disable',
- 'ddns-key': 'test_value_6',
- 'ddns-keyname': 'test_value_7',
- 'ddns-server-ip': 'test_value_8',
- 'ddns-ttl': '9',
- 'ddns-update': 'disable',
- 'ddns-update-override': 'disable',
- 'ddns-zone': 'test_value_12',
- 'default-gateway': 'test_value_13',
- 'dns-server1': 'test_value_14',
- 'dns-server2': 'test_value_15',
- 'dns-server3': 'test_value_16',
- 'dns-service': 'local',
- 'domain': 'test_value_18',
- 'filename': 'test_value_19',
- 'forticlient-on-net-status': 'disable',
- 'id': '21',
- 'interface': 'test_value_22',
- 'ip-mode': 'range',
- 'ipsec-lease-hold': '24',
- 'lease-time': '25',
- 'mac-acl-default-action': 'assign',
- 'netmask': 'test_value_27',
- 'next-server': 'test_value_28',
- 'ntp-server1': 'test_value_29',
- 'ntp-server2': 'test_value_30',
- 'ntp-server3': 'test_value_31',
- 'ntp-service': 'local',
- 'server-type': 'regular',
- 'status': 'disable',
- 'timezone': '01',
- 'timezone-option': 'disable',
- 'vci-match': 'disable',
- 'wifi-ac1': 'test_value_38',
- 'wifi-ac2': 'test_value_39',
- 'wifi-ac3': 'test_value_40',
- 'wins-server1': 'test_value_41',
- 'wins-server2': 'test_value_42'
- }
-
- set_method_mock.assert_called_with('system.dhcp', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_dhcp_server_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dhcp_server': {
- 'random_attribute_not_valid': 'tag',
- 'auto_configuration': 'disable',
- 'conflicted_ip_timeout': '4',
- 'ddns_auth': 'disable',
- 'ddns_key': 'test_value_6',
- 'ddns_keyname': 'test_value_7',
- 'ddns_server_ip': 'test_value_8',
- 'ddns_ttl': '9',
- 'ddns_update': 'disable',
- 'ddns_update_override': 'disable',
- 'ddns_zone': 'test_value_12',
- 'default_gateway': 'test_value_13',
- 'dns_server1': 'test_value_14',
- 'dns_server2': 'test_value_15',
- 'dns_server3': 'test_value_16',
- 'dns_service': 'local',
- 'domain': 'test_value_18',
- 'filename': 'test_value_19',
- 'forticlient_on_net_status': 'disable',
- 'id': '21',
- 'interface': 'test_value_22',
- 'ip_mode': 'range',
- 'ipsec_lease_hold': '24',
- 'lease_time': '25',
- 'mac_acl_default_action': 'assign',
- 'netmask': 'test_value_27',
- 'next_server': 'test_value_28',
- 'ntp_server1': 'test_value_29',
- 'ntp_server2': 'test_value_30',
- 'ntp_server3': 'test_value_31',
- 'ntp_service': 'local',
- 'server_type': 'regular',
- 'status': 'disable',
- 'timezone': '01',
- 'timezone_option': 'disable',
- 'vci_match': 'disable',
- 'wifi_ac1': 'test_value_38',
- 'wifi_ac2': 'test_value_39',
- 'wifi_ac3': 'test_value_40',
- 'wins_server1': 'test_value_41',
- 'wins_server2': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dhcp_server.fortios_system_dhcp(input_data, fos_instance)
-
- expected_data = {
- 'auto-configuration': 'disable',
- 'conflicted-ip-timeout': '4',
- 'ddns-auth': 'disable',
- 'ddns-key': 'test_value_6',
- 'ddns-keyname': 'test_value_7',
- 'ddns-server-ip': 'test_value_8',
- 'ddns-ttl': '9',
- 'ddns-update': 'disable',
- 'ddns-update-override': 'disable',
- 'ddns-zone': 'test_value_12',
- 'default-gateway': 'test_value_13',
- 'dns-server1': 'test_value_14',
- 'dns-server2': 'test_value_15',
- 'dns-server3': 'test_value_16',
- 'dns-service': 'local',
- 'domain': 'test_value_18',
- 'filename': 'test_value_19',
- 'forticlient-on-net-status': 'disable',
- 'id': '21',
- 'interface': 'test_value_22',
- 'ip-mode': 'range',
- 'ipsec-lease-hold': '24',
- 'lease-time': '25',
- 'mac-acl-default-action': 'assign',
- 'netmask': 'test_value_27',
- 'next-server': 'test_value_28',
- 'ntp-server1': 'test_value_29',
- 'ntp-server2': 'test_value_30',
- 'ntp-server3': 'test_value_31',
- 'ntp-service': 'local',
- 'server-type': 'regular',
- 'status': 'disable',
- 'timezone': '01',
- 'timezone-option': 'disable',
- 'vci-match': 'disable',
- 'wifi-ac1': 'test_value_38',
- 'wifi-ac2': 'test_value_39',
- 'wifi-ac3': 'test_value_40',
- 'wins-server1': 'test_value_41',
- 'wins-server2': 'test_value_42'
- }
-
- set_method_mock.assert_called_with('system.dhcp', 'server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_dns.py b/test/units/modules/network/fortios/test_fortios_system_dns.py
deleted file mode 100644
index 0cede4e283..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_dns.py
+++ /dev/null
@@ -1,223 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_dns
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_dns.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_dns_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns': {
- 'cache_notfound_responses': 'disable',
- 'dns_cache_limit': '4',
- 'dns_cache_ttl': '5',
- 'ip6_primary': 'test_value_6',
- 'ip6_secondary': 'test_value_7',
- 'primary': 'test_value_8',
- 'retry': '9',
- 'secondary': 'test_value_10',
- 'source_ip': '84.230.14.11',
- 'timeout': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'cache-notfound-responses': 'disable',
- 'dns-cache-limit': '4',
- 'dns-cache-ttl': '5',
- 'ip6-primary': 'test_value_6',
- 'ip6-secondary': 'test_value_7',
- 'primary': 'test_value_8',
- 'retry': '9',
- 'secondary': 'test_value_10',
- 'source-ip': '84.230.14.11',
- 'timeout': '12'
- }
-
- set_method_mock.assert_called_with('system', 'dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dns_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns': {
- 'cache_notfound_responses': 'disable',
- 'dns_cache_limit': '4',
- 'dns_cache_ttl': '5',
- 'ip6_primary': 'test_value_6',
- 'ip6_secondary': 'test_value_7',
- 'primary': 'test_value_8',
- 'retry': '9',
- 'secondary': 'test_value_10',
- 'source_ip': '84.230.14.11',
- 'timeout': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'cache-notfound-responses': 'disable',
- 'dns-cache-limit': '4',
- 'dns-cache-ttl': '5',
- 'ip6-primary': 'test_value_6',
- 'ip6-secondary': 'test_value_7',
- 'primary': 'test_value_8',
- 'retry': '9',
- 'secondary': 'test_value_10',
- 'source-ip': '84.230.14.11',
- 'timeout': '12'
- }
-
- set_method_mock.assert_called_with('system', 'dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dns_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns': {
- 'cache_notfound_responses': 'disable',
- 'dns_cache_limit': '4',
- 'dns_cache_ttl': '5',
- 'ip6_primary': 'test_value_6',
- 'ip6_secondary': 'test_value_7',
- 'primary': 'test_value_8',
- 'retry': '9',
- 'secondary': 'test_value_10',
- 'source_ip': '84.230.14.11',
- 'timeout': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'cache-notfound-responses': 'disable',
- 'dns-cache-limit': '4',
- 'dns-cache-ttl': '5',
- 'ip6-primary': 'test_value_6',
- 'ip6-secondary': 'test_value_7',
- 'primary': 'test_value_8',
- 'retry': '9',
- 'secondary': 'test_value_10',
- 'source-ip': '84.230.14.11',
- 'timeout': '12'
- }
-
- set_method_mock.assert_called_with('system', 'dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_dns_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns': {
- 'random_attribute_not_valid': 'tag',
- 'cache_notfound_responses': 'disable',
- 'dns_cache_limit': '4',
- 'dns_cache_ttl': '5',
- 'ip6_primary': 'test_value_6',
- 'ip6_secondary': 'test_value_7',
- 'primary': 'test_value_8',
- 'retry': '9',
- 'secondary': 'test_value_10',
- 'source_ip': '84.230.14.11',
- 'timeout': '12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'cache-notfound-responses': 'disable',
- 'dns-cache-limit': '4',
- 'dns-cache-ttl': '5',
- 'ip6-primary': 'test_value_6',
- 'ip6-secondary': 'test_value_7',
- 'primary': 'test_value_8',
- 'retry': '9',
- 'secondary': 'test_value_10',
- 'source-ip': '84.230.14.11',
- 'timeout': '12'
- }
-
- set_method_mock.assert_called_with('system', 'dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_dns_database.py b/test/units/modules/network/fortios/test_fortios_system_dns_database.py
deleted file mode 100644
index fca03aa782..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_dns_database.py
+++ /dev/null
@@ -1,319 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_dns_database
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_dns_database.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_dns_database_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns_database': {
- 'allow_transfer': 'test_value_3',
- 'authoritative': 'enable',
- 'contact': 'test_value_5',
- 'domain': 'test_value_6',
- 'forwarder': 'test_value_7',
- 'ip_master': 'test_value_8',
- 'name': 'default_name_9',
- 'primary_name': 'test_value_10',
- 'source_ip': '84.230.14.11',
- 'status': 'enable',
- 'ttl': '13',
- 'type': 'master',
- 'view': 'shadow'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_database.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-transfer': 'test_value_3',
- 'authoritative': 'enable',
- 'contact': 'test_value_5',
- 'domain': 'test_value_6',
- 'forwarder': 'test_value_7',
- 'ip-master': 'test_value_8',
- 'name': 'default_name_9',
- 'primary-name': 'test_value_10',
- 'source-ip': '84.230.14.11',
- 'status': 'enable',
- 'ttl': '13',
- 'type': 'master',
- 'view': 'shadow'
- }
-
- set_method_mock.assert_called_with('system', 'dns-database', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dns_database_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns_database': {
- 'allow_transfer': 'test_value_3',
- 'authoritative': 'enable',
- 'contact': 'test_value_5',
- 'domain': 'test_value_6',
- 'forwarder': 'test_value_7',
- 'ip_master': 'test_value_8',
- 'name': 'default_name_9',
- 'primary_name': 'test_value_10',
- 'source_ip': '84.230.14.11',
- 'status': 'enable',
- 'ttl': '13',
- 'type': 'master',
- 'view': 'shadow'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_database.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-transfer': 'test_value_3',
- 'authoritative': 'enable',
- 'contact': 'test_value_5',
- 'domain': 'test_value_6',
- 'forwarder': 'test_value_7',
- 'ip-master': 'test_value_8',
- 'name': 'default_name_9',
- 'primary-name': 'test_value_10',
- 'source-ip': '84.230.14.11',
- 'status': 'enable',
- 'ttl': '13',
- 'type': 'master',
- 'view': 'shadow'
- }
-
- set_method_mock.assert_called_with('system', 'dns-database', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dns_database_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_dns_database': {
- 'allow_transfer': 'test_value_3',
- 'authoritative': 'enable',
- 'contact': 'test_value_5',
- 'domain': 'test_value_6',
- 'forwarder': 'test_value_7',
- 'ip_master': 'test_value_8',
- 'name': 'default_name_9',
- 'primary_name': 'test_value_10',
- 'source_ip': '84.230.14.11',
- 'status': 'enable',
- 'ttl': '13',
- 'type': 'master',
- 'view': 'shadow'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_database.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'dns-database', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dns_database_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_dns_database': {
- 'allow_transfer': 'test_value_3',
- 'authoritative': 'enable',
- 'contact': 'test_value_5',
- 'domain': 'test_value_6',
- 'forwarder': 'test_value_7',
- 'ip_master': 'test_value_8',
- 'name': 'default_name_9',
- 'primary_name': 'test_value_10',
- 'source_ip': '84.230.14.11',
- 'status': 'enable',
- 'ttl': '13',
- 'type': 'master',
- 'view': 'shadow'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_database.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'dns-database', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dns_database_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns_database': {
- 'allow_transfer': 'test_value_3',
- 'authoritative': 'enable',
- 'contact': 'test_value_5',
- 'domain': 'test_value_6',
- 'forwarder': 'test_value_7',
- 'ip_master': 'test_value_8',
- 'name': 'default_name_9',
- 'primary_name': 'test_value_10',
- 'source_ip': '84.230.14.11',
- 'status': 'enable',
- 'ttl': '13',
- 'type': 'master',
- 'view': 'shadow'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_database.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-transfer': 'test_value_3',
- 'authoritative': 'enable',
- 'contact': 'test_value_5',
- 'domain': 'test_value_6',
- 'forwarder': 'test_value_7',
- 'ip-master': 'test_value_8',
- 'name': 'default_name_9',
- 'primary-name': 'test_value_10',
- 'source-ip': '84.230.14.11',
- 'status': 'enable',
- 'ttl': '13',
- 'type': 'master',
- 'view': 'shadow'
- }
-
- set_method_mock.assert_called_with('system', 'dns-database', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_dns_database_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns_database': {
- 'random_attribute_not_valid': 'tag',
- 'allow_transfer': 'test_value_3',
- 'authoritative': 'enable',
- 'contact': 'test_value_5',
- 'domain': 'test_value_6',
- 'forwarder': 'test_value_7',
- 'ip_master': 'test_value_8',
- 'name': 'default_name_9',
- 'primary_name': 'test_value_10',
- 'source_ip': '84.230.14.11',
- 'status': 'enable',
- 'ttl': '13',
- 'type': 'master',
- 'view': 'shadow'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_database.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-transfer': 'test_value_3',
- 'authoritative': 'enable',
- 'contact': 'test_value_5',
- 'domain': 'test_value_6',
- 'forwarder': 'test_value_7',
- 'ip-master': 'test_value_8',
- 'name': 'default_name_9',
- 'primary-name': 'test_value_10',
- 'source-ip': '84.230.14.11',
- 'status': 'enable',
- 'ttl': '13',
- 'type': 'master',
- 'view': 'shadow'
- }
-
- set_method_mock.assert_called_with('system', 'dns-database', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_dns_server.py b/test/units/modules/network/fortios/test_fortios_system_dns_server.py
deleted file mode 100644
index d497c1d4f0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_dns_server.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_dns_server
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_dns_server.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_dns_server_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns_server': {
- 'dnsfilter_profile': 'test_value_3',
- 'mode': 'recursive',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'dnsfilter-profile': 'test_value_3',
- 'mode': 'recursive',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'dns-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dns_server_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns_server': {
- 'dnsfilter_profile': 'test_value_3',
- 'mode': 'recursive',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'dnsfilter-profile': 'test_value_3',
- 'mode': 'recursive',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'dns-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dns_server_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_dns_server': {
- 'dnsfilter_profile': 'test_value_3',
- 'mode': 'recursive',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_server.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'dns-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dns_server_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_dns_server': {
- 'dnsfilter_profile': 'test_value_3',
- 'mode': 'recursive',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_server.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'dns-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dns_server_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns_server': {
- 'dnsfilter_profile': 'test_value_3',
- 'mode': 'recursive',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'dnsfilter-profile': 'test_value_3',
- 'mode': 'recursive',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'dns-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_dns_server_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dns_server': {
- 'random_attribute_not_valid': 'tag',
- 'dnsfilter_profile': 'test_value_3',
- 'mode': 'recursive',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dns_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'dnsfilter-profile': 'test_value_3',
- 'mode': 'recursive',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'dns-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_dscp_based_priority.py b/test/units/modules/network/fortios/test_fortios_system_dscp_based_priority.py
deleted file mode 100644
index f52cb59ad3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_dscp_based_priority.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_dscp_based_priority
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_dscp_based_priority.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_dscp_based_priority_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dscp_based_priority': {
- 'ds': '3',
- 'id': '4',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dscp_based_priority.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ds': '3',
- 'id': '4',
- 'priority': 'low'
- }
-
- set_method_mock.assert_called_with('system', 'dscp-based-priority', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dscp_based_priority_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dscp_based_priority': {
- 'ds': '3',
- 'id': '4',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dscp_based_priority.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ds': '3',
- 'id': '4',
- 'priority': 'low'
- }
-
- set_method_mock.assert_called_with('system', 'dscp-based-priority', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dscp_based_priority_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_dscp_based_priority': {
- 'ds': '3',
- 'id': '4',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dscp_based_priority.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'dscp-based-priority', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_dscp_based_priority_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_dscp_based_priority': {
- 'ds': '3',
- 'id': '4',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dscp_based_priority.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'dscp-based-priority', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_dscp_based_priority_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dscp_based_priority': {
- 'ds': '3',
- 'id': '4',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dscp_based_priority.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ds': '3',
- 'id': '4',
- 'priority': 'low'
- }
-
- set_method_mock.assert_called_with('system', 'dscp-based-priority', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_dscp_based_priority_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_dscp_based_priority': {
- 'random_attribute_not_valid': 'tag',
- 'ds': '3',
- 'id': '4',
- 'priority': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_dscp_based_priority.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ds': '3',
- 'id': '4',
- 'priority': 'low'
- }
-
- set_method_mock.assert_called_with('system', 'dscp-based-priority', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_email_server.py b/test/units/modules/network/fortios/test_fortios_system_email_server.py
deleted file mode 100644
index c191d264fd..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_email_server.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_email_server
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_email_server.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_email_server_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_email_server': {
- 'authenticate': 'enable',
- 'password': 'test_value_4',
- 'port': '5',
- 'reply_to': 'test_value_6',
- 'security': 'none',
- 'server': '192.168.100.8',
- 'source_ip': '84.230.14.9',
- 'source_ip6': 'test_value_10',
- 'ssl_min_proto_version': 'default',
- 'type': 'custom',
- 'username': 'test_value_13',
- 'validate_server': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_email_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'authenticate': 'enable',
- 'password': 'test_value_4',
- 'port': '5',
- 'reply-to': 'test_value_6',
- 'security': 'none',
- 'server': '192.168.100.8',
- 'source-ip': '84.230.14.9',
- 'source-ip6': 'test_value_10',
- 'ssl-min-proto-version': 'default',
- 'type': 'custom',
- 'username': 'test_value_13',
- 'validate-server': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'email-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_email_server_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_email_server': {
- 'authenticate': 'enable',
- 'password': 'test_value_4',
- 'port': '5',
- 'reply_to': 'test_value_6',
- 'security': 'none',
- 'server': '192.168.100.8',
- 'source_ip': '84.230.14.9',
- 'source_ip6': 'test_value_10',
- 'ssl_min_proto_version': 'default',
- 'type': 'custom',
- 'username': 'test_value_13',
- 'validate_server': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_email_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'authenticate': 'enable',
- 'password': 'test_value_4',
- 'port': '5',
- 'reply-to': 'test_value_6',
- 'security': 'none',
- 'server': '192.168.100.8',
- 'source-ip': '84.230.14.9',
- 'source-ip6': 'test_value_10',
- 'ssl-min-proto-version': 'default',
- 'type': 'custom',
- 'username': 'test_value_13',
- 'validate-server': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'email-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_email_server_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_email_server': {
- 'authenticate': 'enable',
- 'password': 'test_value_4',
- 'port': '5',
- 'reply_to': 'test_value_6',
- 'security': 'none',
- 'server': '192.168.100.8',
- 'source_ip': '84.230.14.9',
- 'source_ip6': 'test_value_10',
- 'ssl_min_proto_version': 'default',
- 'type': 'custom',
- 'username': 'test_value_13',
- 'validate_server': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_email_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'authenticate': 'enable',
- 'password': 'test_value_4',
- 'port': '5',
- 'reply-to': 'test_value_6',
- 'security': 'none',
- 'server': '192.168.100.8',
- 'source-ip': '84.230.14.9',
- 'source-ip6': 'test_value_10',
- 'ssl-min-proto-version': 'default',
- 'type': 'custom',
- 'username': 'test_value_13',
- 'validate-server': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'email-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_email_server_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_email_server': {
- 'random_attribute_not_valid': 'tag',
- 'authenticate': 'enable',
- 'password': 'test_value_4',
- 'port': '5',
- 'reply_to': 'test_value_6',
- 'security': 'none',
- 'server': '192.168.100.8',
- 'source_ip': '84.230.14.9',
- 'source_ip6': 'test_value_10',
- 'ssl_min_proto_version': 'default',
- 'type': 'custom',
- 'username': 'test_value_13',
- 'validate_server': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_email_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'authenticate': 'enable',
- 'password': 'test_value_4',
- 'port': '5',
- 'reply-to': 'test_value_6',
- 'security': 'none',
- 'server': '192.168.100.8',
- 'source-ip': '84.230.14.9',
- 'source-ip6': 'test_value_10',
- 'ssl-min-proto-version': 'default',
- 'type': 'custom',
- 'username': 'test_value_13',
- 'validate-server': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'email-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_external_resource.py b/test/units/modules/network/fortios/test_fortios_system_external_resource.py
deleted file mode 100644
index 2d6c5f1db9..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_external_resource.py
+++ /dev/null
@@ -1,259 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_external_resource
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_external_resource.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_external_resource_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_external_resource': {
- 'category': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'refresh_rate': '6',
- 'resource': 'test_value_7',
- 'status': 'enable',
- 'type': 'category'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_external_resource.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'category': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'refresh-rate': '6',
- 'resource': 'test_value_7',
- 'status': 'enable',
- 'type': 'category'
- }
-
- set_method_mock.assert_called_with('system', 'external-resource', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_external_resource_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_external_resource': {
- 'category': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'refresh_rate': '6',
- 'resource': 'test_value_7',
- 'status': 'enable',
- 'type': 'category'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_external_resource.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'category': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'refresh-rate': '6',
- 'resource': 'test_value_7',
- 'status': 'enable',
- 'type': 'category'
- }
-
- set_method_mock.assert_called_with('system', 'external-resource', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_external_resource_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_external_resource': {
- 'category': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'refresh_rate': '6',
- 'resource': 'test_value_7',
- 'status': 'enable',
- 'type': 'category'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_external_resource.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'external-resource', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_external_resource_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_external_resource': {
- 'category': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'refresh_rate': '6',
- 'resource': 'test_value_7',
- 'status': 'enable',
- 'type': 'category'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_external_resource.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'external-resource', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_external_resource_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_external_resource': {
- 'category': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'refresh_rate': '6',
- 'resource': 'test_value_7',
- 'status': 'enable',
- 'type': 'category'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_external_resource.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'category': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'refresh-rate': '6',
- 'resource': 'test_value_7',
- 'status': 'enable',
- 'type': 'category'
- }
-
- set_method_mock.assert_called_with('system', 'external-resource', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_external_resource_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_external_resource': {
- 'random_attribute_not_valid': 'tag',
- 'category': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'refresh_rate': '6',
- 'resource': 'test_value_7',
- 'status': 'enable',
- 'type': 'category'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_external_resource.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'category': '3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'refresh-rate': '6',
- 'resource': 'test_value_7',
- 'status': 'enable',
- 'type': 'category'
- }
-
- set_method_mock.assert_called_with('system', 'external-resource', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_fips_cc.py b/test/units/modules/network/fortios/test_fortios_system_fips_cc.py
deleted file mode 100644
index 5fdda3650d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_fips_cc.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_fips_cc
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_fips_cc.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_fips_cc_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fips_cc': {
- 'entropy_token': 'enable',
- 'key_generation_self_test': 'enable',
- 'self_test_period': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fips_cc.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'entropy-token': 'enable',
- 'key-generation-self-test': 'enable',
- 'self-test-period': '5'
- }
-
- set_method_mock.assert_called_with('system', 'fips-cc', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_fips_cc_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fips_cc': {
- 'entropy_token': 'enable',
- 'key_generation_self_test': 'enable',
- 'self_test_period': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fips_cc.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'entropy-token': 'enable',
- 'key-generation-self-test': 'enable',
- 'self-test-period': '5'
- }
-
- set_method_mock.assert_called_with('system', 'fips-cc', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_fips_cc_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fips_cc': {
- 'entropy_token': 'enable',
- 'key_generation_self_test': 'enable',
- 'self_test_period': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fips_cc.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'entropy-token': 'enable',
- 'key-generation-self-test': 'enable',
- 'self-test-period': '5'
- }
-
- set_method_mock.assert_called_with('system', 'fips-cc', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_fips_cc_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fips_cc': {
- 'random_attribute_not_valid': 'tag',
- 'entropy_token': 'enable',
- 'key_generation_self_test': 'enable',
- 'self_test_period': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fips_cc.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'entropy-token': 'enable',
- 'key-generation-self-test': 'enable',
- 'self-test-period': '5'
- }
-
- set_method_mock.assert_called_with('system', 'fips-cc', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_firmware_upgrade.py b/test/units/modules/network/fortios/test_fortios_system_firmware_upgrade.py
deleted file mode 100644
index 58558fd881..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_firmware_upgrade.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_firmware_upgrade
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_firmware_upgrade.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_firmware_upgrade_execute(mocker):
- execute_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- execute_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.execute', return_value=execute_method_result)
-
- input_data = {
- 'username': 'admin',
- 'system_firmware': {
- 'file_content': 'test_value_3',
- 'filename': 'test_value_4',
- 'format_partition': 'test_value_5',
- 'source': 'upload'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_firmware_upgrade.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'file-content': 'test_value_3',
- 'filename': 'test_value_4',
- 'format-partition': 'test_value_5',
- 'source': 'upload'
- }
-
- execute_method_mock.assert_called_with('system', 'firmware/upgrade', data=ANY, vdom='root')
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_fm.py b/test/units/modules/network/fortios/test_fortios_system_fm.py
deleted file mode 100644
index 0ef08f7564..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_fm.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_fm
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_fm.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_fm_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fm': {
- 'auto_backup': 'enable',
- 'id': '4',
- 'ip': 'test_value_5',
- 'ipsec': 'enable',
- 'scheduled_config_restore': 'enable',
- 'status': 'enable',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fm.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auto-backup': 'enable',
- 'id': '4',
- 'ip': 'test_value_5',
- 'ipsec': 'enable',
- 'scheduled-config-restore': 'enable',
- 'status': 'enable',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'fm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_fm_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fm': {
- 'auto_backup': 'enable',
- 'id': '4',
- 'ip': 'test_value_5',
- 'ipsec': 'enable',
- 'scheduled_config_restore': 'enable',
- 'status': 'enable',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fm.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auto-backup': 'enable',
- 'id': '4',
- 'ip': 'test_value_5',
- 'ipsec': 'enable',
- 'scheduled-config-restore': 'enable',
- 'status': 'enable',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'fm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_fm_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fm': {
- 'auto_backup': 'enable',
- 'id': '4',
- 'ip': 'test_value_5',
- 'ipsec': 'enable',
- 'scheduled_config_restore': 'enable',
- 'status': 'enable',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fm.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auto-backup': 'enable',
- 'id': '4',
- 'ip': 'test_value_5',
- 'ipsec': 'enable',
- 'scheduled-config-restore': 'enable',
- 'status': 'enable',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'fm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_fm_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fm': {
- 'random_attribute_not_valid': 'tag',
- 'auto_backup': 'enable',
- 'id': '4',
- 'ip': 'test_value_5',
- 'ipsec': 'enable',
- 'scheduled_config_restore': 'enable',
- 'status': 'enable',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fm.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auto-backup': 'enable',
- 'id': '4',
- 'ip': 'test_value_5',
- 'ipsec': 'enable',
- 'scheduled-config-restore': 'enable',
- 'status': 'enable',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'fm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_fortiguard.py b/test/units/modules/network/fortios/test_fortios_system_fortiguard.py
deleted file mode 100644
index 6b60c94331..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_fortiguard.py
+++ /dev/null
@@ -1,391 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_fortiguard
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_fortiguard.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_fortiguard_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortiguard': {
- 'antispam_cache': 'enable',
- 'antispam_cache_mpercent': '4',
- 'antispam_cache_ttl': '5',
- 'antispam_expiration': '6',
- 'antispam_force_off': 'enable',
- 'antispam_license': '8',
- 'antispam_timeout': '9',
- 'auto_join_forticloud': 'enable',
- 'ddns_server_ip': 'test_value_11',
- 'ddns_server_port': '12',
- 'load_balance_servers': '13',
- 'outbreak_prevention_cache': 'enable',
- 'outbreak_prevention_cache_mpercent': '15',
- 'outbreak_prevention_cache_ttl': '16',
- 'outbreak_prevention_expiration': '17',
- 'outbreak_prevention_force_off': 'enable',
- 'outbreak_prevention_license': '19',
- 'outbreak_prevention_timeout': '20',
- 'port': '53',
- 'sdns_server_ip': 'test_value_22',
- 'sdns_server_port': '23',
- 'service_account_id': 'test_value_24',
- 'source_ip': '84.230.14.25',
- 'source_ip6': 'test_value_26',
- 'update_server_location': 'usa',
- 'webfilter_cache': 'enable',
- 'webfilter_cache_ttl': '29',
- 'webfilter_expiration': '30',
- 'webfilter_force_off': 'enable',
- 'webfilter_license': '32',
- 'webfilter_timeout': '33'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortiguard.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'antispam-cache': 'enable',
- 'antispam-cache-mpercent': '4',
- 'antispam-cache-ttl': '5',
- 'antispam-expiration': '6',
- 'antispam-force-off': 'enable',
- 'antispam-license': '8',
- 'antispam-timeout': '9',
- 'auto-join-forticloud': 'enable',
- 'ddns-server-ip': 'test_value_11',
- 'ddns-server-port': '12',
- 'load-balance-servers': '13',
- 'outbreak-prevention-cache': 'enable',
- 'outbreak-prevention-cache-mpercent': '15',
- 'outbreak-prevention-cache-ttl': '16',
- 'outbreak-prevention-expiration': '17',
- 'outbreak-prevention-force-off': 'enable',
- 'outbreak-prevention-license': '19',
- 'outbreak-prevention-timeout': '20',
- 'port': '53',
- 'sdns-server-ip': 'test_value_22',
- 'sdns-server-port': '23',
- 'service-account-id': 'test_value_24',
- 'source-ip': '84.230.14.25',
- 'source-ip6': 'test_value_26',
- 'update-server-location': 'usa',
- 'webfilter-cache': 'enable',
- 'webfilter-cache-ttl': '29',
- 'webfilter-expiration': '30',
- 'webfilter-force-off': 'enable',
- 'webfilter-license': '32',
- 'webfilter-timeout': '33'
- }
-
- set_method_mock.assert_called_with('system', 'fortiguard', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_fortiguard_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortiguard': {
- 'antispam_cache': 'enable',
- 'antispam_cache_mpercent': '4',
- 'antispam_cache_ttl': '5',
- 'antispam_expiration': '6',
- 'antispam_force_off': 'enable',
- 'antispam_license': '8',
- 'antispam_timeout': '9',
- 'auto_join_forticloud': 'enable',
- 'ddns_server_ip': 'test_value_11',
- 'ddns_server_port': '12',
- 'load_balance_servers': '13',
- 'outbreak_prevention_cache': 'enable',
- 'outbreak_prevention_cache_mpercent': '15',
- 'outbreak_prevention_cache_ttl': '16',
- 'outbreak_prevention_expiration': '17',
- 'outbreak_prevention_force_off': 'enable',
- 'outbreak_prevention_license': '19',
- 'outbreak_prevention_timeout': '20',
- 'port': '53',
- 'sdns_server_ip': 'test_value_22',
- 'sdns_server_port': '23',
- 'service_account_id': 'test_value_24',
- 'source_ip': '84.230.14.25',
- 'source_ip6': 'test_value_26',
- 'update_server_location': 'usa',
- 'webfilter_cache': 'enable',
- 'webfilter_cache_ttl': '29',
- 'webfilter_expiration': '30',
- 'webfilter_force_off': 'enable',
- 'webfilter_license': '32',
- 'webfilter_timeout': '33'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortiguard.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'antispam-cache': 'enable',
- 'antispam-cache-mpercent': '4',
- 'antispam-cache-ttl': '5',
- 'antispam-expiration': '6',
- 'antispam-force-off': 'enable',
- 'antispam-license': '8',
- 'antispam-timeout': '9',
- 'auto-join-forticloud': 'enable',
- 'ddns-server-ip': 'test_value_11',
- 'ddns-server-port': '12',
- 'load-balance-servers': '13',
- 'outbreak-prevention-cache': 'enable',
- 'outbreak-prevention-cache-mpercent': '15',
- 'outbreak-prevention-cache-ttl': '16',
- 'outbreak-prevention-expiration': '17',
- 'outbreak-prevention-force-off': 'enable',
- 'outbreak-prevention-license': '19',
- 'outbreak-prevention-timeout': '20',
- 'port': '53',
- 'sdns-server-ip': 'test_value_22',
- 'sdns-server-port': '23',
- 'service-account-id': 'test_value_24',
- 'source-ip': '84.230.14.25',
- 'source-ip6': 'test_value_26',
- 'update-server-location': 'usa',
- 'webfilter-cache': 'enable',
- 'webfilter-cache-ttl': '29',
- 'webfilter-expiration': '30',
- 'webfilter-force-off': 'enable',
- 'webfilter-license': '32',
- 'webfilter-timeout': '33'
- }
-
- set_method_mock.assert_called_with('system', 'fortiguard', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_fortiguard_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortiguard': {
- 'antispam_cache': 'enable',
- 'antispam_cache_mpercent': '4',
- 'antispam_cache_ttl': '5',
- 'antispam_expiration': '6',
- 'antispam_force_off': 'enable',
- 'antispam_license': '8',
- 'antispam_timeout': '9',
- 'auto_join_forticloud': 'enable',
- 'ddns_server_ip': 'test_value_11',
- 'ddns_server_port': '12',
- 'load_balance_servers': '13',
- 'outbreak_prevention_cache': 'enable',
- 'outbreak_prevention_cache_mpercent': '15',
- 'outbreak_prevention_cache_ttl': '16',
- 'outbreak_prevention_expiration': '17',
- 'outbreak_prevention_force_off': 'enable',
- 'outbreak_prevention_license': '19',
- 'outbreak_prevention_timeout': '20',
- 'port': '53',
- 'sdns_server_ip': 'test_value_22',
- 'sdns_server_port': '23',
- 'service_account_id': 'test_value_24',
- 'source_ip': '84.230.14.25',
- 'source_ip6': 'test_value_26',
- 'update_server_location': 'usa',
- 'webfilter_cache': 'enable',
- 'webfilter_cache_ttl': '29',
- 'webfilter_expiration': '30',
- 'webfilter_force_off': 'enable',
- 'webfilter_license': '32',
- 'webfilter_timeout': '33'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortiguard.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'antispam-cache': 'enable',
- 'antispam-cache-mpercent': '4',
- 'antispam-cache-ttl': '5',
- 'antispam-expiration': '6',
- 'antispam-force-off': 'enable',
- 'antispam-license': '8',
- 'antispam-timeout': '9',
- 'auto-join-forticloud': 'enable',
- 'ddns-server-ip': 'test_value_11',
- 'ddns-server-port': '12',
- 'load-balance-servers': '13',
- 'outbreak-prevention-cache': 'enable',
- 'outbreak-prevention-cache-mpercent': '15',
- 'outbreak-prevention-cache-ttl': '16',
- 'outbreak-prevention-expiration': '17',
- 'outbreak-prevention-force-off': 'enable',
- 'outbreak-prevention-license': '19',
- 'outbreak-prevention-timeout': '20',
- 'port': '53',
- 'sdns-server-ip': 'test_value_22',
- 'sdns-server-port': '23',
- 'service-account-id': 'test_value_24',
- 'source-ip': '84.230.14.25',
- 'source-ip6': 'test_value_26',
- 'update-server-location': 'usa',
- 'webfilter-cache': 'enable',
- 'webfilter-cache-ttl': '29',
- 'webfilter-expiration': '30',
- 'webfilter-force-off': 'enable',
- 'webfilter-license': '32',
- 'webfilter-timeout': '33'
- }
-
- set_method_mock.assert_called_with('system', 'fortiguard', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_fortiguard_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortiguard': {
- 'random_attribute_not_valid': 'tag',
- 'antispam_cache': 'enable',
- 'antispam_cache_mpercent': '4',
- 'antispam_cache_ttl': '5',
- 'antispam_expiration': '6',
- 'antispam_force_off': 'enable',
- 'antispam_license': '8',
- 'antispam_timeout': '9',
- 'auto_join_forticloud': 'enable',
- 'ddns_server_ip': 'test_value_11',
- 'ddns_server_port': '12',
- 'load_balance_servers': '13',
- 'outbreak_prevention_cache': 'enable',
- 'outbreak_prevention_cache_mpercent': '15',
- 'outbreak_prevention_cache_ttl': '16',
- 'outbreak_prevention_expiration': '17',
- 'outbreak_prevention_force_off': 'enable',
- 'outbreak_prevention_license': '19',
- 'outbreak_prevention_timeout': '20',
- 'port': '53',
- 'sdns_server_ip': 'test_value_22',
- 'sdns_server_port': '23',
- 'service_account_id': 'test_value_24',
- 'source_ip': '84.230.14.25',
- 'source_ip6': 'test_value_26',
- 'update_server_location': 'usa',
- 'webfilter_cache': 'enable',
- 'webfilter_cache_ttl': '29',
- 'webfilter_expiration': '30',
- 'webfilter_force_off': 'enable',
- 'webfilter_license': '32',
- 'webfilter_timeout': '33'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortiguard.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'antispam-cache': 'enable',
- 'antispam-cache-mpercent': '4',
- 'antispam-cache-ttl': '5',
- 'antispam-expiration': '6',
- 'antispam-force-off': 'enable',
- 'antispam-license': '8',
- 'antispam-timeout': '9',
- 'auto-join-forticloud': 'enable',
- 'ddns-server-ip': 'test_value_11',
- 'ddns-server-port': '12',
- 'load-balance-servers': '13',
- 'outbreak-prevention-cache': 'enable',
- 'outbreak-prevention-cache-mpercent': '15',
- 'outbreak-prevention-cache-ttl': '16',
- 'outbreak-prevention-expiration': '17',
- 'outbreak-prevention-force-off': 'enable',
- 'outbreak-prevention-license': '19',
- 'outbreak-prevention-timeout': '20',
- 'port': '53',
- 'sdns-server-ip': 'test_value_22',
- 'sdns-server-port': '23',
- 'service-account-id': 'test_value_24',
- 'source-ip': '84.230.14.25',
- 'source-ip6': 'test_value_26',
- 'update-server-location': 'usa',
- 'webfilter-cache': 'enable',
- 'webfilter-cache-ttl': '29',
- 'webfilter-expiration': '30',
- 'webfilter-force-off': 'enable',
- 'webfilter-license': '32',
- 'webfilter-timeout': '33'
- }
-
- set_method_mock.assert_called_with('system', 'fortiguard', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_fortimanager.py b/test/units/modules/network/fortios/test_fortios_system_fortimanager.py
deleted file mode 100644
index a4ec27e421..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_fortimanager.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_fortimanager
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_fortimanager.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_fortimanager_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortimanager': {
- 'central_management': 'enable',
- 'central_mgmt_auto_backup': 'enable',
- 'central_mgmt_schedule_config_restore': 'enable',
- 'central_mgmt_schedule_script_restore': 'enable',
- 'ip': 'test_value_7',
- 'ipsec': 'enable',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortimanager.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'central-management': 'enable',
- 'central-mgmt-auto-backup': 'enable',
- 'central-mgmt-schedule-config-restore': 'enable',
- 'central-mgmt-schedule-script-restore': 'enable',
- 'ip': 'test_value_7',
- 'ipsec': 'enable',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'fortimanager', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_fortimanager_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortimanager': {
- 'central_management': 'enable',
- 'central_mgmt_auto_backup': 'enable',
- 'central_mgmt_schedule_config_restore': 'enable',
- 'central_mgmt_schedule_script_restore': 'enable',
- 'ip': 'test_value_7',
- 'ipsec': 'enable',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortimanager.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'central-management': 'enable',
- 'central-mgmt-auto-backup': 'enable',
- 'central-mgmt-schedule-config-restore': 'enable',
- 'central-mgmt-schedule-script-restore': 'enable',
- 'ip': 'test_value_7',
- 'ipsec': 'enable',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'fortimanager', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_fortimanager_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortimanager': {
- 'central_management': 'enable',
- 'central_mgmt_auto_backup': 'enable',
- 'central_mgmt_schedule_config_restore': 'enable',
- 'central_mgmt_schedule_script_restore': 'enable',
- 'ip': 'test_value_7',
- 'ipsec': 'enable',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortimanager.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'central-management': 'enable',
- 'central-mgmt-auto-backup': 'enable',
- 'central-mgmt-schedule-config-restore': 'enable',
- 'central-mgmt-schedule-script-restore': 'enable',
- 'ip': 'test_value_7',
- 'ipsec': 'enable',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'fortimanager', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_fortimanager_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortimanager': {
- 'random_attribute_not_valid': 'tag',
- 'central_management': 'enable',
- 'central_mgmt_auto_backup': 'enable',
- 'central_mgmt_schedule_config_restore': 'enable',
- 'central_mgmt_schedule_script_restore': 'enable',
- 'ip': 'test_value_7',
- 'ipsec': 'enable',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortimanager.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'central-management': 'enable',
- 'central-mgmt-auto-backup': 'enable',
- 'central-mgmt-schedule-config-restore': 'enable',
- 'central-mgmt-schedule-script-restore': 'enable',
- 'ip': 'test_value_7',
- 'ipsec': 'enable',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'fortimanager', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_fortisandbox.py b/test/units/modules/network/fortios/test_fortios_system_fortisandbox.py
deleted file mode 100644
index a4ff2ad4b0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_fortisandbox.py
+++ /dev/null
@@ -1,191 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_fortisandbox
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_fortisandbox.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_fortisandbox_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortisandbox': {
- 'email': 'test_value_3',
- 'enc_algorithm': 'default',
- 'server': '192.168.100.5',
- 'source_ip': '84.230.14.6',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortisandbox.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'email': 'test_value_3',
- 'enc-algorithm': 'default',
- 'server': '192.168.100.5',
- 'source-ip': '84.230.14.6',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'fortisandbox', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_fortisandbox_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortisandbox': {
- 'email': 'test_value_3',
- 'enc_algorithm': 'default',
- 'server': '192.168.100.5',
- 'source_ip': '84.230.14.6',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortisandbox.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'email': 'test_value_3',
- 'enc-algorithm': 'default',
- 'server': '192.168.100.5',
- 'source-ip': '84.230.14.6',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'fortisandbox', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_fortisandbox_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortisandbox': {
- 'email': 'test_value_3',
- 'enc_algorithm': 'default',
- 'server': '192.168.100.5',
- 'source_ip': '84.230.14.6',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortisandbox.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'email': 'test_value_3',
- 'enc-algorithm': 'default',
- 'server': '192.168.100.5',
- 'source-ip': '84.230.14.6',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'fortisandbox', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_fortisandbox_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fortisandbox': {
- 'random_attribute_not_valid': 'tag',
- 'email': 'test_value_3',
- 'enc_algorithm': 'default',
- 'server': '192.168.100.5',
- 'source_ip': '84.230.14.6',
- 'ssl_min_proto_version': 'default',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fortisandbox.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'email': 'test_value_3',
- 'enc-algorithm': 'default',
- 'server': '192.168.100.5',
- 'source-ip': '84.230.14.6',
- 'ssl-min-proto-version': 'default',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'fortisandbox', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_fsso_polling.py b/test/units/modules/network/fortios/test_fortios_system_fsso_polling.py
deleted file mode 100644
index a7fb490ff0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_fsso_polling.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_fsso_polling
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_fsso_polling.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_fsso_polling_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fsso_polling': {
- 'auth_password': 'test_value_3',
- 'authentication': 'enable',
- 'listening_port': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fsso_polling.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auth-password': 'test_value_3',
- 'authentication': 'enable',
- 'listening-port': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'fsso-polling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_fsso_polling_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fsso_polling': {
- 'auth_password': 'test_value_3',
- 'authentication': 'enable',
- 'listening_port': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fsso_polling.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auth-password': 'test_value_3',
- 'authentication': 'enable',
- 'listening-port': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'fsso-polling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_fsso_polling_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fsso_polling': {
- 'auth_password': 'test_value_3',
- 'authentication': 'enable',
- 'listening_port': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fsso_polling.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auth-password': 'test_value_3',
- 'authentication': 'enable',
- 'listening-port': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'fsso-polling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_fsso_polling_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_fsso_polling': {
- 'random_attribute_not_valid': 'tag',
- 'auth_password': 'test_value_3',
- 'authentication': 'enable',
- 'listening_port': '5',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_fsso_polling.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'auth-password': 'test_value_3',
- 'authentication': 'enable',
- 'listening-port': '5',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'fsso-polling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_ftm_push.py b/test/units/modules/network/fortios/test_fortios_system_ftm_push.py
deleted file mode 100644
index 811dc9f015..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_ftm_push.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_ftm_push
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_ftm_push.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_ftm_push_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ftm_push': {
- 'server_ip': 'test_value_3',
- 'server_port': '4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ftm_push.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'server-ip': 'test_value_3',
- 'server-port': '4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ftm-push', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ftm_push_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ftm_push': {
- 'server_ip': 'test_value_3',
- 'server_port': '4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ftm_push.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'server-ip': 'test_value_3',
- 'server-port': '4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ftm-push', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ftm_push_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ftm_push': {
- 'server_ip': 'test_value_3',
- 'server_port': '4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ftm_push.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'server-ip': 'test_value_3',
- 'server-port': '4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ftm-push', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_ftm_push_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ftm_push': {
- 'random_attribute_not_valid': 'tag',
- 'server_ip': 'test_value_3',
- 'server_port': '4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ftm_push.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'server-ip': 'test_value_3',
- 'server-port': '4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ftm-push', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_geoip_override.py b/test/units/modules/network/fortios/test_fortios_system_geoip_override.py
deleted file mode 100644
index 2187552f58..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_geoip_override.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_geoip_override
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_geoip_override.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_geoip_override_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_geoip_override': {
- 'country_id': 'test_value_3',
- 'description': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_geoip_override.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'country-id': 'test_value_3',
- 'description': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'geoip-override', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_geoip_override_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_geoip_override': {
- 'country_id': 'test_value_3',
- 'description': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_geoip_override.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'country-id': 'test_value_3',
- 'description': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'geoip-override', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_geoip_override_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_geoip_override': {
- 'country_id': 'test_value_3',
- 'description': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_geoip_override.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'geoip-override', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_geoip_override_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_geoip_override': {
- 'country_id': 'test_value_3',
- 'description': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_geoip_override.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'geoip-override', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_geoip_override_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_geoip_override': {
- 'country_id': 'test_value_3',
- 'description': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_geoip_override.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'country-id': 'test_value_3',
- 'description': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'geoip-override', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_geoip_override_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_geoip_override': {
- 'random_attribute_not_valid': 'tag',
- 'country_id': 'test_value_3',
- 'description': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_geoip_override.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'country-id': 'test_value_3',
- 'description': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'geoip-override', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_global.py b/test/units/modules/network/fortios/test_fortios_system_global.py
deleted file mode 100644
index f266463ffa..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_global.py
+++ /dev/null
@@ -1,1567 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_global
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_global.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_global_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_global': {
- 'admin_concurrent': 'enable',
- 'admin_console_timeout': '4',
- 'admin_hsts_max_age': '5',
- 'admin_https_pki_required': 'enable',
- 'admin_https_redirect': 'enable',
- 'admin_lockout_duration': '8',
- 'admin_lockout_threshold': '9',
- 'admin_login_max': '10',
- 'admin_maintainer': 'enable',
- 'admin_port': '12',
- 'admin_restrict_local': 'enable',
- 'admin_scp': 'enable',
- 'admin_server_cert': 'test_value_15',
- 'admin_sport': '16',
- 'admin_ssh_grace_time': '17',
- 'admin_ssh_password': 'enable',
- 'admin_ssh_port': '19',
- 'admin_ssh_v1': 'enable',
- 'admin_telnet_port': '21',
- 'admintimeout': '22',
- 'alias': 'test_value_23',
- 'allow_traffic_redirect': 'enable',
- 'anti_replay': 'disable',
- 'arp_max_entry': '26',
- 'asymroute': 'enable',
- 'auth_cert': 'test_value_28',
- 'auth_http_port': '29',
- 'auth_https_port': '30',
- 'auth_keepalive': 'enable',
- 'auth_session_limit': 'block-new',
- 'auto_auth_extension_device': 'enable',
- 'av_affinity': 'test_value_34',
- 'av_failopen': 'pass',
- 'av_failopen_session': 'enable',
- 'batch_cmdb': 'enable',
- 'block_session_timer': '38',
- 'br_fdb_max_entry': '39',
- 'cert_chain_max': '40',
- 'cfg_revert_timeout': '41',
- 'cfg_save': 'automatic',
- 'check_protocol_header': 'loose',
- 'check_reset_range': 'strict',
- 'cli_audit_log': 'enable',
- 'clt_cert_req': 'enable',
- 'compliance_check': 'enable',
- 'compliance_check_time': 'test_value_48',
- 'cpu_use_threshold': '49',
- 'csr_ca_attribute': 'enable',
- 'daily_restart': 'enable',
- 'device_identification_active_scan_delay': '52',
- 'device_idle_timeout': '53',
- 'dh_params': '1024',
- 'dnsproxy_worker_count': '55',
- 'dst': 'enable',
- 'endpoint_control_fds_access': 'enable',
- 'endpoint_control_portal_port': '58',
- 'failtime': '59',
- 'fds_statistics': 'enable',
- 'fds_statistics_period': '61',
- 'fortiextender': 'enable',
- 'fortiextender_data_port': '63',
- 'fortiextender_vlan_mode': 'enable',
- 'fortiservice_port': '65',
- 'gui_certificates': 'enable',
- 'gui_custom_language': 'enable',
- 'gui_date_format': 'yyyy/MM/dd',
- 'gui_device_latitude': 'test_value_69',
- 'gui_device_longitude': 'test_value_70',
- 'gui_display_hostname': 'enable',
- 'gui_ipv6': 'enable',
- 'gui_lines_per_page': '73',
- 'gui_theme': 'green',
- 'gui_wireless_opensecurity': 'enable',
- 'honor_df': 'enable',
- 'hostname': 'myhostname77',
- 'igmp_state_limit': '78',
- 'interval': '79',
- 'ip_src_port_range': 'test_value_80',
- 'ips_affinity': 'test_value_81',
- 'ipsec_asic_offload': 'enable',
- 'ipsec_hmac_offload': 'enable',
- 'ipsec_soft_dec_async': 'enable',
- 'ipv6_accept_dad': '85',
- 'ipv6_allow_anycast_probe': 'enable',
- 'language': 'english',
- 'ldapconntimeout': '88',
- 'lldp_transmission': 'enable',
- 'log_ssl_connection': 'enable',
- 'log_uuid': 'disable',
- 'login_timestamp': 'enable',
- 'long_vdom_name': 'enable',
- 'management_vdom': 'test_value_94',
- 'max_dlpstat_memory': '95',
- 'max_route_cache_size': '96',
- 'mc_ttl_notchange': 'enable',
- 'memory_use_threshold_extreme': '98',
- 'memory_use_threshold_green': '99',
- 'memory_use_threshold_red': '100',
- 'miglog_affinity': 'test_value_101',
- 'miglogd_children': '102',
- 'multi_factor_authentication': 'optional',
- 'multicast_forward': 'enable',
- 'ndp_max_entry': '105',
- 'per_user_bwl': 'enable',
- 'policy_auth_concurrent': '107',
- 'post_login_banner': 'disable',
- 'pre_login_banner': 'enable',
- 'private_data_encryption': 'disable',
- 'proxy_auth_lifetime': 'enable',
- 'proxy_auth_lifetime_timeout': '112',
- 'proxy_auth_timeout': '113',
- 'proxy_cipher_hardware_acceleration': 'disable',
- 'proxy_kxp_hardware_acceleration': 'disable',
- 'proxy_re_authentication_mode': 'session',
- 'proxy_worker_count': '117',
- 'radius_port': '118',
- 'reboot_upon_config_restore': 'enable',
- 'refresh': '120',
- 'remoteauthtimeout': '121',
- 'reset_sessionless_tcp': 'enable',
- 'restart_time': 'test_value_123',
- 'revision_backup_on_logout': 'enable',
- 'revision_image_auto_backup': 'enable',
- 'scanunit_count': '126',
- 'security_rating_result_submission': 'enable',
- 'security_rating_run_on_schedule': 'enable',
- 'send_pmtu_icmp': 'enable',
- 'snat_route_change': 'enable',
- 'special_file_23_support': 'disable',
- 'ssd_trim_date': '132',
- 'ssd_trim_freq': 'never',
- 'ssd_trim_hour': '134',
- 'ssd_trim_min': '135',
- 'ssd_trim_weekday': 'sunday',
- 'ssh_cbc_cipher': 'enable',
- 'ssh_hmac_md5': 'enable',
- 'ssh_kex_sha1': 'enable',
- 'ssl_min_proto_version': 'SSLv3',
- 'ssl_static_key_ciphers': 'enable',
- 'sslvpn_cipher_hardware_acceleration': 'enable',
- 'sslvpn_kxp_hardware_acceleration': 'enable',
- 'sslvpn_max_worker_count': '144',
- 'sslvpn_plugin_version_check': 'enable',
- 'strict_dirty_session_check': 'enable',
- 'strong_crypto': 'enable',
- 'switch_controller': 'disable',
- 'switch_controller_reserved_network': 'test_value_149',
- 'sys_perf_log_interval': '150',
- 'tcp_halfclose_timer': '151',
- 'tcp_halfopen_timer': '152',
- 'tcp_option': 'enable',
- 'tcp_timewait_timer': '154',
- 'tftp': 'enable',
- 'timezone': '01',
- 'tp_mc_skip_policy': 'enable',
- 'traffic_priority': 'tos',
- 'traffic_priority_level': 'low',
- 'two_factor_email_expiry': '160',
- 'two_factor_fac_expiry': '161',
- 'two_factor_ftk_expiry': '162',
- 'two_factor_ftm_expiry': '163',
- 'two_factor_sms_expiry': '164',
- 'udp_idle_timer': '165',
- 'user_server_cert': 'test_value_166',
- 'vdom_admin': 'enable',
- 'vip_arp_range': 'unlimited',
- 'virtual_server_count': '169',
- 'virtual_server_hardware_acceleration': 'disable',
- 'wad_affinity': 'test_value_171',
- 'wad_csvc_cs_count': '172',
- 'wad_csvc_db_count': '173',
- 'wad_source_affinity': 'disable',
- 'wad_worker_count': '175',
- 'wifi_ca_certificate': 'test_value_176',
- 'wifi_certificate': 'test_value_177',
- 'wimax_4g_usb': 'enable',
- 'wireless_controller': 'enable',
- 'wireless_controller_port': '180'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_global.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'admin-concurrent': 'enable',
- 'admin-console-timeout': '4',
- 'admin-hsts-max-age': '5',
- 'admin-https-pki-required': 'enable',
- 'admin-https-redirect': 'enable',
- 'admin-lockout-duration': '8',
- 'admin-lockout-threshold': '9',
- 'admin-login-max': '10',
- 'admin-maintainer': 'enable',
- 'admin-port': '12',
- 'admin-restrict-local': 'enable',
- 'admin-scp': 'enable',
- 'admin-server-cert': 'test_value_15',
- 'admin-sport': '16',
- 'admin-ssh-grace-time': '17',
- 'admin-ssh-password': 'enable',
- 'admin-ssh-port': '19',
- 'admin-ssh-v1': 'enable',
- 'admin-telnet-port': '21',
- 'admintimeout': '22',
- 'alias': 'test_value_23',
- 'allow-traffic-redirect': 'enable',
- 'anti-replay': 'disable',
- 'arp-max-entry': '26',
- 'asymroute': 'enable',
- 'auth-cert': 'test_value_28',
- 'auth-http-port': '29',
- 'auth-https-port': '30',
- 'auth-keepalive': 'enable',
- 'auth-session-limit': 'block-new',
- 'auto-auth-extension-device': 'enable',
- 'av-affinity': 'test_value_34',
- 'av-failopen': 'pass',
- 'av-failopen-session': 'enable',
- 'batch-cmdb': 'enable',
- 'block-session-timer': '38',
- 'br-fdb-max-entry': '39',
- 'cert-chain-max': '40',
- 'cfg-revert-timeout': '41',
- 'cfg-save': 'automatic',
- 'check-protocol-header': 'loose',
- 'check-reset-range': 'strict',
- 'cli-audit-log': 'enable',
- 'clt-cert-req': 'enable',
- 'compliance-check': 'enable',
- 'compliance-check-time': 'test_value_48',
- 'cpu-use-threshold': '49',
- 'csr-ca-attribute': 'enable',
- 'daily-restart': 'enable',
- 'device-identification-active-scan-delay': '52',
- 'device-idle-timeout': '53',
- 'dh-params': '1024',
- 'dnsproxy-worker-count': '55',
- 'dst': 'enable',
- 'endpoint-control-fds-access': 'enable',
- 'endpoint-control-portal-port': '58',
- 'failtime': '59',
- 'fds-statistics': 'enable',
- 'fds-statistics-period': '61',
- 'fortiextender': 'enable',
- 'fortiextender-data-port': '63',
- 'fortiextender-vlan-mode': 'enable',
- 'fortiservice-port': '65',
- 'gui-certificates': 'enable',
- 'gui-custom-language': 'enable',
- 'gui-date-format': 'yyyy/MM/dd',
- 'gui-device-latitude': 'test_value_69',
- 'gui-device-longitude': 'test_value_70',
- 'gui-display-hostname': 'enable',
- 'gui-ipv6': 'enable',
- 'gui-lines-per-page': '73',
- 'gui-theme': 'green',
- 'gui-wireless-opensecurity': 'enable',
- 'honor-df': 'enable',
- 'hostname': 'myhostname77',
- 'igmp-state-limit': '78',
- 'interval': '79',
- 'ip-src-port-range': 'test_value_80',
- 'ips-affinity': 'test_value_81',
- 'ipsec-asic-offload': 'enable',
- 'ipsec-hmac-offload': 'enable',
- 'ipsec-soft-dec-async': 'enable',
- 'ipv6-accept-dad': '85',
- 'ipv6-allow-anycast-probe': 'enable',
- 'language': 'english',
- 'ldapconntimeout': '88',
- 'lldp-transmission': 'enable',
- 'log-ssl-connection': 'enable',
- 'log-uuid': 'disable',
- 'login-timestamp': 'enable',
- 'long-vdom-name': 'enable',
- 'management-vdom': 'test_value_94',
- 'max-dlpstat-memory': '95',
- 'max-route-cache-size': '96',
- 'mc-ttl-notchange': 'enable',
- 'memory-use-threshold-extreme': '98',
- 'memory-use-threshold-green': '99',
- 'memory-use-threshold-red': '100',
- 'miglog-affinity': 'test_value_101',
- 'miglogd-children': '102',
- 'multi-factor-authentication': 'optional',
- 'multicast-forward': 'enable',
- 'ndp-max-entry': '105',
- 'per-user-bwl': 'enable',
- 'policy-auth-concurrent': '107',
- 'post-login-banner': 'disable',
- 'pre-login-banner': 'enable',
- 'private-data-encryption': 'disable',
- 'proxy-auth-lifetime': 'enable',
- 'proxy-auth-lifetime-timeout': '112',
- 'proxy-auth-timeout': '113',
- 'proxy-cipher-hardware-acceleration': 'disable',
- 'proxy-kxp-hardware-acceleration': 'disable',
- 'proxy-re-authentication-mode': 'session',
- 'proxy-worker-count': '117',
- 'radius-port': '118',
- 'reboot-upon-config-restore': 'enable',
- 'refresh': '120',
- 'remoteauthtimeout': '121',
- 'reset-sessionless-tcp': 'enable',
- 'restart-time': 'test_value_123',
- 'revision-backup-on-logout': 'enable',
- 'revision-image-auto-backup': 'enable',
- 'scanunit-count': '126',
- 'security-rating-result-submission': 'enable',
- 'security-rating-run-on-schedule': 'enable',
- 'send-pmtu-icmp': 'enable',
- 'snat-route-change': 'enable',
- 'special-file-23-support': 'disable',
- 'ssd-trim-date': '132',
- 'ssd-trim-freq': 'never',
- 'ssd-trim-hour': '134',
- 'ssd-trim-min': '135',
- 'ssd-trim-weekday': 'sunday',
- 'ssh-cbc-cipher': 'enable',
- 'ssh-hmac-md5': 'enable',
- 'ssh-kex-sha1': 'enable',
- 'ssl-min-proto-version': 'SSLv3',
- 'ssl-static-key-ciphers': 'enable',
- 'sslvpn-cipher-hardware-acceleration': 'enable',
- 'sslvpn-kxp-hardware-acceleration': 'enable',
- 'sslvpn-max-worker-count': '144',
- 'sslvpn-plugin-version-check': 'enable',
- 'strict-dirty-session-check': 'enable',
- 'strong-crypto': 'enable',
- 'switch-controller': 'disable',
- 'switch-controller-reserved-network': 'test_value_149',
- 'sys-perf-log-interval': '150',
- 'tcp-halfclose-timer': '151',
- 'tcp-halfopen-timer': '152',
- 'tcp-option': 'enable',
- 'tcp-timewait-timer': '154',
- 'tftp': 'enable',
- 'timezone': '01',
- 'tp-mc-skip-policy': 'enable',
- 'traffic-priority': 'tos',
- 'traffic-priority-level': 'low',
- 'two-factor-email-expiry': '160',
- 'two-factor-fac-expiry': '161',
- 'two-factor-ftk-expiry': '162',
- 'two-factor-ftm-expiry': '163',
- 'two-factor-sms-expiry': '164',
- 'udp-idle-timer': '165',
- 'user-server-cert': 'test_value_166',
- 'vdom-admin': 'enable',
- 'vip-arp-range': 'unlimited',
- 'virtual-server-count': '169',
- 'virtual-server-hardware-acceleration': 'disable',
- 'wad-affinity': 'test_value_171',
- 'wad-csvc-cs-count': '172',
- 'wad-csvc-db-count': '173',
- 'wad-source-affinity': 'disable',
- 'wad-worker-count': '175',
- 'wifi-ca-certificate': 'test_value_176',
- 'wifi-certificate': 'test_value_177',
- 'wimax-4g-usb': 'enable',
- 'wireless-controller': 'enable',
- 'wireless-controller-port': '180'
- }
-
- set_method_mock.assert_called_with('system', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_global_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_global': {
- 'admin_concurrent': 'enable',
- 'admin_console_timeout': '4',
- 'admin_hsts_max_age': '5',
- 'admin_https_pki_required': 'enable',
- 'admin_https_redirect': 'enable',
- 'admin_lockout_duration': '8',
- 'admin_lockout_threshold': '9',
- 'admin_login_max': '10',
- 'admin_maintainer': 'enable',
- 'admin_port': '12',
- 'admin_restrict_local': 'enable',
- 'admin_scp': 'enable',
- 'admin_server_cert': 'test_value_15',
- 'admin_sport': '16',
- 'admin_ssh_grace_time': '17',
- 'admin_ssh_password': 'enable',
- 'admin_ssh_port': '19',
- 'admin_ssh_v1': 'enable',
- 'admin_telnet_port': '21',
- 'admintimeout': '22',
- 'alias': 'test_value_23',
- 'allow_traffic_redirect': 'enable',
- 'anti_replay': 'disable',
- 'arp_max_entry': '26',
- 'asymroute': 'enable',
- 'auth_cert': 'test_value_28',
- 'auth_http_port': '29',
- 'auth_https_port': '30',
- 'auth_keepalive': 'enable',
- 'auth_session_limit': 'block-new',
- 'auto_auth_extension_device': 'enable',
- 'av_affinity': 'test_value_34',
- 'av_failopen': 'pass',
- 'av_failopen_session': 'enable',
- 'batch_cmdb': 'enable',
- 'block_session_timer': '38',
- 'br_fdb_max_entry': '39',
- 'cert_chain_max': '40',
- 'cfg_revert_timeout': '41',
- 'cfg_save': 'automatic',
- 'check_protocol_header': 'loose',
- 'check_reset_range': 'strict',
- 'cli_audit_log': 'enable',
- 'clt_cert_req': 'enable',
- 'compliance_check': 'enable',
- 'compliance_check_time': 'test_value_48',
- 'cpu_use_threshold': '49',
- 'csr_ca_attribute': 'enable',
- 'daily_restart': 'enable',
- 'device_identification_active_scan_delay': '52',
- 'device_idle_timeout': '53',
- 'dh_params': '1024',
- 'dnsproxy_worker_count': '55',
- 'dst': 'enable',
- 'endpoint_control_fds_access': 'enable',
- 'endpoint_control_portal_port': '58',
- 'failtime': '59',
- 'fds_statistics': 'enable',
- 'fds_statistics_period': '61',
- 'fortiextender': 'enable',
- 'fortiextender_data_port': '63',
- 'fortiextender_vlan_mode': 'enable',
- 'fortiservice_port': '65',
- 'gui_certificates': 'enable',
- 'gui_custom_language': 'enable',
- 'gui_date_format': 'yyyy/MM/dd',
- 'gui_device_latitude': 'test_value_69',
- 'gui_device_longitude': 'test_value_70',
- 'gui_display_hostname': 'enable',
- 'gui_ipv6': 'enable',
- 'gui_lines_per_page': '73',
- 'gui_theme': 'green',
- 'gui_wireless_opensecurity': 'enable',
- 'honor_df': 'enable',
- 'hostname': 'myhostname77',
- 'igmp_state_limit': '78',
- 'interval': '79',
- 'ip_src_port_range': 'test_value_80',
- 'ips_affinity': 'test_value_81',
- 'ipsec_asic_offload': 'enable',
- 'ipsec_hmac_offload': 'enable',
- 'ipsec_soft_dec_async': 'enable',
- 'ipv6_accept_dad': '85',
- 'ipv6_allow_anycast_probe': 'enable',
- 'language': 'english',
- 'ldapconntimeout': '88',
- 'lldp_transmission': 'enable',
- 'log_ssl_connection': 'enable',
- 'log_uuid': 'disable',
- 'login_timestamp': 'enable',
- 'long_vdom_name': 'enable',
- 'management_vdom': 'test_value_94',
- 'max_dlpstat_memory': '95',
- 'max_route_cache_size': '96',
- 'mc_ttl_notchange': 'enable',
- 'memory_use_threshold_extreme': '98',
- 'memory_use_threshold_green': '99',
- 'memory_use_threshold_red': '100',
- 'miglog_affinity': 'test_value_101',
- 'miglogd_children': '102',
- 'multi_factor_authentication': 'optional',
- 'multicast_forward': 'enable',
- 'ndp_max_entry': '105',
- 'per_user_bwl': 'enable',
- 'policy_auth_concurrent': '107',
- 'post_login_banner': 'disable',
- 'pre_login_banner': 'enable',
- 'private_data_encryption': 'disable',
- 'proxy_auth_lifetime': 'enable',
- 'proxy_auth_lifetime_timeout': '112',
- 'proxy_auth_timeout': '113',
- 'proxy_cipher_hardware_acceleration': 'disable',
- 'proxy_kxp_hardware_acceleration': 'disable',
- 'proxy_re_authentication_mode': 'session',
- 'proxy_worker_count': '117',
- 'radius_port': '118',
- 'reboot_upon_config_restore': 'enable',
- 'refresh': '120',
- 'remoteauthtimeout': '121',
- 'reset_sessionless_tcp': 'enable',
- 'restart_time': 'test_value_123',
- 'revision_backup_on_logout': 'enable',
- 'revision_image_auto_backup': 'enable',
- 'scanunit_count': '126',
- 'security_rating_result_submission': 'enable',
- 'security_rating_run_on_schedule': 'enable',
- 'send_pmtu_icmp': 'enable',
- 'snat_route_change': 'enable',
- 'special_file_23_support': 'disable',
- 'ssd_trim_date': '132',
- 'ssd_trim_freq': 'never',
- 'ssd_trim_hour': '134',
- 'ssd_trim_min': '135',
- 'ssd_trim_weekday': 'sunday',
- 'ssh_cbc_cipher': 'enable',
- 'ssh_hmac_md5': 'enable',
- 'ssh_kex_sha1': 'enable',
- 'ssl_min_proto_version': 'SSLv3',
- 'ssl_static_key_ciphers': 'enable',
- 'sslvpn_cipher_hardware_acceleration': 'enable',
- 'sslvpn_kxp_hardware_acceleration': 'enable',
- 'sslvpn_max_worker_count': '144',
- 'sslvpn_plugin_version_check': 'enable',
- 'strict_dirty_session_check': 'enable',
- 'strong_crypto': 'enable',
- 'switch_controller': 'disable',
- 'switch_controller_reserved_network': 'test_value_149',
- 'sys_perf_log_interval': '150',
- 'tcp_halfclose_timer': '151',
- 'tcp_halfopen_timer': '152',
- 'tcp_option': 'enable',
- 'tcp_timewait_timer': '154',
- 'tftp': 'enable',
- 'timezone': '01',
- 'tp_mc_skip_policy': 'enable',
- 'traffic_priority': 'tos',
- 'traffic_priority_level': 'low',
- 'two_factor_email_expiry': '160',
- 'two_factor_fac_expiry': '161',
- 'two_factor_ftk_expiry': '162',
- 'two_factor_ftm_expiry': '163',
- 'two_factor_sms_expiry': '164',
- 'udp_idle_timer': '165',
- 'user_server_cert': 'test_value_166',
- 'vdom_admin': 'enable',
- 'vip_arp_range': 'unlimited',
- 'virtual_server_count': '169',
- 'virtual_server_hardware_acceleration': 'disable',
- 'wad_affinity': 'test_value_171',
- 'wad_csvc_cs_count': '172',
- 'wad_csvc_db_count': '173',
- 'wad_source_affinity': 'disable',
- 'wad_worker_count': '175',
- 'wifi_ca_certificate': 'test_value_176',
- 'wifi_certificate': 'test_value_177',
- 'wimax_4g_usb': 'enable',
- 'wireless_controller': 'enable',
- 'wireless_controller_port': '180'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_global.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'admin-concurrent': 'enable',
- 'admin-console-timeout': '4',
- 'admin-hsts-max-age': '5',
- 'admin-https-pki-required': 'enable',
- 'admin-https-redirect': 'enable',
- 'admin-lockout-duration': '8',
- 'admin-lockout-threshold': '9',
- 'admin-login-max': '10',
- 'admin-maintainer': 'enable',
- 'admin-port': '12',
- 'admin-restrict-local': 'enable',
- 'admin-scp': 'enable',
- 'admin-server-cert': 'test_value_15',
- 'admin-sport': '16',
- 'admin-ssh-grace-time': '17',
- 'admin-ssh-password': 'enable',
- 'admin-ssh-port': '19',
- 'admin-ssh-v1': 'enable',
- 'admin-telnet-port': '21',
- 'admintimeout': '22',
- 'alias': 'test_value_23',
- 'allow-traffic-redirect': 'enable',
- 'anti-replay': 'disable',
- 'arp-max-entry': '26',
- 'asymroute': 'enable',
- 'auth-cert': 'test_value_28',
- 'auth-http-port': '29',
- 'auth-https-port': '30',
- 'auth-keepalive': 'enable',
- 'auth-session-limit': 'block-new',
- 'auto-auth-extension-device': 'enable',
- 'av-affinity': 'test_value_34',
- 'av-failopen': 'pass',
- 'av-failopen-session': 'enable',
- 'batch-cmdb': 'enable',
- 'block-session-timer': '38',
- 'br-fdb-max-entry': '39',
- 'cert-chain-max': '40',
- 'cfg-revert-timeout': '41',
- 'cfg-save': 'automatic',
- 'check-protocol-header': 'loose',
- 'check-reset-range': 'strict',
- 'cli-audit-log': 'enable',
- 'clt-cert-req': 'enable',
- 'compliance-check': 'enable',
- 'compliance-check-time': 'test_value_48',
- 'cpu-use-threshold': '49',
- 'csr-ca-attribute': 'enable',
- 'daily-restart': 'enable',
- 'device-identification-active-scan-delay': '52',
- 'device-idle-timeout': '53',
- 'dh-params': '1024',
- 'dnsproxy-worker-count': '55',
- 'dst': 'enable',
- 'endpoint-control-fds-access': 'enable',
- 'endpoint-control-portal-port': '58',
- 'failtime': '59',
- 'fds-statistics': 'enable',
- 'fds-statistics-period': '61',
- 'fortiextender': 'enable',
- 'fortiextender-data-port': '63',
- 'fortiextender-vlan-mode': 'enable',
- 'fortiservice-port': '65',
- 'gui-certificates': 'enable',
- 'gui-custom-language': 'enable',
- 'gui-date-format': 'yyyy/MM/dd',
- 'gui-device-latitude': 'test_value_69',
- 'gui-device-longitude': 'test_value_70',
- 'gui-display-hostname': 'enable',
- 'gui-ipv6': 'enable',
- 'gui-lines-per-page': '73',
- 'gui-theme': 'green',
- 'gui-wireless-opensecurity': 'enable',
- 'honor-df': 'enable',
- 'hostname': 'myhostname77',
- 'igmp-state-limit': '78',
- 'interval': '79',
- 'ip-src-port-range': 'test_value_80',
- 'ips-affinity': 'test_value_81',
- 'ipsec-asic-offload': 'enable',
- 'ipsec-hmac-offload': 'enable',
- 'ipsec-soft-dec-async': 'enable',
- 'ipv6-accept-dad': '85',
- 'ipv6-allow-anycast-probe': 'enable',
- 'language': 'english',
- 'ldapconntimeout': '88',
- 'lldp-transmission': 'enable',
- 'log-ssl-connection': 'enable',
- 'log-uuid': 'disable',
- 'login-timestamp': 'enable',
- 'long-vdom-name': 'enable',
- 'management-vdom': 'test_value_94',
- 'max-dlpstat-memory': '95',
- 'max-route-cache-size': '96',
- 'mc-ttl-notchange': 'enable',
- 'memory-use-threshold-extreme': '98',
- 'memory-use-threshold-green': '99',
- 'memory-use-threshold-red': '100',
- 'miglog-affinity': 'test_value_101',
- 'miglogd-children': '102',
- 'multi-factor-authentication': 'optional',
- 'multicast-forward': 'enable',
- 'ndp-max-entry': '105',
- 'per-user-bwl': 'enable',
- 'policy-auth-concurrent': '107',
- 'post-login-banner': 'disable',
- 'pre-login-banner': 'enable',
- 'private-data-encryption': 'disable',
- 'proxy-auth-lifetime': 'enable',
- 'proxy-auth-lifetime-timeout': '112',
- 'proxy-auth-timeout': '113',
- 'proxy-cipher-hardware-acceleration': 'disable',
- 'proxy-kxp-hardware-acceleration': 'disable',
- 'proxy-re-authentication-mode': 'session',
- 'proxy-worker-count': '117',
- 'radius-port': '118',
- 'reboot-upon-config-restore': 'enable',
- 'refresh': '120',
- 'remoteauthtimeout': '121',
- 'reset-sessionless-tcp': 'enable',
- 'restart-time': 'test_value_123',
- 'revision-backup-on-logout': 'enable',
- 'revision-image-auto-backup': 'enable',
- 'scanunit-count': '126',
- 'security-rating-result-submission': 'enable',
- 'security-rating-run-on-schedule': 'enable',
- 'send-pmtu-icmp': 'enable',
- 'snat-route-change': 'enable',
- 'special-file-23-support': 'disable',
- 'ssd-trim-date': '132',
- 'ssd-trim-freq': 'never',
- 'ssd-trim-hour': '134',
- 'ssd-trim-min': '135',
- 'ssd-trim-weekday': 'sunday',
- 'ssh-cbc-cipher': 'enable',
- 'ssh-hmac-md5': 'enable',
- 'ssh-kex-sha1': 'enable',
- 'ssl-min-proto-version': 'SSLv3',
- 'ssl-static-key-ciphers': 'enable',
- 'sslvpn-cipher-hardware-acceleration': 'enable',
- 'sslvpn-kxp-hardware-acceleration': 'enable',
- 'sslvpn-max-worker-count': '144',
- 'sslvpn-plugin-version-check': 'enable',
- 'strict-dirty-session-check': 'enable',
- 'strong-crypto': 'enable',
- 'switch-controller': 'disable',
- 'switch-controller-reserved-network': 'test_value_149',
- 'sys-perf-log-interval': '150',
- 'tcp-halfclose-timer': '151',
- 'tcp-halfopen-timer': '152',
- 'tcp-option': 'enable',
- 'tcp-timewait-timer': '154',
- 'tftp': 'enable',
- 'timezone': '01',
- 'tp-mc-skip-policy': 'enable',
- 'traffic-priority': 'tos',
- 'traffic-priority-level': 'low',
- 'two-factor-email-expiry': '160',
- 'two-factor-fac-expiry': '161',
- 'two-factor-ftk-expiry': '162',
- 'two-factor-ftm-expiry': '163',
- 'two-factor-sms-expiry': '164',
- 'udp-idle-timer': '165',
- 'user-server-cert': 'test_value_166',
- 'vdom-admin': 'enable',
- 'vip-arp-range': 'unlimited',
- 'virtual-server-count': '169',
- 'virtual-server-hardware-acceleration': 'disable',
- 'wad-affinity': 'test_value_171',
- 'wad-csvc-cs-count': '172',
- 'wad-csvc-db-count': '173',
- 'wad-source-affinity': 'disable',
- 'wad-worker-count': '175',
- 'wifi-ca-certificate': 'test_value_176',
- 'wifi-certificate': 'test_value_177',
- 'wimax-4g-usb': 'enable',
- 'wireless-controller': 'enable',
- 'wireless-controller-port': '180'
- }
-
- set_method_mock.assert_called_with('system', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_global_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_global': {
- 'admin_concurrent': 'enable',
- 'admin_console_timeout': '4',
- 'admin_hsts_max_age': '5',
- 'admin_https_pki_required': 'enable',
- 'admin_https_redirect': 'enable',
- 'admin_lockout_duration': '8',
- 'admin_lockout_threshold': '9',
- 'admin_login_max': '10',
- 'admin_maintainer': 'enable',
- 'admin_port': '12',
- 'admin_restrict_local': 'enable',
- 'admin_scp': 'enable',
- 'admin_server_cert': 'test_value_15',
- 'admin_sport': '16',
- 'admin_ssh_grace_time': '17',
- 'admin_ssh_password': 'enable',
- 'admin_ssh_port': '19',
- 'admin_ssh_v1': 'enable',
- 'admin_telnet_port': '21',
- 'admintimeout': '22',
- 'alias': 'test_value_23',
- 'allow_traffic_redirect': 'enable',
- 'anti_replay': 'disable',
- 'arp_max_entry': '26',
- 'asymroute': 'enable',
- 'auth_cert': 'test_value_28',
- 'auth_http_port': '29',
- 'auth_https_port': '30',
- 'auth_keepalive': 'enable',
- 'auth_session_limit': 'block-new',
- 'auto_auth_extension_device': 'enable',
- 'av_affinity': 'test_value_34',
- 'av_failopen': 'pass',
- 'av_failopen_session': 'enable',
- 'batch_cmdb': 'enable',
- 'block_session_timer': '38',
- 'br_fdb_max_entry': '39',
- 'cert_chain_max': '40',
- 'cfg_revert_timeout': '41',
- 'cfg_save': 'automatic',
- 'check_protocol_header': 'loose',
- 'check_reset_range': 'strict',
- 'cli_audit_log': 'enable',
- 'clt_cert_req': 'enable',
- 'compliance_check': 'enable',
- 'compliance_check_time': 'test_value_48',
- 'cpu_use_threshold': '49',
- 'csr_ca_attribute': 'enable',
- 'daily_restart': 'enable',
- 'device_identification_active_scan_delay': '52',
- 'device_idle_timeout': '53',
- 'dh_params': '1024',
- 'dnsproxy_worker_count': '55',
- 'dst': 'enable',
- 'endpoint_control_fds_access': 'enable',
- 'endpoint_control_portal_port': '58',
- 'failtime': '59',
- 'fds_statistics': 'enable',
- 'fds_statistics_period': '61',
- 'fortiextender': 'enable',
- 'fortiextender_data_port': '63',
- 'fortiextender_vlan_mode': 'enable',
- 'fortiservice_port': '65',
- 'gui_certificates': 'enable',
- 'gui_custom_language': 'enable',
- 'gui_date_format': 'yyyy/MM/dd',
- 'gui_device_latitude': 'test_value_69',
- 'gui_device_longitude': 'test_value_70',
- 'gui_display_hostname': 'enable',
- 'gui_ipv6': 'enable',
- 'gui_lines_per_page': '73',
- 'gui_theme': 'green',
- 'gui_wireless_opensecurity': 'enable',
- 'honor_df': 'enable',
- 'hostname': 'myhostname77',
- 'igmp_state_limit': '78',
- 'interval': '79',
- 'ip_src_port_range': 'test_value_80',
- 'ips_affinity': 'test_value_81',
- 'ipsec_asic_offload': 'enable',
- 'ipsec_hmac_offload': 'enable',
- 'ipsec_soft_dec_async': 'enable',
- 'ipv6_accept_dad': '85',
- 'ipv6_allow_anycast_probe': 'enable',
- 'language': 'english',
- 'ldapconntimeout': '88',
- 'lldp_transmission': 'enable',
- 'log_ssl_connection': 'enable',
- 'log_uuid': 'disable',
- 'login_timestamp': 'enable',
- 'long_vdom_name': 'enable',
- 'management_vdom': 'test_value_94',
- 'max_dlpstat_memory': '95',
- 'max_route_cache_size': '96',
- 'mc_ttl_notchange': 'enable',
- 'memory_use_threshold_extreme': '98',
- 'memory_use_threshold_green': '99',
- 'memory_use_threshold_red': '100',
- 'miglog_affinity': 'test_value_101',
- 'miglogd_children': '102',
- 'multi_factor_authentication': 'optional',
- 'multicast_forward': 'enable',
- 'ndp_max_entry': '105',
- 'per_user_bwl': 'enable',
- 'policy_auth_concurrent': '107',
- 'post_login_banner': 'disable',
- 'pre_login_banner': 'enable',
- 'private_data_encryption': 'disable',
- 'proxy_auth_lifetime': 'enable',
- 'proxy_auth_lifetime_timeout': '112',
- 'proxy_auth_timeout': '113',
- 'proxy_cipher_hardware_acceleration': 'disable',
- 'proxy_kxp_hardware_acceleration': 'disable',
- 'proxy_re_authentication_mode': 'session',
- 'proxy_worker_count': '117',
- 'radius_port': '118',
- 'reboot_upon_config_restore': 'enable',
- 'refresh': '120',
- 'remoteauthtimeout': '121',
- 'reset_sessionless_tcp': 'enable',
- 'restart_time': 'test_value_123',
- 'revision_backup_on_logout': 'enable',
- 'revision_image_auto_backup': 'enable',
- 'scanunit_count': '126',
- 'security_rating_result_submission': 'enable',
- 'security_rating_run_on_schedule': 'enable',
- 'send_pmtu_icmp': 'enable',
- 'snat_route_change': 'enable',
- 'special_file_23_support': 'disable',
- 'ssd_trim_date': '132',
- 'ssd_trim_freq': 'never',
- 'ssd_trim_hour': '134',
- 'ssd_trim_min': '135',
- 'ssd_trim_weekday': 'sunday',
- 'ssh_cbc_cipher': 'enable',
- 'ssh_hmac_md5': 'enable',
- 'ssh_kex_sha1': 'enable',
- 'ssl_min_proto_version': 'SSLv3',
- 'ssl_static_key_ciphers': 'enable',
- 'sslvpn_cipher_hardware_acceleration': 'enable',
- 'sslvpn_kxp_hardware_acceleration': 'enable',
- 'sslvpn_max_worker_count': '144',
- 'sslvpn_plugin_version_check': 'enable',
- 'strict_dirty_session_check': 'enable',
- 'strong_crypto': 'enable',
- 'switch_controller': 'disable',
- 'switch_controller_reserved_network': 'test_value_149',
- 'sys_perf_log_interval': '150',
- 'tcp_halfclose_timer': '151',
- 'tcp_halfopen_timer': '152',
- 'tcp_option': 'enable',
- 'tcp_timewait_timer': '154',
- 'tftp': 'enable',
- 'timezone': '01',
- 'tp_mc_skip_policy': 'enable',
- 'traffic_priority': 'tos',
- 'traffic_priority_level': 'low',
- 'two_factor_email_expiry': '160',
- 'two_factor_fac_expiry': '161',
- 'two_factor_ftk_expiry': '162',
- 'two_factor_ftm_expiry': '163',
- 'two_factor_sms_expiry': '164',
- 'udp_idle_timer': '165',
- 'user_server_cert': 'test_value_166',
- 'vdom_admin': 'enable',
- 'vip_arp_range': 'unlimited',
- 'virtual_server_count': '169',
- 'virtual_server_hardware_acceleration': 'disable',
- 'wad_affinity': 'test_value_171',
- 'wad_csvc_cs_count': '172',
- 'wad_csvc_db_count': '173',
- 'wad_source_affinity': 'disable',
- 'wad_worker_count': '175',
- 'wifi_ca_certificate': 'test_value_176',
- 'wifi_certificate': 'test_value_177',
- 'wimax_4g_usb': 'enable',
- 'wireless_controller': 'enable',
- 'wireless_controller_port': '180'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_global.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'admin-concurrent': 'enable',
- 'admin-console-timeout': '4',
- 'admin-hsts-max-age': '5',
- 'admin-https-pki-required': 'enable',
- 'admin-https-redirect': 'enable',
- 'admin-lockout-duration': '8',
- 'admin-lockout-threshold': '9',
- 'admin-login-max': '10',
- 'admin-maintainer': 'enable',
- 'admin-port': '12',
- 'admin-restrict-local': 'enable',
- 'admin-scp': 'enable',
- 'admin-server-cert': 'test_value_15',
- 'admin-sport': '16',
- 'admin-ssh-grace-time': '17',
- 'admin-ssh-password': 'enable',
- 'admin-ssh-port': '19',
- 'admin-ssh-v1': 'enable',
- 'admin-telnet-port': '21',
- 'admintimeout': '22',
- 'alias': 'test_value_23',
- 'allow-traffic-redirect': 'enable',
- 'anti-replay': 'disable',
- 'arp-max-entry': '26',
- 'asymroute': 'enable',
- 'auth-cert': 'test_value_28',
- 'auth-http-port': '29',
- 'auth-https-port': '30',
- 'auth-keepalive': 'enable',
- 'auth-session-limit': 'block-new',
- 'auto-auth-extension-device': 'enable',
- 'av-affinity': 'test_value_34',
- 'av-failopen': 'pass',
- 'av-failopen-session': 'enable',
- 'batch-cmdb': 'enable',
- 'block-session-timer': '38',
- 'br-fdb-max-entry': '39',
- 'cert-chain-max': '40',
- 'cfg-revert-timeout': '41',
- 'cfg-save': 'automatic',
- 'check-protocol-header': 'loose',
- 'check-reset-range': 'strict',
- 'cli-audit-log': 'enable',
- 'clt-cert-req': 'enable',
- 'compliance-check': 'enable',
- 'compliance-check-time': 'test_value_48',
- 'cpu-use-threshold': '49',
- 'csr-ca-attribute': 'enable',
- 'daily-restart': 'enable',
- 'device-identification-active-scan-delay': '52',
- 'device-idle-timeout': '53',
- 'dh-params': '1024',
- 'dnsproxy-worker-count': '55',
- 'dst': 'enable',
- 'endpoint-control-fds-access': 'enable',
- 'endpoint-control-portal-port': '58',
- 'failtime': '59',
- 'fds-statistics': 'enable',
- 'fds-statistics-period': '61',
- 'fortiextender': 'enable',
- 'fortiextender-data-port': '63',
- 'fortiextender-vlan-mode': 'enable',
- 'fortiservice-port': '65',
- 'gui-certificates': 'enable',
- 'gui-custom-language': 'enable',
- 'gui-date-format': 'yyyy/MM/dd',
- 'gui-device-latitude': 'test_value_69',
- 'gui-device-longitude': 'test_value_70',
- 'gui-display-hostname': 'enable',
- 'gui-ipv6': 'enable',
- 'gui-lines-per-page': '73',
- 'gui-theme': 'green',
- 'gui-wireless-opensecurity': 'enable',
- 'honor-df': 'enable',
- 'hostname': 'myhostname77',
- 'igmp-state-limit': '78',
- 'interval': '79',
- 'ip-src-port-range': 'test_value_80',
- 'ips-affinity': 'test_value_81',
- 'ipsec-asic-offload': 'enable',
- 'ipsec-hmac-offload': 'enable',
- 'ipsec-soft-dec-async': 'enable',
- 'ipv6-accept-dad': '85',
- 'ipv6-allow-anycast-probe': 'enable',
- 'language': 'english',
- 'ldapconntimeout': '88',
- 'lldp-transmission': 'enable',
- 'log-ssl-connection': 'enable',
- 'log-uuid': 'disable',
- 'login-timestamp': 'enable',
- 'long-vdom-name': 'enable',
- 'management-vdom': 'test_value_94',
- 'max-dlpstat-memory': '95',
- 'max-route-cache-size': '96',
- 'mc-ttl-notchange': 'enable',
- 'memory-use-threshold-extreme': '98',
- 'memory-use-threshold-green': '99',
- 'memory-use-threshold-red': '100',
- 'miglog-affinity': 'test_value_101',
- 'miglogd-children': '102',
- 'multi-factor-authentication': 'optional',
- 'multicast-forward': 'enable',
- 'ndp-max-entry': '105',
- 'per-user-bwl': 'enable',
- 'policy-auth-concurrent': '107',
- 'post-login-banner': 'disable',
- 'pre-login-banner': 'enable',
- 'private-data-encryption': 'disable',
- 'proxy-auth-lifetime': 'enable',
- 'proxy-auth-lifetime-timeout': '112',
- 'proxy-auth-timeout': '113',
- 'proxy-cipher-hardware-acceleration': 'disable',
- 'proxy-kxp-hardware-acceleration': 'disable',
- 'proxy-re-authentication-mode': 'session',
- 'proxy-worker-count': '117',
- 'radius-port': '118',
- 'reboot-upon-config-restore': 'enable',
- 'refresh': '120',
- 'remoteauthtimeout': '121',
- 'reset-sessionless-tcp': 'enable',
- 'restart-time': 'test_value_123',
- 'revision-backup-on-logout': 'enable',
- 'revision-image-auto-backup': 'enable',
- 'scanunit-count': '126',
- 'security-rating-result-submission': 'enable',
- 'security-rating-run-on-schedule': 'enable',
- 'send-pmtu-icmp': 'enable',
- 'snat-route-change': 'enable',
- 'special-file-23-support': 'disable',
- 'ssd-trim-date': '132',
- 'ssd-trim-freq': 'never',
- 'ssd-trim-hour': '134',
- 'ssd-trim-min': '135',
- 'ssd-trim-weekday': 'sunday',
- 'ssh-cbc-cipher': 'enable',
- 'ssh-hmac-md5': 'enable',
- 'ssh-kex-sha1': 'enable',
- 'ssl-min-proto-version': 'SSLv3',
- 'ssl-static-key-ciphers': 'enable',
- 'sslvpn-cipher-hardware-acceleration': 'enable',
- 'sslvpn-kxp-hardware-acceleration': 'enable',
- 'sslvpn-max-worker-count': '144',
- 'sslvpn-plugin-version-check': 'enable',
- 'strict-dirty-session-check': 'enable',
- 'strong-crypto': 'enable',
- 'switch-controller': 'disable',
- 'switch-controller-reserved-network': 'test_value_149',
- 'sys-perf-log-interval': '150',
- 'tcp-halfclose-timer': '151',
- 'tcp-halfopen-timer': '152',
- 'tcp-option': 'enable',
- 'tcp-timewait-timer': '154',
- 'tftp': 'enable',
- 'timezone': '01',
- 'tp-mc-skip-policy': 'enable',
- 'traffic-priority': 'tos',
- 'traffic-priority-level': 'low',
- 'two-factor-email-expiry': '160',
- 'two-factor-fac-expiry': '161',
- 'two-factor-ftk-expiry': '162',
- 'two-factor-ftm-expiry': '163',
- 'two-factor-sms-expiry': '164',
- 'udp-idle-timer': '165',
- 'user-server-cert': 'test_value_166',
- 'vdom-admin': 'enable',
- 'vip-arp-range': 'unlimited',
- 'virtual-server-count': '169',
- 'virtual-server-hardware-acceleration': 'disable',
- 'wad-affinity': 'test_value_171',
- 'wad-csvc-cs-count': '172',
- 'wad-csvc-db-count': '173',
- 'wad-source-affinity': 'disable',
- 'wad-worker-count': '175',
- 'wifi-ca-certificate': 'test_value_176',
- 'wifi-certificate': 'test_value_177',
- 'wimax-4g-usb': 'enable',
- 'wireless-controller': 'enable',
- 'wireless-controller-port': '180'
- }
-
- set_method_mock.assert_called_with('system', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_global_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_global': {
- 'random_attribute_not_valid': 'tag',
- 'admin_concurrent': 'enable',
- 'admin_console_timeout': '4',
- 'admin_hsts_max_age': '5',
- 'admin_https_pki_required': 'enable',
- 'admin_https_redirect': 'enable',
- 'admin_lockout_duration': '8',
- 'admin_lockout_threshold': '9',
- 'admin_login_max': '10',
- 'admin_maintainer': 'enable',
- 'admin_port': '12',
- 'admin_restrict_local': 'enable',
- 'admin_scp': 'enable',
- 'admin_server_cert': 'test_value_15',
- 'admin_sport': '16',
- 'admin_ssh_grace_time': '17',
- 'admin_ssh_password': 'enable',
- 'admin_ssh_port': '19',
- 'admin_ssh_v1': 'enable',
- 'admin_telnet_port': '21',
- 'admintimeout': '22',
- 'alias': 'test_value_23',
- 'allow_traffic_redirect': 'enable',
- 'anti_replay': 'disable',
- 'arp_max_entry': '26',
- 'asymroute': 'enable',
- 'auth_cert': 'test_value_28',
- 'auth_http_port': '29',
- 'auth_https_port': '30',
- 'auth_keepalive': 'enable',
- 'auth_session_limit': 'block-new',
- 'auto_auth_extension_device': 'enable',
- 'av_affinity': 'test_value_34',
- 'av_failopen': 'pass',
- 'av_failopen_session': 'enable',
- 'batch_cmdb': 'enable',
- 'block_session_timer': '38',
- 'br_fdb_max_entry': '39',
- 'cert_chain_max': '40',
- 'cfg_revert_timeout': '41',
- 'cfg_save': 'automatic',
- 'check_protocol_header': 'loose',
- 'check_reset_range': 'strict',
- 'cli_audit_log': 'enable',
- 'clt_cert_req': 'enable',
- 'compliance_check': 'enable',
- 'compliance_check_time': 'test_value_48',
- 'cpu_use_threshold': '49',
- 'csr_ca_attribute': 'enable',
- 'daily_restart': 'enable',
- 'device_identification_active_scan_delay': '52',
- 'device_idle_timeout': '53',
- 'dh_params': '1024',
- 'dnsproxy_worker_count': '55',
- 'dst': 'enable',
- 'endpoint_control_fds_access': 'enable',
- 'endpoint_control_portal_port': '58',
- 'failtime': '59',
- 'fds_statistics': 'enable',
- 'fds_statistics_period': '61',
- 'fortiextender': 'enable',
- 'fortiextender_data_port': '63',
- 'fortiextender_vlan_mode': 'enable',
- 'fortiservice_port': '65',
- 'gui_certificates': 'enable',
- 'gui_custom_language': 'enable',
- 'gui_date_format': 'yyyy/MM/dd',
- 'gui_device_latitude': 'test_value_69',
- 'gui_device_longitude': 'test_value_70',
- 'gui_display_hostname': 'enable',
- 'gui_ipv6': 'enable',
- 'gui_lines_per_page': '73',
- 'gui_theme': 'green',
- 'gui_wireless_opensecurity': 'enable',
- 'honor_df': 'enable',
- 'hostname': 'myhostname77',
- 'igmp_state_limit': '78',
- 'interval': '79',
- 'ip_src_port_range': 'test_value_80',
- 'ips_affinity': 'test_value_81',
- 'ipsec_asic_offload': 'enable',
- 'ipsec_hmac_offload': 'enable',
- 'ipsec_soft_dec_async': 'enable',
- 'ipv6_accept_dad': '85',
- 'ipv6_allow_anycast_probe': 'enable',
- 'language': 'english',
- 'ldapconntimeout': '88',
- 'lldp_transmission': 'enable',
- 'log_ssl_connection': 'enable',
- 'log_uuid': 'disable',
- 'login_timestamp': 'enable',
- 'long_vdom_name': 'enable',
- 'management_vdom': 'test_value_94',
- 'max_dlpstat_memory': '95',
- 'max_route_cache_size': '96',
- 'mc_ttl_notchange': 'enable',
- 'memory_use_threshold_extreme': '98',
- 'memory_use_threshold_green': '99',
- 'memory_use_threshold_red': '100',
- 'miglog_affinity': 'test_value_101',
- 'miglogd_children': '102',
- 'multi_factor_authentication': 'optional',
- 'multicast_forward': 'enable',
- 'ndp_max_entry': '105',
- 'per_user_bwl': 'enable',
- 'policy_auth_concurrent': '107',
- 'post_login_banner': 'disable',
- 'pre_login_banner': 'enable',
- 'private_data_encryption': 'disable',
- 'proxy_auth_lifetime': 'enable',
- 'proxy_auth_lifetime_timeout': '112',
- 'proxy_auth_timeout': '113',
- 'proxy_cipher_hardware_acceleration': 'disable',
- 'proxy_kxp_hardware_acceleration': 'disable',
- 'proxy_re_authentication_mode': 'session',
- 'proxy_worker_count': '117',
- 'radius_port': '118',
- 'reboot_upon_config_restore': 'enable',
- 'refresh': '120',
- 'remoteauthtimeout': '121',
- 'reset_sessionless_tcp': 'enable',
- 'restart_time': 'test_value_123',
- 'revision_backup_on_logout': 'enable',
- 'revision_image_auto_backup': 'enable',
- 'scanunit_count': '126',
- 'security_rating_result_submission': 'enable',
- 'security_rating_run_on_schedule': 'enable',
- 'send_pmtu_icmp': 'enable',
- 'snat_route_change': 'enable',
- 'special_file_23_support': 'disable',
- 'ssd_trim_date': '132',
- 'ssd_trim_freq': 'never',
- 'ssd_trim_hour': '134',
- 'ssd_trim_min': '135',
- 'ssd_trim_weekday': 'sunday',
- 'ssh_cbc_cipher': 'enable',
- 'ssh_hmac_md5': 'enable',
- 'ssh_kex_sha1': 'enable',
- 'ssl_min_proto_version': 'SSLv3',
- 'ssl_static_key_ciphers': 'enable',
- 'sslvpn_cipher_hardware_acceleration': 'enable',
- 'sslvpn_kxp_hardware_acceleration': 'enable',
- 'sslvpn_max_worker_count': '144',
- 'sslvpn_plugin_version_check': 'enable',
- 'strict_dirty_session_check': 'enable',
- 'strong_crypto': 'enable',
- 'switch_controller': 'disable',
- 'switch_controller_reserved_network': 'test_value_149',
- 'sys_perf_log_interval': '150',
- 'tcp_halfclose_timer': '151',
- 'tcp_halfopen_timer': '152',
- 'tcp_option': 'enable',
- 'tcp_timewait_timer': '154',
- 'tftp': 'enable',
- 'timezone': '01',
- 'tp_mc_skip_policy': 'enable',
- 'traffic_priority': 'tos',
- 'traffic_priority_level': 'low',
- 'two_factor_email_expiry': '160',
- 'two_factor_fac_expiry': '161',
- 'two_factor_ftk_expiry': '162',
- 'two_factor_ftm_expiry': '163',
- 'two_factor_sms_expiry': '164',
- 'udp_idle_timer': '165',
- 'user_server_cert': 'test_value_166',
- 'vdom_admin': 'enable',
- 'vip_arp_range': 'unlimited',
- 'virtual_server_count': '169',
- 'virtual_server_hardware_acceleration': 'disable',
- 'wad_affinity': 'test_value_171',
- 'wad_csvc_cs_count': '172',
- 'wad_csvc_db_count': '173',
- 'wad_source_affinity': 'disable',
- 'wad_worker_count': '175',
- 'wifi_ca_certificate': 'test_value_176',
- 'wifi_certificate': 'test_value_177',
- 'wimax_4g_usb': 'enable',
- 'wireless_controller': 'enable',
- 'wireless_controller_port': '180'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_global.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'admin-concurrent': 'enable',
- 'admin-console-timeout': '4',
- 'admin-hsts-max-age': '5',
- 'admin-https-pki-required': 'enable',
- 'admin-https-redirect': 'enable',
- 'admin-lockout-duration': '8',
- 'admin-lockout-threshold': '9',
- 'admin-login-max': '10',
- 'admin-maintainer': 'enable',
- 'admin-port': '12',
- 'admin-restrict-local': 'enable',
- 'admin-scp': 'enable',
- 'admin-server-cert': 'test_value_15',
- 'admin-sport': '16',
- 'admin-ssh-grace-time': '17',
- 'admin-ssh-password': 'enable',
- 'admin-ssh-port': '19',
- 'admin-ssh-v1': 'enable',
- 'admin-telnet-port': '21',
- 'admintimeout': '22',
- 'alias': 'test_value_23',
- 'allow-traffic-redirect': 'enable',
- 'anti-replay': 'disable',
- 'arp-max-entry': '26',
- 'asymroute': 'enable',
- 'auth-cert': 'test_value_28',
- 'auth-http-port': '29',
- 'auth-https-port': '30',
- 'auth-keepalive': 'enable',
- 'auth-session-limit': 'block-new',
- 'auto-auth-extension-device': 'enable',
- 'av-affinity': 'test_value_34',
- 'av-failopen': 'pass',
- 'av-failopen-session': 'enable',
- 'batch-cmdb': 'enable',
- 'block-session-timer': '38',
- 'br-fdb-max-entry': '39',
- 'cert-chain-max': '40',
- 'cfg-revert-timeout': '41',
- 'cfg-save': 'automatic',
- 'check-protocol-header': 'loose',
- 'check-reset-range': 'strict',
- 'cli-audit-log': 'enable',
- 'clt-cert-req': 'enable',
- 'compliance-check': 'enable',
- 'compliance-check-time': 'test_value_48',
- 'cpu-use-threshold': '49',
- 'csr-ca-attribute': 'enable',
- 'daily-restart': 'enable',
- 'device-identification-active-scan-delay': '52',
- 'device-idle-timeout': '53',
- 'dh-params': '1024',
- 'dnsproxy-worker-count': '55',
- 'dst': 'enable',
- 'endpoint-control-fds-access': 'enable',
- 'endpoint-control-portal-port': '58',
- 'failtime': '59',
- 'fds-statistics': 'enable',
- 'fds-statistics-period': '61',
- 'fortiextender': 'enable',
- 'fortiextender-data-port': '63',
- 'fortiextender-vlan-mode': 'enable',
- 'fortiservice-port': '65',
- 'gui-certificates': 'enable',
- 'gui-custom-language': 'enable',
- 'gui-date-format': 'yyyy/MM/dd',
- 'gui-device-latitude': 'test_value_69',
- 'gui-device-longitude': 'test_value_70',
- 'gui-display-hostname': 'enable',
- 'gui-ipv6': 'enable',
- 'gui-lines-per-page': '73',
- 'gui-theme': 'green',
- 'gui-wireless-opensecurity': 'enable',
- 'honor-df': 'enable',
- 'hostname': 'myhostname77',
- 'igmp-state-limit': '78',
- 'interval': '79',
- 'ip-src-port-range': 'test_value_80',
- 'ips-affinity': 'test_value_81',
- 'ipsec-asic-offload': 'enable',
- 'ipsec-hmac-offload': 'enable',
- 'ipsec-soft-dec-async': 'enable',
- 'ipv6-accept-dad': '85',
- 'ipv6-allow-anycast-probe': 'enable',
- 'language': 'english',
- 'ldapconntimeout': '88',
- 'lldp-transmission': 'enable',
- 'log-ssl-connection': 'enable',
- 'log-uuid': 'disable',
- 'login-timestamp': 'enable',
- 'long-vdom-name': 'enable',
- 'management-vdom': 'test_value_94',
- 'max-dlpstat-memory': '95',
- 'max-route-cache-size': '96',
- 'mc-ttl-notchange': 'enable',
- 'memory-use-threshold-extreme': '98',
- 'memory-use-threshold-green': '99',
- 'memory-use-threshold-red': '100',
- 'miglog-affinity': 'test_value_101',
- 'miglogd-children': '102',
- 'multi-factor-authentication': 'optional',
- 'multicast-forward': 'enable',
- 'ndp-max-entry': '105',
- 'per-user-bwl': 'enable',
- 'policy-auth-concurrent': '107',
- 'post-login-banner': 'disable',
- 'pre-login-banner': 'enable',
- 'private-data-encryption': 'disable',
- 'proxy-auth-lifetime': 'enable',
- 'proxy-auth-lifetime-timeout': '112',
- 'proxy-auth-timeout': '113',
- 'proxy-cipher-hardware-acceleration': 'disable',
- 'proxy-kxp-hardware-acceleration': 'disable',
- 'proxy-re-authentication-mode': 'session',
- 'proxy-worker-count': '117',
- 'radius-port': '118',
- 'reboot-upon-config-restore': 'enable',
- 'refresh': '120',
- 'remoteauthtimeout': '121',
- 'reset-sessionless-tcp': 'enable',
- 'restart-time': 'test_value_123',
- 'revision-backup-on-logout': 'enable',
- 'revision-image-auto-backup': 'enable',
- 'scanunit-count': '126',
- 'security-rating-result-submission': 'enable',
- 'security-rating-run-on-schedule': 'enable',
- 'send-pmtu-icmp': 'enable',
- 'snat-route-change': 'enable',
- 'special-file-23-support': 'disable',
- 'ssd-trim-date': '132',
- 'ssd-trim-freq': 'never',
- 'ssd-trim-hour': '134',
- 'ssd-trim-min': '135',
- 'ssd-trim-weekday': 'sunday',
- 'ssh-cbc-cipher': 'enable',
- 'ssh-hmac-md5': 'enable',
- 'ssh-kex-sha1': 'enable',
- 'ssl-min-proto-version': 'SSLv3',
- 'ssl-static-key-ciphers': 'enable',
- 'sslvpn-cipher-hardware-acceleration': 'enable',
- 'sslvpn-kxp-hardware-acceleration': 'enable',
- 'sslvpn-max-worker-count': '144',
- 'sslvpn-plugin-version-check': 'enable',
- 'strict-dirty-session-check': 'enable',
- 'strong-crypto': 'enable',
- 'switch-controller': 'disable',
- 'switch-controller-reserved-network': 'test_value_149',
- 'sys-perf-log-interval': '150',
- 'tcp-halfclose-timer': '151',
- 'tcp-halfopen-timer': '152',
- 'tcp-option': 'enable',
- 'tcp-timewait-timer': '154',
- 'tftp': 'enable',
- 'timezone': '01',
- 'tp-mc-skip-policy': 'enable',
- 'traffic-priority': 'tos',
- 'traffic-priority-level': 'low',
- 'two-factor-email-expiry': '160',
- 'two-factor-fac-expiry': '161',
- 'two-factor-ftk-expiry': '162',
- 'two-factor-ftm-expiry': '163',
- 'two-factor-sms-expiry': '164',
- 'udp-idle-timer': '165',
- 'user-server-cert': 'test_value_166',
- 'vdom-admin': 'enable',
- 'vip-arp-range': 'unlimited',
- 'virtual-server-count': '169',
- 'virtual-server-hardware-acceleration': 'disable',
- 'wad-affinity': 'test_value_171',
- 'wad-csvc-cs-count': '172',
- 'wad-csvc-db-count': '173',
- 'wad-source-affinity': 'disable',
- 'wad-worker-count': '175',
- 'wifi-ca-certificate': 'test_value_176',
- 'wifi-certificate': 'test_value_177',
- 'wimax-4g-usb': 'enable',
- 'wireless-controller': 'enable',
- 'wireless-controller-port': '180'
- }
-
- set_method_mock.assert_called_with('system', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_gre_tunnel.py b/test/units/modules/network/fortios/test_fortios_system_gre_tunnel.py
deleted file mode 100644
index eb00a47e0f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_gre_tunnel.py
+++ /dev/null
@@ -1,349 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_gre_tunnel
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_gre_tunnel.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_gre_tunnel_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_gre_tunnel': {
- 'checksum_reception': 'disable',
- 'checksum_transmission': 'disable',
- 'dscp_copying': 'disable',
- 'interface': 'test_value_6',
- 'ip_version': '4',
- 'keepalive_failtimes': '8',
- 'keepalive_interval': '9',
- 'key_inbound': '10',
- 'key_outbound': '11',
- 'local_gw': 'test_value_12',
- 'local_gw6': 'test_value_13',
- 'name': 'default_name_14',
- 'remote_gw': 'test_value_15',
- 'remote_gw6': 'test_value_16',
- 'sequence_number_reception': 'disable',
- 'sequence_number_transmission': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_gre_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'checksum-reception': 'disable',
- 'checksum-transmission': 'disable',
- 'dscp-copying': 'disable',
- 'interface': 'test_value_6',
- 'ip-version': '4',
- 'keepalive-failtimes': '8',
- 'keepalive-interval': '9',
- 'key-inbound': '10',
- 'key-outbound': '11',
- 'local-gw': 'test_value_12',
- 'local-gw6': 'test_value_13',
- 'name': 'default_name_14',
- 'remote-gw': 'test_value_15',
- 'remote-gw6': 'test_value_16',
- 'sequence-number-reception': 'disable',
- 'sequence-number-transmission': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'gre-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_gre_tunnel_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_gre_tunnel': {
- 'checksum_reception': 'disable',
- 'checksum_transmission': 'disable',
- 'dscp_copying': 'disable',
- 'interface': 'test_value_6',
- 'ip_version': '4',
- 'keepalive_failtimes': '8',
- 'keepalive_interval': '9',
- 'key_inbound': '10',
- 'key_outbound': '11',
- 'local_gw': 'test_value_12',
- 'local_gw6': 'test_value_13',
- 'name': 'default_name_14',
- 'remote_gw': 'test_value_15',
- 'remote_gw6': 'test_value_16',
- 'sequence_number_reception': 'disable',
- 'sequence_number_transmission': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_gre_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'checksum-reception': 'disable',
- 'checksum-transmission': 'disable',
- 'dscp-copying': 'disable',
- 'interface': 'test_value_6',
- 'ip-version': '4',
- 'keepalive-failtimes': '8',
- 'keepalive-interval': '9',
- 'key-inbound': '10',
- 'key-outbound': '11',
- 'local-gw': 'test_value_12',
- 'local-gw6': 'test_value_13',
- 'name': 'default_name_14',
- 'remote-gw': 'test_value_15',
- 'remote-gw6': 'test_value_16',
- 'sequence-number-reception': 'disable',
- 'sequence-number-transmission': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'gre-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_gre_tunnel_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_gre_tunnel': {
- 'checksum_reception': 'disable',
- 'checksum_transmission': 'disable',
- 'dscp_copying': 'disable',
- 'interface': 'test_value_6',
- 'ip_version': '4',
- 'keepalive_failtimes': '8',
- 'keepalive_interval': '9',
- 'key_inbound': '10',
- 'key_outbound': '11',
- 'local_gw': 'test_value_12',
- 'local_gw6': 'test_value_13',
- 'name': 'default_name_14',
- 'remote_gw': 'test_value_15',
- 'remote_gw6': 'test_value_16',
- 'sequence_number_reception': 'disable',
- 'sequence_number_transmission': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_gre_tunnel.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'gre-tunnel', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_gre_tunnel_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_gre_tunnel': {
- 'checksum_reception': 'disable',
- 'checksum_transmission': 'disable',
- 'dscp_copying': 'disable',
- 'interface': 'test_value_6',
- 'ip_version': '4',
- 'keepalive_failtimes': '8',
- 'keepalive_interval': '9',
- 'key_inbound': '10',
- 'key_outbound': '11',
- 'local_gw': 'test_value_12',
- 'local_gw6': 'test_value_13',
- 'name': 'default_name_14',
- 'remote_gw': 'test_value_15',
- 'remote_gw6': 'test_value_16',
- 'sequence_number_reception': 'disable',
- 'sequence_number_transmission': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_gre_tunnel.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'gre-tunnel', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_gre_tunnel_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_gre_tunnel': {
- 'checksum_reception': 'disable',
- 'checksum_transmission': 'disable',
- 'dscp_copying': 'disable',
- 'interface': 'test_value_6',
- 'ip_version': '4',
- 'keepalive_failtimes': '8',
- 'keepalive_interval': '9',
- 'key_inbound': '10',
- 'key_outbound': '11',
- 'local_gw': 'test_value_12',
- 'local_gw6': 'test_value_13',
- 'name': 'default_name_14',
- 'remote_gw': 'test_value_15',
- 'remote_gw6': 'test_value_16',
- 'sequence_number_reception': 'disable',
- 'sequence_number_transmission': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_gre_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'checksum-reception': 'disable',
- 'checksum-transmission': 'disable',
- 'dscp-copying': 'disable',
- 'interface': 'test_value_6',
- 'ip-version': '4',
- 'keepalive-failtimes': '8',
- 'keepalive-interval': '9',
- 'key-inbound': '10',
- 'key-outbound': '11',
- 'local-gw': 'test_value_12',
- 'local-gw6': 'test_value_13',
- 'name': 'default_name_14',
- 'remote-gw': 'test_value_15',
- 'remote-gw6': 'test_value_16',
- 'sequence-number-reception': 'disable',
- 'sequence-number-transmission': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'gre-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_gre_tunnel_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_gre_tunnel': {
- 'random_attribute_not_valid': 'tag',
- 'checksum_reception': 'disable',
- 'checksum_transmission': 'disable',
- 'dscp_copying': 'disable',
- 'interface': 'test_value_6',
- 'ip_version': '4',
- 'keepalive_failtimes': '8',
- 'keepalive_interval': '9',
- 'key_inbound': '10',
- 'key_outbound': '11',
- 'local_gw': 'test_value_12',
- 'local_gw6': 'test_value_13',
- 'name': 'default_name_14',
- 'remote_gw': 'test_value_15',
- 'remote_gw6': 'test_value_16',
- 'sequence_number_reception': 'disable',
- 'sequence_number_transmission': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_gre_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'checksum-reception': 'disable',
- 'checksum-transmission': 'disable',
- 'dscp-copying': 'disable',
- 'interface': 'test_value_6',
- 'ip-version': '4',
- 'keepalive-failtimes': '8',
- 'keepalive-interval': '9',
- 'key-inbound': '10',
- 'key-outbound': '11',
- 'local-gw': 'test_value_12',
- 'local-gw6': 'test_value_13',
- 'name': 'default_name_14',
- 'remote-gw': 'test_value_15',
- 'remote-gw6': 'test_value_16',
- 'sequence-number-reception': 'disable',
- 'sequence-number-transmission': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'gre-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_ha.py b/test/units/modules/network/fortios/test_fortios_system_ha.py
deleted file mode 100644
index dc2fdfbfb1..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_ha.py
+++ /dev/null
@@ -1,647 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_ha
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_ha.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_ha_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ha': {
- 'arps': '3',
- 'arps_interval': '4',
- 'authentication': 'enable',
- 'cpu_threshold': 'test_value_6',
- 'encryption': 'enable',
- 'ftp_proxy_threshold': 'test_value_8',
- 'gratuitous_arps': 'enable',
- 'group_id': '10',
- 'group_name': 'test_value_11',
- 'ha_direct': 'enable',
- 'ha_eth_type': 'test_value_13',
- 'ha_mgmt_status': 'enable',
- 'ha_uptime_diff_margin': '15',
- 'hb_interval': '16',
- 'hb_lost_threshold': '17',
- 'hbdev': 'test_value_18',
- 'hc_eth_type': 'test_value_19',
- 'hello_holddown': '20',
- 'http_proxy_threshold': 'test_value_21',
- 'imap_proxy_threshold': 'test_value_22',
- 'inter_cluster_session_sync': 'enable',
- 'key': 'test_value_24',
- 'l2ep_eth_type': 'test_value_25',
- 'link_failed_signal': 'enable',
- 'load_balance_all': 'enable',
- 'memory_compatible_mode': 'enable',
- 'memory_threshold': 'test_value_29',
- 'mode': 'standalone',
- 'monitor': 'test_value_31',
- 'multicast_ttl': '32',
- 'nntp_proxy_threshold': 'test_value_33',
- 'override': 'enable',
- 'override_wait_time': '35',
- 'password': 'test_value_36',
- 'pingserver_failover_threshold': '37',
- 'pingserver_flip_timeout': '38',
- 'pingserver_monitor_interface': 'test_value_39',
- 'pingserver_slave_force_reset': 'enable',
- 'pop3_proxy_threshold': 'test_value_41',
- 'priority': '42',
- 'route_hold': '43',
- 'route_ttl': '44',
- 'route_wait': '45',
- 'schedule': 'none',
- 'session_pickup': 'enable',
- 'session_pickup_connectionless': 'enable',
- 'session_pickup_delay': 'enable',
- 'session_pickup_expectation': 'enable',
- 'session_pickup_nat': 'enable',
- 'session_sync_dev': 'test_value_52',
- 'smtp_proxy_threshold': 'test_value_53',
- 'standalone_config_sync': 'enable',
- 'standalone_mgmt_vdom': 'enable',
- 'sync_config': 'enable',
- 'sync_packet_balance': 'enable',
- 'unicast_hb': 'enable',
- 'unicast_hb_netmask': 'test_value_59',
- 'unicast_hb_peerip': 'test_value_60',
- 'uninterruptible_upgrade': 'enable',
- 'vcluster_id': '62',
- 'vcluster2': 'enable',
- 'vdom': 'test_value_64',
- 'weight': 'test_value_65'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ha.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'arps': '3',
- 'arps-interval': '4',
- 'authentication': 'enable',
- 'cpu-threshold': 'test_value_6',
- 'encryption': 'enable',
- 'ftp-proxy-threshold': 'test_value_8',
- 'gratuitous-arps': 'enable',
- 'group-id': '10',
- 'group-name': 'test_value_11',
- 'ha-direct': 'enable',
- 'ha-eth-type': 'test_value_13',
- 'ha-mgmt-status': 'enable',
- 'ha-uptime-diff-margin': '15',
- 'hb-interval': '16',
- 'hb-lost-threshold': '17',
- 'hbdev': 'test_value_18',
- 'hc-eth-type': 'test_value_19',
- 'hello-holddown': '20',
- 'http-proxy-threshold': 'test_value_21',
- 'imap-proxy-threshold': 'test_value_22',
- 'inter-cluster-session-sync': 'enable',
- 'key': 'test_value_24',
- 'l2ep-eth-type': 'test_value_25',
- 'link-failed-signal': 'enable',
- 'load-balance-all': 'enable',
- 'memory-compatible-mode': 'enable',
- 'memory-threshold': 'test_value_29',
- 'mode': 'standalone',
- 'monitor': 'test_value_31',
- 'multicast-ttl': '32',
- 'nntp-proxy-threshold': 'test_value_33',
- 'override': 'enable',
- 'override-wait-time': '35',
- 'password': 'test_value_36',
- 'pingserver-failover-threshold': '37',
- 'pingserver-flip-timeout': '38',
- 'pingserver-monitor-interface': 'test_value_39',
- 'pingserver-slave-force-reset': 'enable',
- 'pop3-proxy-threshold': 'test_value_41',
- 'priority': '42',
- 'route-hold': '43',
- 'route-ttl': '44',
- 'route-wait': '45',
- 'schedule': 'none',
- 'session-pickup': 'enable',
- 'session-pickup-connectionless': 'enable',
- 'session-pickup-delay': 'enable',
- 'session-pickup-expectation': 'enable',
- 'session-pickup-nat': 'enable',
- 'session-sync-dev': 'test_value_52',
- 'smtp-proxy-threshold': 'test_value_53',
- 'standalone-config-sync': 'enable',
- 'standalone-mgmt-vdom': 'enable',
- 'sync-config': 'enable',
- 'sync-packet-balance': 'enable',
- 'unicast-hb': 'enable',
- 'unicast-hb-netmask': 'test_value_59',
- 'unicast-hb-peerip': 'test_value_60',
- 'uninterruptible-upgrade': 'enable',
- 'vcluster-id': '62',
- 'vcluster2': 'enable',
- 'vdom': 'test_value_64',
- 'weight': 'test_value_65'
- }
-
- set_method_mock.assert_called_with('system', 'ha', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ha_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ha': {
- 'arps': '3',
- 'arps_interval': '4',
- 'authentication': 'enable',
- 'cpu_threshold': 'test_value_6',
- 'encryption': 'enable',
- 'ftp_proxy_threshold': 'test_value_8',
- 'gratuitous_arps': 'enable',
- 'group_id': '10',
- 'group_name': 'test_value_11',
- 'ha_direct': 'enable',
- 'ha_eth_type': 'test_value_13',
- 'ha_mgmt_status': 'enable',
- 'ha_uptime_diff_margin': '15',
- 'hb_interval': '16',
- 'hb_lost_threshold': '17',
- 'hbdev': 'test_value_18',
- 'hc_eth_type': 'test_value_19',
- 'hello_holddown': '20',
- 'http_proxy_threshold': 'test_value_21',
- 'imap_proxy_threshold': 'test_value_22',
- 'inter_cluster_session_sync': 'enable',
- 'key': 'test_value_24',
- 'l2ep_eth_type': 'test_value_25',
- 'link_failed_signal': 'enable',
- 'load_balance_all': 'enable',
- 'memory_compatible_mode': 'enable',
- 'memory_threshold': 'test_value_29',
- 'mode': 'standalone',
- 'monitor': 'test_value_31',
- 'multicast_ttl': '32',
- 'nntp_proxy_threshold': 'test_value_33',
- 'override': 'enable',
- 'override_wait_time': '35',
- 'password': 'test_value_36',
- 'pingserver_failover_threshold': '37',
- 'pingserver_flip_timeout': '38',
- 'pingserver_monitor_interface': 'test_value_39',
- 'pingserver_slave_force_reset': 'enable',
- 'pop3_proxy_threshold': 'test_value_41',
- 'priority': '42',
- 'route_hold': '43',
- 'route_ttl': '44',
- 'route_wait': '45',
- 'schedule': 'none',
- 'session_pickup': 'enable',
- 'session_pickup_connectionless': 'enable',
- 'session_pickup_delay': 'enable',
- 'session_pickup_expectation': 'enable',
- 'session_pickup_nat': 'enable',
- 'session_sync_dev': 'test_value_52',
- 'smtp_proxy_threshold': 'test_value_53',
- 'standalone_config_sync': 'enable',
- 'standalone_mgmt_vdom': 'enable',
- 'sync_config': 'enable',
- 'sync_packet_balance': 'enable',
- 'unicast_hb': 'enable',
- 'unicast_hb_netmask': 'test_value_59',
- 'unicast_hb_peerip': 'test_value_60',
- 'uninterruptible_upgrade': 'enable',
- 'vcluster_id': '62',
- 'vcluster2': 'enable',
- 'vdom': 'test_value_64',
- 'weight': 'test_value_65'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ha.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'arps': '3',
- 'arps-interval': '4',
- 'authentication': 'enable',
- 'cpu-threshold': 'test_value_6',
- 'encryption': 'enable',
- 'ftp-proxy-threshold': 'test_value_8',
- 'gratuitous-arps': 'enable',
- 'group-id': '10',
- 'group-name': 'test_value_11',
- 'ha-direct': 'enable',
- 'ha-eth-type': 'test_value_13',
- 'ha-mgmt-status': 'enable',
- 'ha-uptime-diff-margin': '15',
- 'hb-interval': '16',
- 'hb-lost-threshold': '17',
- 'hbdev': 'test_value_18',
- 'hc-eth-type': 'test_value_19',
- 'hello-holddown': '20',
- 'http-proxy-threshold': 'test_value_21',
- 'imap-proxy-threshold': 'test_value_22',
- 'inter-cluster-session-sync': 'enable',
- 'key': 'test_value_24',
- 'l2ep-eth-type': 'test_value_25',
- 'link-failed-signal': 'enable',
- 'load-balance-all': 'enable',
- 'memory-compatible-mode': 'enable',
- 'memory-threshold': 'test_value_29',
- 'mode': 'standalone',
- 'monitor': 'test_value_31',
- 'multicast-ttl': '32',
- 'nntp-proxy-threshold': 'test_value_33',
- 'override': 'enable',
- 'override-wait-time': '35',
- 'password': 'test_value_36',
- 'pingserver-failover-threshold': '37',
- 'pingserver-flip-timeout': '38',
- 'pingserver-monitor-interface': 'test_value_39',
- 'pingserver-slave-force-reset': 'enable',
- 'pop3-proxy-threshold': 'test_value_41',
- 'priority': '42',
- 'route-hold': '43',
- 'route-ttl': '44',
- 'route-wait': '45',
- 'schedule': 'none',
- 'session-pickup': 'enable',
- 'session-pickup-connectionless': 'enable',
- 'session-pickup-delay': 'enable',
- 'session-pickup-expectation': 'enable',
- 'session-pickup-nat': 'enable',
- 'session-sync-dev': 'test_value_52',
- 'smtp-proxy-threshold': 'test_value_53',
- 'standalone-config-sync': 'enable',
- 'standalone-mgmt-vdom': 'enable',
- 'sync-config': 'enable',
- 'sync-packet-balance': 'enable',
- 'unicast-hb': 'enable',
- 'unicast-hb-netmask': 'test_value_59',
- 'unicast-hb-peerip': 'test_value_60',
- 'uninterruptible-upgrade': 'enable',
- 'vcluster-id': '62',
- 'vcluster2': 'enable',
- 'vdom': 'test_value_64',
- 'weight': 'test_value_65'
- }
-
- set_method_mock.assert_called_with('system', 'ha', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ha_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ha': {
- 'arps': '3',
- 'arps_interval': '4',
- 'authentication': 'enable',
- 'cpu_threshold': 'test_value_6',
- 'encryption': 'enable',
- 'ftp_proxy_threshold': 'test_value_8',
- 'gratuitous_arps': 'enable',
- 'group_id': '10',
- 'group_name': 'test_value_11',
- 'ha_direct': 'enable',
- 'ha_eth_type': 'test_value_13',
- 'ha_mgmt_status': 'enable',
- 'ha_uptime_diff_margin': '15',
- 'hb_interval': '16',
- 'hb_lost_threshold': '17',
- 'hbdev': 'test_value_18',
- 'hc_eth_type': 'test_value_19',
- 'hello_holddown': '20',
- 'http_proxy_threshold': 'test_value_21',
- 'imap_proxy_threshold': 'test_value_22',
- 'inter_cluster_session_sync': 'enable',
- 'key': 'test_value_24',
- 'l2ep_eth_type': 'test_value_25',
- 'link_failed_signal': 'enable',
- 'load_balance_all': 'enable',
- 'memory_compatible_mode': 'enable',
- 'memory_threshold': 'test_value_29',
- 'mode': 'standalone',
- 'monitor': 'test_value_31',
- 'multicast_ttl': '32',
- 'nntp_proxy_threshold': 'test_value_33',
- 'override': 'enable',
- 'override_wait_time': '35',
- 'password': 'test_value_36',
- 'pingserver_failover_threshold': '37',
- 'pingserver_flip_timeout': '38',
- 'pingserver_monitor_interface': 'test_value_39',
- 'pingserver_slave_force_reset': 'enable',
- 'pop3_proxy_threshold': 'test_value_41',
- 'priority': '42',
- 'route_hold': '43',
- 'route_ttl': '44',
- 'route_wait': '45',
- 'schedule': 'none',
- 'session_pickup': 'enable',
- 'session_pickup_connectionless': 'enable',
- 'session_pickup_delay': 'enable',
- 'session_pickup_expectation': 'enable',
- 'session_pickup_nat': 'enable',
- 'session_sync_dev': 'test_value_52',
- 'smtp_proxy_threshold': 'test_value_53',
- 'standalone_config_sync': 'enable',
- 'standalone_mgmt_vdom': 'enable',
- 'sync_config': 'enable',
- 'sync_packet_balance': 'enable',
- 'unicast_hb': 'enable',
- 'unicast_hb_netmask': 'test_value_59',
- 'unicast_hb_peerip': 'test_value_60',
- 'uninterruptible_upgrade': 'enable',
- 'vcluster_id': '62',
- 'vcluster2': 'enable',
- 'vdom': 'test_value_64',
- 'weight': 'test_value_65'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ha.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'arps': '3',
- 'arps-interval': '4',
- 'authentication': 'enable',
- 'cpu-threshold': 'test_value_6',
- 'encryption': 'enable',
- 'ftp-proxy-threshold': 'test_value_8',
- 'gratuitous-arps': 'enable',
- 'group-id': '10',
- 'group-name': 'test_value_11',
- 'ha-direct': 'enable',
- 'ha-eth-type': 'test_value_13',
- 'ha-mgmt-status': 'enable',
- 'ha-uptime-diff-margin': '15',
- 'hb-interval': '16',
- 'hb-lost-threshold': '17',
- 'hbdev': 'test_value_18',
- 'hc-eth-type': 'test_value_19',
- 'hello-holddown': '20',
- 'http-proxy-threshold': 'test_value_21',
- 'imap-proxy-threshold': 'test_value_22',
- 'inter-cluster-session-sync': 'enable',
- 'key': 'test_value_24',
- 'l2ep-eth-type': 'test_value_25',
- 'link-failed-signal': 'enable',
- 'load-balance-all': 'enable',
- 'memory-compatible-mode': 'enable',
- 'memory-threshold': 'test_value_29',
- 'mode': 'standalone',
- 'monitor': 'test_value_31',
- 'multicast-ttl': '32',
- 'nntp-proxy-threshold': 'test_value_33',
- 'override': 'enable',
- 'override-wait-time': '35',
- 'password': 'test_value_36',
- 'pingserver-failover-threshold': '37',
- 'pingserver-flip-timeout': '38',
- 'pingserver-monitor-interface': 'test_value_39',
- 'pingserver-slave-force-reset': 'enable',
- 'pop3-proxy-threshold': 'test_value_41',
- 'priority': '42',
- 'route-hold': '43',
- 'route-ttl': '44',
- 'route-wait': '45',
- 'schedule': 'none',
- 'session-pickup': 'enable',
- 'session-pickup-connectionless': 'enable',
- 'session-pickup-delay': 'enable',
- 'session-pickup-expectation': 'enable',
- 'session-pickup-nat': 'enable',
- 'session-sync-dev': 'test_value_52',
- 'smtp-proxy-threshold': 'test_value_53',
- 'standalone-config-sync': 'enable',
- 'standalone-mgmt-vdom': 'enable',
- 'sync-config': 'enable',
- 'sync-packet-balance': 'enable',
- 'unicast-hb': 'enable',
- 'unicast-hb-netmask': 'test_value_59',
- 'unicast-hb-peerip': 'test_value_60',
- 'uninterruptible-upgrade': 'enable',
- 'vcluster-id': '62',
- 'vcluster2': 'enable',
- 'vdom': 'test_value_64',
- 'weight': 'test_value_65'
- }
-
- set_method_mock.assert_called_with('system', 'ha', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_ha_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ha': {
- 'random_attribute_not_valid': 'tag',
- 'arps': '3',
- 'arps_interval': '4',
- 'authentication': 'enable',
- 'cpu_threshold': 'test_value_6',
- 'encryption': 'enable',
- 'ftp_proxy_threshold': 'test_value_8',
- 'gratuitous_arps': 'enable',
- 'group_id': '10',
- 'group_name': 'test_value_11',
- 'ha_direct': 'enable',
- 'ha_eth_type': 'test_value_13',
- 'ha_mgmt_status': 'enable',
- 'ha_uptime_diff_margin': '15',
- 'hb_interval': '16',
- 'hb_lost_threshold': '17',
- 'hbdev': 'test_value_18',
- 'hc_eth_type': 'test_value_19',
- 'hello_holddown': '20',
- 'http_proxy_threshold': 'test_value_21',
- 'imap_proxy_threshold': 'test_value_22',
- 'inter_cluster_session_sync': 'enable',
- 'key': 'test_value_24',
- 'l2ep_eth_type': 'test_value_25',
- 'link_failed_signal': 'enable',
- 'load_balance_all': 'enable',
- 'memory_compatible_mode': 'enable',
- 'memory_threshold': 'test_value_29',
- 'mode': 'standalone',
- 'monitor': 'test_value_31',
- 'multicast_ttl': '32',
- 'nntp_proxy_threshold': 'test_value_33',
- 'override': 'enable',
- 'override_wait_time': '35',
- 'password': 'test_value_36',
- 'pingserver_failover_threshold': '37',
- 'pingserver_flip_timeout': '38',
- 'pingserver_monitor_interface': 'test_value_39',
- 'pingserver_slave_force_reset': 'enable',
- 'pop3_proxy_threshold': 'test_value_41',
- 'priority': '42',
- 'route_hold': '43',
- 'route_ttl': '44',
- 'route_wait': '45',
- 'schedule': 'none',
- 'session_pickup': 'enable',
- 'session_pickup_connectionless': 'enable',
- 'session_pickup_delay': 'enable',
- 'session_pickup_expectation': 'enable',
- 'session_pickup_nat': 'enable',
- 'session_sync_dev': 'test_value_52',
- 'smtp_proxy_threshold': 'test_value_53',
- 'standalone_config_sync': 'enable',
- 'standalone_mgmt_vdom': 'enable',
- 'sync_config': 'enable',
- 'sync_packet_balance': 'enable',
- 'unicast_hb': 'enable',
- 'unicast_hb_netmask': 'test_value_59',
- 'unicast_hb_peerip': 'test_value_60',
- 'uninterruptible_upgrade': 'enable',
- 'vcluster_id': '62',
- 'vcluster2': 'enable',
- 'vdom': 'test_value_64',
- 'weight': 'test_value_65'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ha.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'arps': '3',
- 'arps-interval': '4',
- 'authentication': 'enable',
- 'cpu-threshold': 'test_value_6',
- 'encryption': 'enable',
- 'ftp-proxy-threshold': 'test_value_8',
- 'gratuitous-arps': 'enable',
- 'group-id': '10',
- 'group-name': 'test_value_11',
- 'ha-direct': 'enable',
- 'ha-eth-type': 'test_value_13',
- 'ha-mgmt-status': 'enable',
- 'ha-uptime-diff-margin': '15',
- 'hb-interval': '16',
- 'hb-lost-threshold': '17',
- 'hbdev': 'test_value_18',
- 'hc-eth-type': 'test_value_19',
- 'hello-holddown': '20',
- 'http-proxy-threshold': 'test_value_21',
- 'imap-proxy-threshold': 'test_value_22',
- 'inter-cluster-session-sync': 'enable',
- 'key': 'test_value_24',
- 'l2ep-eth-type': 'test_value_25',
- 'link-failed-signal': 'enable',
- 'load-balance-all': 'enable',
- 'memory-compatible-mode': 'enable',
- 'memory-threshold': 'test_value_29',
- 'mode': 'standalone',
- 'monitor': 'test_value_31',
- 'multicast-ttl': '32',
- 'nntp-proxy-threshold': 'test_value_33',
- 'override': 'enable',
- 'override-wait-time': '35',
- 'password': 'test_value_36',
- 'pingserver-failover-threshold': '37',
- 'pingserver-flip-timeout': '38',
- 'pingserver-monitor-interface': 'test_value_39',
- 'pingserver-slave-force-reset': 'enable',
- 'pop3-proxy-threshold': 'test_value_41',
- 'priority': '42',
- 'route-hold': '43',
- 'route-ttl': '44',
- 'route-wait': '45',
- 'schedule': 'none',
- 'session-pickup': 'enable',
- 'session-pickup-connectionless': 'enable',
- 'session-pickup-delay': 'enable',
- 'session-pickup-expectation': 'enable',
- 'session-pickup-nat': 'enable',
- 'session-sync-dev': 'test_value_52',
- 'smtp-proxy-threshold': 'test_value_53',
- 'standalone-config-sync': 'enable',
- 'standalone-mgmt-vdom': 'enable',
- 'sync-config': 'enable',
- 'sync-packet-balance': 'enable',
- 'unicast-hb': 'enable',
- 'unicast-hb-netmask': 'test_value_59',
- 'unicast-hb-peerip': 'test_value_60',
- 'uninterruptible-upgrade': 'enable',
- 'vcluster-id': '62',
- 'vcluster2': 'enable',
- 'vdom': 'test_value_64',
- 'weight': 'test_value_65'
- }
-
- set_method_mock.assert_called_with('system', 'ha', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_ha_monitor.py b/test/units/modules/network/fortios/test_fortios_system_ha_monitor.py
deleted file mode 100644
index 34cb747f1d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_ha_monitor.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_ha_monitor
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_ha_monitor.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_ha_monitor_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ha_monitor': {
- 'monitor_vlan': 'enable',
- 'vlan_hb_interval': '4',
- 'vlan_hb_lost_threshold': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ha_monitor.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'monitor-vlan': 'enable',
- 'vlan-hb-interval': '4',
- 'vlan-hb-lost-threshold': '5'
- }
-
- set_method_mock.assert_called_with('system', 'ha-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ha_monitor_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ha_monitor': {
- 'monitor_vlan': 'enable',
- 'vlan_hb_interval': '4',
- 'vlan_hb_lost_threshold': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ha_monitor.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'monitor-vlan': 'enable',
- 'vlan-hb-interval': '4',
- 'vlan-hb-lost-threshold': '5'
- }
-
- set_method_mock.assert_called_with('system', 'ha-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ha_monitor_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ha_monitor': {
- 'monitor_vlan': 'enable',
- 'vlan_hb_interval': '4',
- 'vlan_hb_lost_threshold': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ha_monitor.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'monitor-vlan': 'enable',
- 'vlan-hb-interval': '4',
- 'vlan-hb-lost-threshold': '5'
- }
-
- set_method_mock.assert_called_with('system', 'ha-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_ha_monitor_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ha_monitor': {
- 'random_attribute_not_valid': 'tag',
- 'monitor_vlan': 'enable',
- 'vlan_hb_interval': '4',
- 'vlan_hb_lost_threshold': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ha_monitor.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'monitor-vlan': 'enable',
- 'vlan-hb-interval': '4',
- 'vlan-hb-lost-threshold': '5'
- }
-
- set_method_mock.assert_called_with('system', 'ha-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_interface.py b/test/units/modules/network/fortios/test_fortios_system_interface.py
deleted file mode 100644
index 41a5bfd27e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_interface.py
+++ /dev/null
@@ -1,1769 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_interface
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_interface.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_interface_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_interface': {
- 'ac_name': 'test_value_3',
- 'aggregate': 'test_value_4',
- 'algorithm': 'L2',
- 'alias': 'test_value_6',
- 'ap_discover': 'enable',
- 'arpforward': 'enable',
- 'auth_type': 'auto',
- 'auto_auth_extension_device': 'enable',
- 'bfd': 'global',
- 'bfd_desired_min_tx': '12',
- 'bfd_detect_mult': '13',
- 'bfd_required_min_rx': '14',
- 'broadcast_forticlient_discovery': 'enable',
- 'broadcast_forward': 'enable',
- 'captive_portal': '17',
- 'cli_conn_status': '18',
- 'color': '19',
- 'dedicated_to': 'none',
- 'defaultgw': 'enable',
- 'description': 'test_value_22',
- 'detected_peer_mtu': '23',
- 'detectprotocol': 'ping',
- 'detectserver': 'test_value_25',
- 'device_access_list': 'test_value_26',
- 'device_identification': 'enable',
- 'device_identification_active_scan': 'enable',
- 'device_netscan': 'disable',
- 'device_user_identification': 'enable',
- 'devindex': '31',
- 'dhcp_client_identifier': 'myId_32',
- 'dhcp_relay_agent_option': 'enable',
- 'dhcp_relay_ip': 'test_value_34',
- 'dhcp_relay_service': 'disable',
- 'dhcp_relay_type': 'regular',
- 'dhcp_renew_time': '37',
- 'disc_retry_timeout': '38',
- 'disconnect_threshold': '39',
- 'distance': '40',
- 'dns_server_override': 'enable',
- 'drop_fragment': 'enable',
- 'drop_overlapped_fragment': 'enable',
- 'egress_shaping_profile': 'test_value_44',
- 'endpoint_compliance': 'enable',
- 'estimated_downstream_bandwidth': '46',
- 'estimated_upstream_bandwidth': '47',
- 'explicit_ftp_proxy': 'enable',
- 'explicit_web_proxy': 'enable',
- 'external': 'enable',
- 'fail_action_on_extender': 'soft-restart',
- 'fail_alert_method': 'link-failed-signal',
- 'fail_detect': 'enable',
- 'fail_detect_option': 'detectserver',
- 'fortiheartbeat': 'enable',
- 'fortilink': 'enable',
- 'fortilink_backup_link': '57',
- 'fortilink_split_interface': 'enable',
- 'fortilink_stacking': 'enable',
- 'forward_domain': '60',
- 'gwdetect': 'enable',
- 'ha_priority': '62',
- 'icmp_accept_redirect': 'enable',
- 'icmp_send_redirect': 'enable',
- 'ident_accept': 'enable',
- 'idle_timeout': '66',
- 'inbandwidth': '67',
- 'ingress_spillover_threshold': '68',
- 'interface': 'test_value_69',
- 'internal': '70',
- 'ip': 'test_value_71',
- 'ipmac': 'enable',
- 'ips_sniffer_mode': 'enable',
- 'ipunnumbered': 'test_value_74',
- 'l2forward': 'enable',
- 'lacp_ha_slave': 'enable',
- 'lacp_mode': 'static',
- 'lacp_speed': 'slow',
- 'lcp_echo_interval': '79',
- 'lcp_max_echo_fails': '80',
- 'link_up_delay': '81',
- 'lldp_transmission': 'enable',
- 'macaddr': 'test_value_83',
- 'management_ip': 'test_value_84',
- 'min_links': '85',
- 'min_links_down': 'operational',
- 'mode': 'static',
- 'mtu': '88',
- 'mtu_override': 'enable',
- 'name': 'default_name_90',
- 'ndiscforward': 'enable',
- 'netbios_forward': 'disable',
- 'netflow_sampler': 'disable',
- 'outbandwidth': '94',
- 'padt_retry_timeout': '95',
- 'password': 'test_value_96',
- 'ping_serv_status': '97',
- 'polling_interval': '98',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'pptp_auth_type': 'auto',
- 'pptp_client': 'enable',
- 'pptp_password': 'test_value_102',
- 'pptp_server_ip': 'test_value_103',
- 'pptp_timeout': '104',
- 'pptp_user': 'test_value_105',
- 'preserve_session_route': 'enable',
- 'priority': '107',
- 'priority_override': 'enable',
- 'proxy_captive_portal': 'enable',
- 'redundant_interface': 'test_value_110',
- 'remote_ip': 'test_value_111',
- 'replacemsg_override_group': 'test_value_112',
- 'role': 'lan',
- 'sample_direction': 'tx',
- 'sample_rate': '115',
- 'scan_botnet_connections': 'disable',
- 'secondary_IP': 'enable',
- 'security_exempt_list': 'test_value_118',
- 'security_external_logout': 'test_value_119',
- 'security_external_web': 'test_value_120',
- 'security_mac_auth_bypass': 'enable',
- 'security_mode': 'none',
- 'security_redirect_url': 'test_value_123',
- 'service_name': 'test_value_124',
- 'sflow_sampler': 'enable',
- 'snmp_index': '126',
- 'speed': 'auto',
- 'spillover_threshold': '128',
- 'src_check': 'enable',
- 'status': 'up',
- 'stpforward': 'enable',
- 'stpforward_mode': 'rpl-all-ext-id',
- 'subst': 'enable',
- 'substitute_dst_mac': 'test_value_134',
- 'switch': 'test_value_135',
- 'switch_controller_access_vlan': 'enable',
- 'switch_controller_arp_inspection': 'enable',
- 'switch_controller_dhcp_snooping': 'enable',
- 'switch_controller_dhcp_snooping_option82': 'enable',
- 'switch_controller_dhcp_snooping_verify_mac': 'enable',
- 'switch_controller_igmp_snooping': 'enable',
- 'switch_controller_learning_limit': '142',
- 'tcp_mss': '143',
- 'trust_ip_1': 'test_value_144',
- 'trust_ip_2': 'test_value_145',
- 'trust_ip_3': 'test_value_146',
- 'trust_ip6_1': 'test_value_147',
- 'trust_ip6_2': 'test_value_148',
- 'trust_ip6_3': 'test_value_149',
- 'type': 'physical',
- 'username': 'test_value_151',
- 'vdom': 'test_value_152',
- 'vindex': '153',
- 'vlanforward': 'enable',
- 'vlanid': '155',
- 'vrf': '156',
- 'vrrp_virtual_mac': 'enable',
- 'wccp': 'enable',
- 'weight': '159',
- 'wins_ip': 'test_value_160'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ac-name': 'test_value_3',
- 'aggregate': 'test_value_4',
- 'algorithm': 'L2',
- 'alias': 'test_value_6',
- 'ap-discover': 'enable',
- 'arpforward': 'enable',
- 'auth-type': 'auto',
- 'auto-auth-extension-device': 'enable',
- 'bfd': 'global',
- 'bfd-desired-min-tx': '12',
- 'bfd-detect-mult': '13',
- 'bfd-required-min-rx': '14',
- 'broadcast-forticlient-discovery': 'enable',
- 'broadcast-forward': 'enable',
- 'captive-portal': '17',
- 'cli-conn-status': '18',
- 'color': '19',
- 'dedicated-to': 'none',
- 'defaultgw': 'enable',
- 'description': 'test_value_22',
- 'detected-peer-mtu': '23',
- 'detectprotocol': 'ping',
- 'detectserver': 'test_value_25',
- 'device-access-list': 'test_value_26',
- 'device-identification': 'enable',
- 'device-identification-active-scan': 'enable',
- 'device-netscan': 'disable',
- 'device-user-identification': 'enable',
- 'devindex': '31',
- 'dhcp-client-identifier': 'myId_32',
- 'dhcp-relay-agent-option': 'enable',
- 'dhcp-relay-ip': 'test_value_34',
- 'dhcp-relay-service': 'disable',
- 'dhcp-relay-type': 'regular',
- 'dhcp-renew-time': '37',
- 'disc-retry-timeout': '38',
- 'disconnect-threshold': '39',
- 'distance': '40',
- 'dns-server-override': 'enable',
- 'drop-fragment': 'enable',
- 'drop-overlapped-fragment': 'enable',
- 'egress-shaping-profile': 'test_value_44',
- 'endpoint-compliance': 'enable',
- 'estimated-downstream-bandwidth': '46',
- 'estimated-upstream-bandwidth': '47',
- 'explicit-ftp-proxy': 'enable',
- 'explicit-web-proxy': 'enable',
- 'external': 'enable',
- 'fail-action-on-extender': 'soft-restart',
- 'fail-alert-method': 'link-failed-signal',
- 'fail-detect': 'enable',
- 'fail-detect-option': 'detectserver',
- 'fortiheartbeat': 'enable',
- 'fortilink': 'enable',
- 'fortilink-backup-link': '57',
- 'fortilink-split-interface': 'enable',
- 'fortilink-stacking': 'enable',
- 'forward-domain': '60',
- 'gwdetect': 'enable',
- 'ha-priority': '62',
- 'icmp-accept-redirect': 'enable',
- 'icmp-send-redirect': 'enable',
- 'ident-accept': 'enable',
- 'idle-timeout': '66',
- 'inbandwidth': '67',
- 'ingress-spillover-threshold': '68',
- 'interface': 'test_value_69',
- 'internal': '70',
- 'ip': 'test_value_71',
- 'ipmac': 'enable',
- 'ips-sniffer-mode': 'enable',
- 'ipunnumbered': 'test_value_74',
- 'l2forward': 'enable',
- 'lacp-ha-slave': 'enable',
- 'lacp-mode': 'static',
- 'lacp-speed': 'slow',
- 'lcp-echo-interval': '79',
- 'lcp-max-echo-fails': '80',
- 'link-up-delay': '81',
- 'lldp-transmission': 'enable',
- 'macaddr': 'test_value_83',
- 'management-ip': 'test_value_84',
- 'min-links': '85',
- 'min-links-down': 'operational',
- 'mode': 'static',
- 'mtu': '88',
- 'mtu-override': 'enable',
- 'name': 'default_name_90',
- 'ndiscforward': 'enable',
- 'netbios-forward': 'disable',
- 'netflow-sampler': 'disable',
- 'outbandwidth': '94',
- 'padt-retry-timeout': '95',
- 'password': 'test_value_96',
- 'ping-serv-status': '97',
- 'polling-interval': '98',
- 'pppoe-unnumbered-negotiate': 'enable',
- 'pptp-auth-type': 'auto',
- 'pptp-client': 'enable',
- 'pptp-password': 'test_value_102',
- 'pptp-server-ip': 'test_value_103',
- 'pptp-timeout': '104',
- 'pptp-user': 'test_value_105',
- 'preserve-session-route': 'enable',
- 'priority': '107',
- 'priority-override': 'enable',
- 'proxy-captive-portal': 'enable',
- 'redundant-interface': 'test_value_110',
- 'remote-ip': 'test_value_111',
- 'replacemsg-override-group': 'test_value_112',
- 'role': 'lan',
- 'sample-direction': 'tx',
- 'sample-rate': '115',
- 'scan-botnet-connections': 'disable',
- 'secondary-IP': 'enable',
- 'security-exempt-list': 'test_value_118',
- 'security-external-logout': 'test_value_119',
- 'security-external-web': 'test_value_120',
- 'security-mac-auth-bypass': 'enable',
- 'security-mode': 'none',
- 'security-redirect-url': 'test_value_123',
- 'service-name': 'test_value_124',
- 'sflow-sampler': 'enable',
- 'snmp-index': '126',
- 'speed': 'auto',
- 'spillover-threshold': '128',
- 'src-check': 'enable',
- 'status': 'up',
- 'stpforward': 'enable',
- 'stpforward-mode': 'rpl-all-ext-id',
- 'subst': 'enable',
- 'substitute-dst-mac': 'test_value_134',
- 'switch': 'test_value_135',
- 'switch-controller-access-vlan': 'enable',
- 'switch-controller-arp-inspection': 'enable',
- 'switch-controller-dhcp-snooping': 'enable',
- 'switch-controller-dhcp-snooping-option82': 'enable',
- 'switch-controller-dhcp-snooping-verify-mac': 'enable',
- 'switch-controller-igmp-snooping': 'enable',
- 'switch-controller-learning-limit': '142',
- 'tcp-mss': '143',
- 'trust-ip-1': 'test_value_144',
- 'trust-ip-2': 'test_value_145',
- 'trust-ip-3': 'test_value_146',
- 'trust-ip6-1': 'test_value_147',
- 'trust-ip6-2': 'test_value_148',
- 'trust-ip6-3': 'test_value_149',
- 'type': 'physical',
- 'username': 'test_value_151',
- 'vdom': 'test_value_152',
- 'vindex': '153',
- 'vlanforward': 'enable',
- 'vlanid': '155',
- 'vrf': '156',
- 'vrrp-virtual-mac': 'enable',
- 'wccp': 'enable',
- 'weight': '159',
- 'wins-ip': 'test_value_160'
- }
-
- set_method_mock.assert_called_with('system', 'interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_interface_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_interface': {
- 'ac_name': 'test_value_3',
- 'aggregate': 'test_value_4',
- 'algorithm': 'L2',
- 'alias': 'test_value_6',
- 'ap_discover': 'enable',
- 'arpforward': 'enable',
- 'auth_type': 'auto',
- 'auto_auth_extension_device': 'enable',
- 'bfd': 'global',
- 'bfd_desired_min_tx': '12',
- 'bfd_detect_mult': '13',
- 'bfd_required_min_rx': '14',
- 'broadcast_forticlient_discovery': 'enable',
- 'broadcast_forward': 'enable',
- 'captive_portal': '17',
- 'cli_conn_status': '18',
- 'color': '19',
- 'dedicated_to': 'none',
- 'defaultgw': 'enable',
- 'description': 'test_value_22',
- 'detected_peer_mtu': '23',
- 'detectprotocol': 'ping',
- 'detectserver': 'test_value_25',
- 'device_access_list': 'test_value_26',
- 'device_identification': 'enable',
- 'device_identification_active_scan': 'enable',
- 'device_netscan': 'disable',
- 'device_user_identification': 'enable',
- 'devindex': '31',
- 'dhcp_client_identifier': 'myId_32',
- 'dhcp_relay_agent_option': 'enable',
- 'dhcp_relay_ip': 'test_value_34',
- 'dhcp_relay_service': 'disable',
- 'dhcp_relay_type': 'regular',
- 'dhcp_renew_time': '37',
- 'disc_retry_timeout': '38',
- 'disconnect_threshold': '39',
- 'distance': '40',
- 'dns_server_override': 'enable',
- 'drop_fragment': 'enable',
- 'drop_overlapped_fragment': 'enable',
- 'egress_shaping_profile': 'test_value_44',
- 'endpoint_compliance': 'enable',
- 'estimated_downstream_bandwidth': '46',
- 'estimated_upstream_bandwidth': '47',
- 'explicit_ftp_proxy': 'enable',
- 'explicit_web_proxy': 'enable',
- 'external': 'enable',
- 'fail_action_on_extender': 'soft-restart',
- 'fail_alert_method': 'link-failed-signal',
- 'fail_detect': 'enable',
- 'fail_detect_option': 'detectserver',
- 'fortiheartbeat': 'enable',
- 'fortilink': 'enable',
- 'fortilink_backup_link': '57',
- 'fortilink_split_interface': 'enable',
- 'fortilink_stacking': 'enable',
- 'forward_domain': '60',
- 'gwdetect': 'enable',
- 'ha_priority': '62',
- 'icmp_accept_redirect': 'enable',
- 'icmp_send_redirect': 'enable',
- 'ident_accept': 'enable',
- 'idle_timeout': '66',
- 'inbandwidth': '67',
- 'ingress_spillover_threshold': '68',
- 'interface': 'test_value_69',
- 'internal': '70',
- 'ip': 'test_value_71',
- 'ipmac': 'enable',
- 'ips_sniffer_mode': 'enable',
- 'ipunnumbered': 'test_value_74',
- 'l2forward': 'enable',
- 'lacp_ha_slave': 'enable',
- 'lacp_mode': 'static',
- 'lacp_speed': 'slow',
- 'lcp_echo_interval': '79',
- 'lcp_max_echo_fails': '80',
- 'link_up_delay': '81',
- 'lldp_transmission': 'enable',
- 'macaddr': 'test_value_83',
- 'management_ip': 'test_value_84',
- 'min_links': '85',
- 'min_links_down': 'operational',
- 'mode': 'static',
- 'mtu': '88',
- 'mtu_override': 'enable',
- 'name': 'default_name_90',
- 'ndiscforward': 'enable',
- 'netbios_forward': 'disable',
- 'netflow_sampler': 'disable',
- 'outbandwidth': '94',
- 'padt_retry_timeout': '95',
- 'password': 'test_value_96',
- 'ping_serv_status': '97',
- 'polling_interval': '98',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'pptp_auth_type': 'auto',
- 'pptp_client': 'enable',
- 'pptp_password': 'test_value_102',
- 'pptp_server_ip': 'test_value_103',
- 'pptp_timeout': '104',
- 'pptp_user': 'test_value_105',
- 'preserve_session_route': 'enable',
- 'priority': '107',
- 'priority_override': 'enable',
- 'proxy_captive_portal': 'enable',
- 'redundant_interface': 'test_value_110',
- 'remote_ip': 'test_value_111',
- 'replacemsg_override_group': 'test_value_112',
- 'role': 'lan',
- 'sample_direction': 'tx',
- 'sample_rate': '115',
- 'scan_botnet_connections': 'disable',
- 'secondary_IP': 'enable',
- 'security_exempt_list': 'test_value_118',
- 'security_external_logout': 'test_value_119',
- 'security_external_web': 'test_value_120',
- 'security_mac_auth_bypass': 'enable',
- 'security_mode': 'none',
- 'security_redirect_url': 'test_value_123',
- 'service_name': 'test_value_124',
- 'sflow_sampler': 'enable',
- 'snmp_index': '126',
- 'speed': 'auto',
- 'spillover_threshold': '128',
- 'src_check': 'enable',
- 'status': 'up',
- 'stpforward': 'enable',
- 'stpforward_mode': 'rpl-all-ext-id',
- 'subst': 'enable',
- 'substitute_dst_mac': 'test_value_134',
- 'switch': 'test_value_135',
- 'switch_controller_access_vlan': 'enable',
- 'switch_controller_arp_inspection': 'enable',
- 'switch_controller_dhcp_snooping': 'enable',
- 'switch_controller_dhcp_snooping_option82': 'enable',
- 'switch_controller_dhcp_snooping_verify_mac': 'enable',
- 'switch_controller_igmp_snooping': 'enable',
- 'switch_controller_learning_limit': '142',
- 'tcp_mss': '143',
- 'trust_ip_1': 'test_value_144',
- 'trust_ip_2': 'test_value_145',
- 'trust_ip_3': 'test_value_146',
- 'trust_ip6_1': 'test_value_147',
- 'trust_ip6_2': 'test_value_148',
- 'trust_ip6_3': 'test_value_149',
- 'type': 'physical',
- 'username': 'test_value_151',
- 'vdom': 'test_value_152',
- 'vindex': '153',
- 'vlanforward': 'enable',
- 'vlanid': '155',
- 'vrf': '156',
- 'vrrp_virtual_mac': 'enable',
- 'wccp': 'enable',
- 'weight': '159',
- 'wins_ip': 'test_value_160'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ac-name': 'test_value_3',
- 'aggregate': 'test_value_4',
- 'algorithm': 'L2',
- 'alias': 'test_value_6',
- 'ap-discover': 'enable',
- 'arpforward': 'enable',
- 'auth-type': 'auto',
- 'auto-auth-extension-device': 'enable',
- 'bfd': 'global',
- 'bfd-desired-min-tx': '12',
- 'bfd-detect-mult': '13',
- 'bfd-required-min-rx': '14',
- 'broadcast-forticlient-discovery': 'enable',
- 'broadcast-forward': 'enable',
- 'captive-portal': '17',
- 'cli-conn-status': '18',
- 'color': '19',
- 'dedicated-to': 'none',
- 'defaultgw': 'enable',
- 'description': 'test_value_22',
- 'detected-peer-mtu': '23',
- 'detectprotocol': 'ping',
- 'detectserver': 'test_value_25',
- 'device-access-list': 'test_value_26',
- 'device-identification': 'enable',
- 'device-identification-active-scan': 'enable',
- 'device-netscan': 'disable',
- 'device-user-identification': 'enable',
- 'devindex': '31',
- 'dhcp-client-identifier': 'myId_32',
- 'dhcp-relay-agent-option': 'enable',
- 'dhcp-relay-ip': 'test_value_34',
- 'dhcp-relay-service': 'disable',
- 'dhcp-relay-type': 'regular',
- 'dhcp-renew-time': '37',
- 'disc-retry-timeout': '38',
- 'disconnect-threshold': '39',
- 'distance': '40',
- 'dns-server-override': 'enable',
- 'drop-fragment': 'enable',
- 'drop-overlapped-fragment': 'enable',
- 'egress-shaping-profile': 'test_value_44',
- 'endpoint-compliance': 'enable',
- 'estimated-downstream-bandwidth': '46',
- 'estimated-upstream-bandwidth': '47',
- 'explicit-ftp-proxy': 'enable',
- 'explicit-web-proxy': 'enable',
- 'external': 'enable',
- 'fail-action-on-extender': 'soft-restart',
- 'fail-alert-method': 'link-failed-signal',
- 'fail-detect': 'enable',
- 'fail-detect-option': 'detectserver',
- 'fortiheartbeat': 'enable',
- 'fortilink': 'enable',
- 'fortilink-backup-link': '57',
- 'fortilink-split-interface': 'enable',
- 'fortilink-stacking': 'enable',
- 'forward-domain': '60',
- 'gwdetect': 'enable',
- 'ha-priority': '62',
- 'icmp-accept-redirect': 'enable',
- 'icmp-send-redirect': 'enable',
- 'ident-accept': 'enable',
- 'idle-timeout': '66',
- 'inbandwidth': '67',
- 'ingress-spillover-threshold': '68',
- 'interface': 'test_value_69',
- 'internal': '70',
- 'ip': 'test_value_71',
- 'ipmac': 'enable',
- 'ips-sniffer-mode': 'enable',
- 'ipunnumbered': 'test_value_74',
- 'l2forward': 'enable',
- 'lacp-ha-slave': 'enable',
- 'lacp-mode': 'static',
- 'lacp-speed': 'slow',
- 'lcp-echo-interval': '79',
- 'lcp-max-echo-fails': '80',
- 'link-up-delay': '81',
- 'lldp-transmission': 'enable',
- 'macaddr': 'test_value_83',
- 'management-ip': 'test_value_84',
- 'min-links': '85',
- 'min-links-down': 'operational',
- 'mode': 'static',
- 'mtu': '88',
- 'mtu-override': 'enable',
- 'name': 'default_name_90',
- 'ndiscforward': 'enable',
- 'netbios-forward': 'disable',
- 'netflow-sampler': 'disable',
- 'outbandwidth': '94',
- 'padt-retry-timeout': '95',
- 'password': 'test_value_96',
- 'ping-serv-status': '97',
- 'polling-interval': '98',
- 'pppoe-unnumbered-negotiate': 'enable',
- 'pptp-auth-type': 'auto',
- 'pptp-client': 'enable',
- 'pptp-password': 'test_value_102',
- 'pptp-server-ip': 'test_value_103',
- 'pptp-timeout': '104',
- 'pptp-user': 'test_value_105',
- 'preserve-session-route': 'enable',
- 'priority': '107',
- 'priority-override': 'enable',
- 'proxy-captive-portal': 'enable',
- 'redundant-interface': 'test_value_110',
- 'remote-ip': 'test_value_111',
- 'replacemsg-override-group': 'test_value_112',
- 'role': 'lan',
- 'sample-direction': 'tx',
- 'sample-rate': '115',
- 'scan-botnet-connections': 'disable',
- 'secondary-IP': 'enable',
- 'security-exempt-list': 'test_value_118',
- 'security-external-logout': 'test_value_119',
- 'security-external-web': 'test_value_120',
- 'security-mac-auth-bypass': 'enable',
- 'security-mode': 'none',
- 'security-redirect-url': 'test_value_123',
- 'service-name': 'test_value_124',
- 'sflow-sampler': 'enable',
- 'snmp-index': '126',
- 'speed': 'auto',
- 'spillover-threshold': '128',
- 'src-check': 'enable',
- 'status': 'up',
- 'stpforward': 'enable',
- 'stpforward-mode': 'rpl-all-ext-id',
- 'subst': 'enable',
- 'substitute-dst-mac': 'test_value_134',
- 'switch': 'test_value_135',
- 'switch-controller-access-vlan': 'enable',
- 'switch-controller-arp-inspection': 'enable',
- 'switch-controller-dhcp-snooping': 'enable',
- 'switch-controller-dhcp-snooping-option82': 'enable',
- 'switch-controller-dhcp-snooping-verify-mac': 'enable',
- 'switch-controller-igmp-snooping': 'enable',
- 'switch-controller-learning-limit': '142',
- 'tcp-mss': '143',
- 'trust-ip-1': 'test_value_144',
- 'trust-ip-2': 'test_value_145',
- 'trust-ip-3': 'test_value_146',
- 'trust-ip6-1': 'test_value_147',
- 'trust-ip6-2': 'test_value_148',
- 'trust-ip6-3': 'test_value_149',
- 'type': 'physical',
- 'username': 'test_value_151',
- 'vdom': 'test_value_152',
- 'vindex': '153',
- 'vlanforward': 'enable',
- 'vlanid': '155',
- 'vrf': '156',
- 'vrrp-virtual-mac': 'enable',
- 'wccp': 'enable',
- 'weight': '159',
- 'wins-ip': 'test_value_160'
- }
-
- set_method_mock.assert_called_with('system', 'interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_interface_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_interface': {
- 'ac_name': 'test_value_3',
- 'aggregate': 'test_value_4',
- 'algorithm': 'L2',
- 'alias': 'test_value_6',
- 'ap_discover': 'enable',
- 'arpforward': 'enable',
- 'auth_type': 'auto',
- 'auto_auth_extension_device': 'enable',
- 'bfd': 'global',
- 'bfd_desired_min_tx': '12',
- 'bfd_detect_mult': '13',
- 'bfd_required_min_rx': '14',
- 'broadcast_forticlient_discovery': 'enable',
- 'broadcast_forward': 'enable',
- 'captive_portal': '17',
- 'cli_conn_status': '18',
- 'color': '19',
- 'dedicated_to': 'none',
- 'defaultgw': 'enable',
- 'description': 'test_value_22',
- 'detected_peer_mtu': '23',
- 'detectprotocol': 'ping',
- 'detectserver': 'test_value_25',
- 'device_access_list': 'test_value_26',
- 'device_identification': 'enable',
- 'device_identification_active_scan': 'enable',
- 'device_netscan': 'disable',
- 'device_user_identification': 'enable',
- 'devindex': '31',
- 'dhcp_client_identifier': 'myId_32',
- 'dhcp_relay_agent_option': 'enable',
- 'dhcp_relay_ip': 'test_value_34',
- 'dhcp_relay_service': 'disable',
- 'dhcp_relay_type': 'regular',
- 'dhcp_renew_time': '37',
- 'disc_retry_timeout': '38',
- 'disconnect_threshold': '39',
- 'distance': '40',
- 'dns_server_override': 'enable',
- 'drop_fragment': 'enable',
- 'drop_overlapped_fragment': 'enable',
- 'egress_shaping_profile': 'test_value_44',
- 'endpoint_compliance': 'enable',
- 'estimated_downstream_bandwidth': '46',
- 'estimated_upstream_bandwidth': '47',
- 'explicit_ftp_proxy': 'enable',
- 'explicit_web_proxy': 'enable',
- 'external': 'enable',
- 'fail_action_on_extender': 'soft-restart',
- 'fail_alert_method': 'link-failed-signal',
- 'fail_detect': 'enable',
- 'fail_detect_option': 'detectserver',
- 'fortiheartbeat': 'enable',
- 'fortilink': 'enable',
- 'fortilink_backup_link': '57',
- 'fortilink_split_interface': 'enable',
- 'fortilink_stacking': 'enable',
- 'forward_domain': '60',
- 'gwdetect': 'enable',
- 'ha_priority': '62',
- 'icmp_accept_redirect': 'enable',
- 'icmp_send_redirect': 'enable',
- 'ident_accept': 'enable',
- 'idle_timeout': '66',
- 'inbandwidth': '67',
- 'ingress_spillover_threshold': '68',
- 'interface': 'test_value_69',
- 'internal': '70',
- 'ip': 'test_value_71',
- 'ipmac': 'enable',
- 'ips_sniffer_mode': 'enable',
- 'ipunnumbered': 'test_value_74',
- 'l2forward': 'enable',
- 'lacp_ha_slave': 'enable',
- 'lacp_mode': 'static',
- 'lacp_speed': 'slow',
- 'lcp_echo_interval': '79',
- 'lcp_max_echo_fails': '80',
- 'link_up_delay': '81',
- 'lldp_transmission': 'enable',
- 'macaddr': 'test_value_83',
- 'management_ip': 'test_value_84',
- 'min_links': '85',
- 'min_links_down': 'operational',
- 'mode': 'static',
- 'mtu': '88',
- 'mtu_override': 'enable',
- 'name': 'default_name_90',
- 'ndiscforward': 'enable',
- 'netbios_forward': 'disable',
- 'netflow_sampler': 'disable',
- 'outbandwidth': '94',
- 'padt_retry_timeout': '95',
- 'password': 'test_value_96',
- 'ping_serv_status': '97',
- 'polling_interval': '98',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'pptp_auth_type': 'auto',
- 'pptp_client': 'enable',
- 'pptp_password': 'test_value_102',
- 'pptp_server_ip': 'test_value_103',
- 'pptp_timeout': '104',
- 'pptp_user': 'test_value_105',
- 'preserve_session_route': 'enable',
- 'priority': '107',
- 'priority_override': 'enable',
- 'proxy_captive_portal': 'enable',
- 'redundant_interface': 'test_value_110',
- 'remote_ip': 'test_value_111',
- 'replacemsg_override_group': 'test_value_112',
- 'role': 'lan',
- 'sample_direction': 'tx',
- 'sample_rate': '115',
- 'scan_botnet_connections': 'disable',
- 'secondary_IP': 'enable',
- 'security_exempt_list': 'test_value_118',
- 'security_external_logout': 'test_value_119',
- 'security_external_web': 'test_value_120',
- 'security_mac_auth_bypass': 'enable',
- 'security_mode': 'none',
- 'security_redirect_url': 'test_value_123',
- 'service_name': 'test_value_124',
- 'sflow_sampler': 'enable',
- 'snmp_index': '126',
- 'speed': 'auto',
- 'spillover_threshold': '128',
- 'src_check': 'enable',
- 'status': 'up',
- 'stpforward': 'enable',
- 'stpforward_mode': 'rpl-all-ext-id',
- 'subst': 'enable',
- 'substitute_dst_mac': 'test_value_134',
- 'switch': 'test_value_135',
- 'switch_controller_access_vlan': 'enable',
- 'switch_controller_arp_inspection': 'enable',
- 'switch_controller_dhcp_snooping': 'enable',
- 'switch_controller_dhcp_snooping_option82': 'enable',
- 'switch_controller_dhcp_snooping_verify_mac': 'enable',
- 'switch_controller_igmp_snooping': 'enable',
- 'switch_controller_learning_limit': '142',
- 'tcp_mss': '143',
- 'trust_ip_1': 'test_value_144',
- 'trust_ip_2': 'test_value_145',
- 'trust_ip_3': 'test_value_146',
- 'trust_ip6_1': 'test_value_147',
- 'trust_ip6_2': 'test_value_148',
- 'trust_ip6_3': 'test_value_149',
- 'type': 'physical',
- 'username': 'test_value_151',
- 'vdom': 'test_value_152',
- 'vindex': '153',
- 'vlanforward': 'enable',
- 'vlanid': '155',
- 'vrf': '156',
- 'vrrp_virtual_mac': 'enable',
- 'wccp': 'enable',
- 'weight': '159',
- 'wins_ip': 'test_value_160'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_interface.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_interface_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_interface': {
- 'ac_name': 'test_value_3',
- 'aggregate': 'test_value_4',
- 'algorithm': 'L2',
- 'alias': 'test_value_6',
- 'ap_discover': 'enable',
- 'arpforward': 'enable',
- 'auth_type': 'auto',
- 'auto_auth_extension_device': 'enable',
- 'bfd': 'global',
- 'bfd_desired_min_tx': '12',
- 'bfd_detect_mult': '13',
- 'bfd_required_min_rx': '14',
- 'broadcast_forticlient_discovery': 'enable',
- 'broadcast_forward': 'enable',
- 'captive_portal': '17',
- 'cli_conn_status': '18',
- 'color': '19',
- 'dedicated_to': 'none',
- 'defaultgw': 'enable',
- 'description': 'test_value_22',
- 'detected_peer_mtu': '23',
- 'detectprotocol': 'ping',
- 'detectserver': 'test_value_25',
- 'device_access_list': 'test_value_26',
- 'device_identification': 'enable',
- 'device_identification_active_scan': 'enable',
- 'device_netscan': 'disable',
- 'device_user_identification': 'enable',
- 'devindex': '31',
- 'dhcp_client_identifier': 'myId_32',
- 'dhcp_relay_agent_option': 'enable',
- 'dhcp_relay_ip': 'test_value_34',
- 'dhcp_relay_service': 'disable',
- 'dhcp_relay_type': 'regular',
- 'dhcp_renew_time': '37',
- 'disc_retry_timeout': '38',
- 'disconnect_threshold': '39',
- 'distance': '40',
- 'dns_server_override': 'enable',
- 'drop_fragment': 'enable',
- 'drop_overlapped_fragment': 'enable',
- 'egress_shaping_profile': 'test_value_44',
- 'endpoint_compliance': 'enable',
- 'estimated_downstream_bandwidth': '46',
- 'estimated_upstream_bandwidth': '47',
- 'explicit_ftp_proxy': 'enable',
- 'explicit_web_proxy': 'enable',
- 'external': 'enable',
- 'fail_action_on_extender': 'soft-restart',
- 'fail_alert_method': 'link-failed-signal',
- 'fail_detect': 'enable',
- 'fail_detect_option': 'detectserver',
- 'fortiheartbeat': 'enable',
- 'fortilink': 'enable',
- 'fortilink_backup_link': '57',
- 'fortilink_split_interface': 'enable',
- 'fortilink_stacking': 'enable',
- 'forward_domain': '60',
- 'gwdetect': 'enable',
- 'ha_priority': '62',
- 'icmp_accept_redirect': 'enable',
- 'icmp_send_redirect': 'enable',
- 'ident_accept': 'enable',
- 'idle_timeout': '66',
- 'inbandwidth': '67',
- 'ingress_spillover_threshold': '68',
- 'interface': 'test_value_69',
- 'internal': '70',
- 'ip': 'test_value_71',
- 'ipmac': 'enable',
- 'ips_sniffer_mode': 'enable',
- 'ipunnumbered': 'test_value_74',
- 'l2forward': 'enable',
- 'lacp_ha_slave': 'enable',
- 'lacp_mode': 'static',
- 'lacp_speed': 'slow',
- 'lcp_echo_interval': '79',
- 'lcp_max_echo_fails': '80',
- 'link_up_delay': '81',
- 'lldp_transmission': 'enable',
- 'macaddr': 'test_value_83',
- 'management_ip': 'test_value_84',
- 'min_links': '85',
- 'min_links_down': 'operational',
- 'mode': 'static',
- 'mtu': '88',
- 'mtu_override': 'enable',
- 'name': 'default_name_90',
- 'ndiscforward': 'enable',
- 'netbios_forward': 'disable',
- 'netflow_sampler': 'disable',
- 'outbandwidth': '94',
- 'padt_retry_timeout': '95',
- 'password': 'test_value_96',
- 'ping_serv_status': '97',
- 'polling_interval': '98',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'pptp_auth_type': 'auto',
- 'pptp_client': 'enable',
- 'pptp_password': 'test_value_102',
- 'pptp_server_ip': 'test_value_103',
- 'pptp_timeout': '104',
- 'pptp_user': 'test_value_105',
- 'preserve_session_route': 'enable',
- 'priority': '107',
- 'priority_override': 'enable',
- 'proxy_captive_portal': 'enable',
- 'redundant_interface': 'test_value_110',
- 'remote_ip': 'test_value_111',
- 'replacemsg_override_group': 'test_value_112',
- 'role': 'lan',
- 'sample_direction': 'tx',
- 'sample_rate': '115',
- 'scan_botnet_connections': 'disable',
- 'secondary_IP': 'enable',
- 'security_exempt_list': 'test_value_118',
- 'security_external_logout': 'test_value_119',
- 'security_external_web': 'test_value_120',
- 'security_mac_auth_bypass': 'enable',
- 'security_mode': 'none',
- 'security_redirect_url': 'test_value_123',
- 'service_name': 'test_value_124',
- 'sflow_sampler': 'enable',
- 'snmp_index': '126',
- 'speed': 'auto',
- 'spillover_threshold': '128',
- 'src_check': 'enable',
- 'status': 'up',
- 'stpforward': 'enable',
- 'stpforward_mode': 'rpl-all-ext-id',
- 'subst': 'enable',
- 'substitute_dst_mac': 'test_value_134',
- 'switch': 'test_value_135',
- 'switch_controller_access_vlan': 'enable',
- 'switch_controller_arp_inspection': 'enable',
- 'switch_controller_dhcp_snooping': 'enable',
- 'switch_controller_dhcp_snooping_option82': 'enable',
- 'switch_controller_dhcp_snooping_verify_mac': 'enable',
- 'switch_controller_igmp_snooping': 'enable',
- 'switch_controller_learning_limit': '142',
- 'tcp_mss': '143',
- 'trust_ip_1': 'test_value_144',
- 'trust_ip_2': 'test_value_145',
- 'trust_ip_3': 'test_value_146',
- 'trust_ip6_1': 'test_value_147',
- 'trust_ip6_2': 'test_value_148',
- 'trust_ip6_3': 'test_value_149',
- 'type': 'physical',
- 'username': 'test_value_151',
- 'vdom': 'test_value_152',
- 'vindex': '153',
- 'vlanforward': 'enable',
- 'vlanid': '155',
- 'vrf': '156',
- 'vrrp_virtual_mac': 'enable',
- 'wccp': 'enable',
- 'weight': '159',
- 'wins_ip': 'test_value_160'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_interface.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_interface_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_interface': {
- 'ac_name': 'test_value_3',
- 'aggregate': 'test_value_4',
- 'algorithm': 'L2',
- 'alias': 'test_value_6',
- 'ap_discover': 'enable',
- 'arpforward': 'enable',
- 'auth_type': 'auto',
- 'auto_auth_extension_device': 'enable',
- 'bfd': 'global',
- 'bfd_desired_min_tx': '12',
- 'bfd_detect_mult': '13',
- 'bfd_required_min_rx': '14',
- 'broadcast_forticlient_discovery': 'enable',
- 'broadcast_forward': 'enable',
- 'captive_portal': '17',
- 'cli_conn_status': '18',
- 'color': '19',
- 'dedicated_to': 'none',
- 'defaultgw': 'enable',
- 'description': 'test_value_22',
- 'detected_peer_mtu': '23',
- 'detectprotocol': 'ping',
- 'detectserver': 'test_value_25',
- 'device_access_list': 'test_value_26',
- 'device_identification': 'enable',
- 'device_identification_active_scan': 'enable',
- 'device_netscan': 'disable',
- 'device_user_identification': 'enable',
- 'devindex': '31',
- 'dhcp_client_identifier': 'myId_32',
- 'dhcp_relay_agent_option': 'enable',
- 'dhcp_relay_ip': 'test_value_34',
- 'dhcp_relay_service': 'disable',
- 'dhcp_relay_type': 'regular',
- 'dhcp_renew_time': '37',
- 'disc_retry_timeout': '38',
- 'disconnect_threshold': '39',
- 'distance': '40',
- 'dns_server_override': 'enable',
- 'drop_fragment': 'enable',
- 'drop_overlapped_fragment': 'enable',
- 'egress_shaping_profile': 'test_value_44',
- 'endpoint_compliance': 'enable',
- 'estimated_downstream_bandwidth': '46',
- 'estimated_upstream_bandwidth': '47',
- 'explicit_ftp_proxy': 'enable',
- 'explicit_web_proxy': 'enable',
- 'external': 'enable',
- 'fail_action_on_extender': 'soft-restart',
- 'fail_alert_method': 'link-failed-signal',
- 'fail_detect': 'enable',
- 'fail_detect_option': 'detectserver',
- 'fortiheartbeat': 'enable',
- 'fortilink': 'enable',
- 'fortilink_backup_link': '57',
- 'fortilink_split_interface': 'enable',
- 'fortilink_stacking': 'enable',
- 'forward_domain': '60',
- 'gwdetect': 'enable',
- 'ha_priority': '62',
- 'icmp_accept_redirect': 'enable',
- 'icmp_send_redirect': 'enable',
- 'ident_accept': 'enable',
- 'idle_timeout': '66',
- 'inbandwidth': '67',
- 'ingress_spillover_threshold': '68',
- 'interface': 'test_value_69',
- 'internal': '70',
- 'ip': 'test_value_71',
- 'ipmac': 'enable',
- 'ips_sniffer_mode': 'enable',
- 'ipunnumbered': 'test_value_74',
- 'l2forward': 'enable',
- 'lacp_ha_slave': 'enable',
- 'lacp_mode': 'static',
- 'lacp_speed': 'slow',
- 'lcp_echo_interval': '79',
- 'lcp_max_echo_fails': '80',
- 'link_up_delay': '81',
- 'lldp_transmission': 'enable',
- 'macaddr': 'test_value_83',
- 'management_ip': 'test_value_84',
- 'min_links': '85',
- 'min_links_down': 'operational',
- 'mode': 'static',
- 'mtu': '88',
- 'mtu_override': 'enable',
- 'name': 'default_name_90',
- 'ndiscforward': 'enable',
- 'netbios_forward': 'disable',
- 'netflow_sampler': 'disable',
- 'outbandwidth': '94',
- 'padt_retry_timeout': '95',
- 'password': 'test_value_96',
- 'ping_serv_status': '97',
- 'polling_interval': '98',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'pptp_auth_type': 'auto',
- 'pptp_client': 'enable',
- 'pptp_password': 'test_value_102',
- 'pptp_server_ip': 'test_value_103',
- 'pptp_timeout': '104',
- 'pptp_user': 'test_value_105',
- 'preserve_session_route': 'enable',
- 'priority': '107',
- 'priority_override': 'enable',
- 'proxy_captive_portal': 'enable',
- 'redundant_interface': 'test_value_110',
- 'remote_ip': 'test_value_111',
- 'replacemsg_override_group': 'test_value_112',
- 'role': 'lan',
- 'sample_direction': 'tx',
- 'sample_rate': '115',
- 'scan_botnet_connections': 'disable',
- 'secondary_IP': 'enable',
- 'security_exempt_list': 'test_value_118',
- 'security_external_logout': 'test_value_119',
- 'security_external_web': 'test_value_120',
- 'security_mac_auth_bypass': 'enable',
- 'security_mode': 'none',
- 'security_redirect_url': 'test_value_123',
- 'service_name': 'test_value_124',
- 'sflow_sampler': 'enable',
- 'snmp_index': '126',
- 'speed': 'auto',
- 'spillover_threshold': '128',
- 'src_check': 'enable',
- 'status': 'up',
- 'stpforward': 'enable',
- 'stpforward_mode': 'rpl-all-ext-id',
- 'subst': 'enable',
- 'substitute_dst_mac': 'test_value_134',
- 'switch': 'test_value_135',
- 'switch_controller_access_vlan': 'enable',
- 'switch_controller_arp_inspection': 'enable',
- 'switch_controller_dhcp_snooping': 'enable',
- 'switch_controller_dhcp_snooping_option82': 'enable',
- 'switch_controller_dhcp_snooping_verify_mac': 'enable',
- 'switch_controller_igmp_snooping': 'enable',
- 'switch_controller_learning_limit': '142',
- 'tcp_mss': '143',
- 'trust_ip_1': 'test_value_144',
- 'trust_ip_2': 'test_value_145',
- 'trust_ip_3': 'test_value_146',
- 'trust_ip6_1': 'test_value_147',
- 'trust_ip6_2': 'test_value_148',
- 'trust_ip6_3': 'test_value_149',
- 'type': 'physical',
- 'username': 'test_value_151',
- 'vdom': 'test_value_152',
- 'vindex': '153',
- 'vlanforward': 'enable',
- 'vlanid': '155',
- 'vrf': '156',
- 'vrrp_virtual_mac': 'enable',
- 'wccp': 'enable',
- 'weight': '159',
- 'wins_ip': 'test_value_160'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ac-name': 'test_value_3',
- 'aggregate': 'test_value_4',
- 'algorithm': 'L2',
- 'alias': 'test_value_6',
- 'ap-discover': 'enable',
- 'arpforward': 'enable',
- 'auth-type': 'auto',
- 'auto-auth-extension-device': 'enable',
- 'bfd': 'global',
- 'bfd-desired-min-tx': '12',
- 'bfd-detect-mult': '13',
- 'bfd-required-min-rx': '14',
- 'broadcast-forticlient-discovery': 'enable',
- 'broadcast-forward': 'enable',
- 'captive-portal': '17',
- 'cli-conn-status': '18',
- 'color': '19',
- 'dedicated-to': 'none',
- 'defaultgw': 'enable',
- 'description': 'test_value_22',
- 'detected-peer-mtu': '23',
- 'detectprotocol': 'ping',
- 'detectserver': 'test_value_25',
- 'device-access-list': 'test_value_26',
- 'device-identification': 'enable',
- 'device-identification-active-scan': 'enable',
- 'device-netscan': 'disable',
- 'device-user-identification': 'enable',
- 'devindex': '31',
- 'dhcp-client-identifier': 'myId_32',
- 'dhcp-relay-agent-option': 'enable',
- 'dhcp-relay-ip': 'test_value_34',
- 'dhcp-relay-service': 'disable',
- 'dhcp-relay-type': 'regular',
- 'dhcp-renew-time': '37',
- 'disc-retry-timeout': '38',
- 'disconnect-threshold': '39',
- 'distance': '40',
- 'dns-server-override': 'enable',
- 'drop-fragment': 'enable',
- 'drop-overlapped-fragment': 'enable',
- 'egress-shaping-profile': 'test_value_44',
- 'endpoint-compliance': 'enable',
- 'estimated-downstream-bandwidth': '46',
- 'estimated-upstream-bandwidth': '47',
- 'explicit-ftp-proxy': 'enable',
- 'explicit-web-proxy': 'enable',
- 'external': 'enable',
- 'fail-action-on-extender': 'soft-restart',
- 'fail-alert-method': 'link-failed-signal',
- 'fail-detect': 'enable',
- 'fail-detect-option': 'detectserver',
- 'fortiheartbeat': 'enable',
- 'fortilink': 'enable',
- 'fortilink-backup-link': '57',
- 'fortilink-split-interface': 'enable',
- 'fortilink-stacking': 'enable',
- 'forward-domain': '60',
- 'gwdetect': 'enable',
- 'ha-priority': '62',
- 'icmp-accept-redirect': 'enable',
- 'icmp-send-redirect': 'enable',
- 'ident-accept': 'enable',
- 'idle-timeout': '66',
- 'inbandwidth': '67',
- 'ingress-spillover-threshold': '68',
- 'interface': 'test_value_69',
- 'internal': '70',
- 'ip': 'test_value_71',
- 'ipmac': 'enable',
- 'ips-sniffer-mode': 'enable',
- 'ipunnumbered': 'test_value_74',
- 'l2forward': 'enable',
- 'lacp-ha-slave': 'enable',
- 'lacp-mode': 'static',
- 'lacp-speed': 'slow',
- 'lcp-echo-interval': '79',
- 'lcp-max-echo-fails': '80',
- 'link-up-delay': '81',
- 'lldp-transmission': 'enable',
- 'macaddr': 'test_value_83',
- 'management-ip': 'test_value_84',
- 'min-links': '85',
- 'min-links-down': 'operational',
- 'mode': 'static',
- 'mtu': '88',
- 'mtu-override': 'enable',
- 'name': 'default_name_90',
- 'ndiscforward': 'enable',
- 'netbios-forward': 'disable',
- 'netflow-sampler': 'disable',
- 'outbandwidth': '94',
- 'padt-retry-timeout': '95',
- 'password': 'test_value_96',
- 'ping-serv-status': '97',
- 'polling-interval': '98',
- 'pppoe-unnumbered-negotiate': 'enable',
- 'pptp-auth-type': 'auto',
- 'pptp-client': 'enable',
- 'pptp-password': 'test_value_102',
- 'pptp-server-ip': 'test_value_103',
- 'pptp-timeout': '104',
- 'pptp-user': 'test_value_105',
- 'preserve-session-route': 'enable',
- 'priority': '107',
- 'priority-override': 'enable',
- 'proxy-captive-portal': 'enable',
- 'redundant-interface': 'test_value_110',
- 'remote-ip': 'test_value_111',
- 'replacemsg-override-group': 'test_value_112',
- 'role': 'lan',
- 'sample-direction': 'tx',
- 'sample-rate': '115',
- 'scan-botnet-connections': 'disable',
- 'secondary-IP': 'enable',
- 'security-exempt-list': 'test_value_118',
- 'security-external-logout': 'test_value_119',
- 'security-external-web': 'test_value_120',
- 'security-mac-auth-bypass': 'enable',
- 'security-mode': 'none',
- 'security-redirect-url': 'test_value_123',
- 'service-name': 'test_value_124',
- 'sflow-sampler': 'enable',
- 'snmp-index': '126',
- 'speed': 'auto',
- 'spillover-threshold': '128',
- 'src-check': 'enable',
- 'status': 'up',
- 'stpforward': 'enable',
- 'stpforward-mode': 'rpl-all-ext-id',
- 'subst': 'enable',
- 'substitute-dst-mac': 'test_value_134',
- 'switch': 'test_value_135',
- 'switch-controller-access-vlan': 'enable',
- 'switch-controller-arp-inspection': 'enable',
- 'switch-controller-dhcp-snooping': 'enable',
- 'switch-controller-dhcp-snooping-option82': 'enable',
- 'switch-controller-dhcp-snooping-verify-mac': 'enable',
- 'switch-controller-igmp-snooping': 'enable',
- 'switch-controller-learning-limit': '142',
- 'tcp-mss': '143',
- 'trust-ip-1': 'test_value_144',
- 'trust-ip-2': 'test_value_145',
- 'trust-ip-3': 'test_value_146',
- 'trust-ip6-1': 'test_value_147',
- 'trust-ip6-2': 'test_value_148',
- 'trust-ip6-3': 'test_value_149',
- 'type': 'physical',
- 'username': 'test_value_151',
- 'vdom': 'test_value_152',
- 'vindex': '153',
- 'vlanforward': 'enable',
- 'vlanid': '155',
- 'vrf': '156',
- 'vrrp-virtual-mac': 'enable',
- 'wccp': 'enable',
- 'weight': '159',
- 'wins-ip': 'test_value_160'
- }
-
- set_method_mock.assert_called_with('system', 'interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_interface_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_interface': {
- 'random_attribute_not_valid': 'tag',
- 'ac_name': 'test_value_3',
- 'aggregate': 'test_value_4',
- 'algorithm': 'L2',
- 'alias': 'test_value_6',
- 'ap_discover': 'enable',
- 'arpforward': 'enable',
- 'auth_type': 'auto',
- 'auto_auth_extension_device': 'enable',
- 'bfd': 'global',
- 'bfd_desired_min_tx': '12',
- 'bfd_detect_mult': '13',
- 'bfd_required_min_rx': '14',
- 'broadcast_forticlient_discovery': 'enable',
- 'broadcast_forward': 'enable',
- 'captive_portal': '17',
- 'cli_conn_status': '18',
- 'color': '19',
- 'dedicated_to': 'none',
- 'defaultgw': 'enable',
- 'description': 'test_value_22',
- 'detected_peer_mtu': '23',
- 'detectprotocol': 'ping',
- 'detectserver': 'test_value_25',
- 'device_access_list': 'test_value_26',
- 'device_identification': 'enable',
- 'device_identification_active_scan': 'enable',
- 'device_netscan': 'disable',
- 'device_user_identification': 'enable',
- 'devindex': '31',
- 'dhcp_client_identifier': 'myId_32',
- 'dhcp_relay_agent_option': 'enable',
- 'dhcp_relay_ip': 'test_value_34',
- 'dhcp_relay_service': 'disable',
- 'dhcp_relay_type': 'regular',
- 'dhcp_renew_time': '37',
- 'disc_retry_timeout': '38',
- 'disconnect_threshold': '39',
- 'distance': '40',
- 'dns_server_override': 'enable',
- 'drop_fragment': 'enable',
- 'drop_overlapped_fragment': 'enable',
- 'egress_shaping_profile': 'test_value_44',
- 'endpoint_compliance': 'enable',
- 'estimated_downstream_bandwidth': '46',
- 'estimated_upstream_bandwidth': '47',
- 'explicit_ftp_proxy': 'enable',
- 'explicit_web_proxy': 'enable',
- 'external': 'enable',
- 'fail_action_on_extender': 'soft-restart',
- 'fail_alert_method': 'link-failed-signal',
- 'fail_detect': 'enable',
- 'fail_detect_option': 'detectserver',
- 'fortiheartbeat': 'enable',
- 'fortilink': 'enable',
- 'fortilink_backup_link': '57',
- 'fortilink_split_interface': 'enable',
- 'fortilink_stacking': 'enable',
- 'forward_domain': '60',
- 'gwdetect': 'enable',
- 'ha_priority': '62',
- 'icmp_accept_redirect': 'enable',
- 'icmp_send_redirect': 'enable',
- 'ident_accept': 'enable',
- 'idle_timeout': '66',
- 'inbandwidth': '67',
- 'ingress_spillover_threshold': '68',
- 'interface': 'test_value_69',
- 'internal': '70',
- 'ip': 'test_value_71',
- 'ipmac': 'enable',
- 'ips_sniffer_mode': 'enable',
- 'ipunnumbered': 'test_value_74',
- 'l2forward': 'enable',
- 'lacp_ha_slave': 'enable',
- 'lacp_mode': 'static',
- 'lacp_speed': 'slow',
- 'lcp_echo_interval': '79',
- 'lcp_max_echo_fails': '80',
- 'link_up_delay': '81',
- 'lldp_transmission': 'enable',
- 'macaddr': 'test_value_83',
- 'management_ip': 'test_value_84',
- 'min_links': '85',
- 'min_links_down': 'operational',
- 'mode': 'static',
- 'mtu': '88',
- 'mtu_override': 'enable',
- 'name': 'default_name_90',
- 'ndiscforward': 'enable',
- 'netbios_forward': 'disable',
- 'netflow_sampler': 'disable',
- 'outbandwidth': '94',
- 'padt_retry_timeout': '95',
- 'password': 'test_value_96',
- 'ping_serv_status': '97',
- 'polling_interval': '98',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'pptp_auth_type': 'auto',
- 'pptp_client': 'enable',
- 'pptp_password': 'test_value_102',
- 'pptp_server_ip': 'test_value_103',
- 'pptp_timeout': '104',
- 'pptp_user': 'test_value_105',
- 'preserve_session_route': 'enable',
- 'priority': '107',
- 'priority_override': 'enable',
- 'proxy_captive_portal': 'enable',
- 'redundant_interface': 'test_value_110',
- 'remote_ip': 'test_value_111',
- 'replacemsg_override_group': 'test_value_112',
- 'role': 'lan',
- 'sample_direction': 'tx',
- 'sample_rate': '115',
- 'scan_botnet_connections': 'disable',
- 'secondary_IP': 'enable',
- 'security_exempt_list': 'test_value_118',
- 'security_external_logout': 'test_value_119',
- 'security_external_web': 'test_value_120',
- 'security_mac_auth_bypass': 'enable',
- 'security_mode': 'none',
- 'security_redirect_url': 'test_value_123',
- 'service_name': 'test_value_124',
- 'sflow_sampler': 'enable',
- 'snmp_index': '126',
- 'speed': 'auto',
- 'spillover_threshold': '128',
- 'src_check': 'enable',
- 'status': 'up',
- 'stpforward': 'enable',
- 'stpforward_mode': 'rpl-all-ext-id',
- 'subst': 'enable',
- 'substitute_dst_mac': 'test_value_134',
- 'switch': 'test_value_135',
- 'switch_controller_access_vlan': 'enable',
- 'switch_controller_arp_inspection': 'enable',
- 'switch_controller_dhcp_snooping': 'enable',
- 'switch_controller_dhcp_snooping_option82': 'enable',
- 'switch_controller_dhcp_snooping_verify_mac': 'enable',
- 'switch_controller_igmp_snooping': 'enable',
- 'switch_controller_learning_limit': '142',
- 'tcp_mss': '143',
- 'trust_ip_1': 'test_value_144',
- 'trust_ip_2': 'test_value_145',
- 'trust_ip_3': 'test_value_146',
- 'trust_ip6_1': 'test_value_147',
- 'trust_ip6_2': 'test_value_148',
- 'trust_ip6_3': 'test_value_149',
- 'type': 'physical',
- 'username': 'test_value_151',
- 'vdom': 'test_value_152',
- 'vindex': '153',
- 'vlanforward': 'enable',
- 'vlanid': '155',
- 'vrf': '156',
- 'vrrp_virtual_mac': 'enable',
- 'wccp': 'enable',
- 'weight': '159',
- 'wins_ip': 'test_value_160'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ac-name': 'test_value_3',
- 'aggregate': 'test_value_4',
- 'algorithm': 'L2',
- 'alias': 'test_value_6',
- 'ap-discover': 'enable',
- 'arpforward': 'enable',
- 'auth-type': 'auto',
- 'auto-auth-extension-device': 'enable',
- 'bfd': 'global',
- 'bfd-desired-min-tx': '12',
- 'bfd-detect-mult': '13',
- 'bfd-required-min-rx': '14',
- 'broadcast-forticlient-discovery': 'enable',
- 'broadcast-forward': 'enable',
- 'captive-portal': '17',
- 'cli-conn-status': '18',
- 'color': '19',
- 'dedicated-to': 'none',
- 'defaultgw': 'enable',
- 'description': 'test_value_22',
- 'detected-peer-mtu': '23',
- 'detectprotocol': 'ping',
- 'detectserver': 'test_value_25',
- 'device-access-list': 'test_value_26',
- 'device-identification': 'enable',
- 'device-identification-active-scan': 'enable',
- 'device-netscan': 'disable',
- 'device-user-identification': 'enable',
- 'devindex': '31',
- 'dhcp-client-identifier': 'myId_32',
- 'dhcp-relay-agent-option': 'enable',
- 'dhcp-relay-ip': 'test_value_34',
- 'dhcp-relay-service': 'disable',
- 'dhcp-relay-type': 'regular',
- 'dhcp-renew-time': '37',
- 'disc-retry-timeout': '38',
- 'disconnect-threshold': '39',
- 'distance': '40',
- 'dns-server-override': 'enable',
- 'drop-fragment': 'enable',
- 'drop-overlapped-fragment': 'enable',
- 'egress-shaping-profile': 'test_value_44',
- 'endpoint-compliance': 'enable',
- 'estimated-downstream-bandwidth': '46',
- 'estimated-upstream-bandwidth': '47',
- 'explicit-ftp-proxy': 'enable',
- 'explicit-web-proxy': 'enable',
- 'external': 'enable',
- 'fail-action-on-extender': 'soft-restart',
- 'fail-alert-method': 'link-failed-signal',
- 'fail-detect': 'enable',
- 'fail-detect-option': 'detectserver',
- 'fortiheartbeat': 'enable',
- 'fortilink': 'enable',
- 'fortilink-backup-link': '57',
- 'fortilink-split-interface': 'enable',
- 'fortilink-stacking': 'enable',
- 'forward-domain': '60',
- 'gwdetect': 'enable',
- 'ha-priority': '62',
- 'icmp-accept-redirect': 'enable',
- 'icmp-send-redirect': 'enable',
- 'ident-accept': 'enable',
- 'idle-timeout': '66',
- 'inbandwidth': '67',
- 'ingress-spillover-threshold': '68',
- 'interface': 'test_value_69',
- 'internal': '70',
- 'ip': 'test_value_71',
- 'ipmac': 'enable',
- 'ips-sniffer-mode': 'enable',
- 'ipunnumbered': 'test_value_74',
- 'l2forward': 'enable',
- 'lacp-ha-slave': 'enable',
- 'lacp-mode': 'static',
- 'lacp-speed': 'slow',
- 'lcp-echo-interval': '79',
- 'lcp-max-echo-fails': '80',
- 'link-up-delay': '81',
- 'lldp-transmission': 'enable',
- 'macaddr': 'test_value_83',
- 'management-ip': 'test_value_84',
- 'min-links': '85',
- 'min-links-down': 'operational',
- 'mode': 'static',
- 'mtu': '88',
- 'mtu-override': 'enable',
- 'name': 'default_name_90',
- 'ndiscforward': 'enable',
- 'netbios-forward': 'disable',
- 'netflow-sampler': 'disable',
- 'outbandwidth': '94',
- 'padt-retry-timeout': '95',
- 'password': 'test_value_96',
- 'ping-serv-status': '97',
- 'polling-interval': '98',
- 'pppoe-unnumbered-negotiate': 'enable',
- 'pptp-auth-type': 'auto',
- 'pptp-client': 'enable',
- 'pptp-password': 'test_value_102',
- 'pptp-server-ip': 'test_value_103',
- 'pptp-timeout': '104',
- 'pptp-user': 'test_value_105',
- 'preserve-session-route': 'enable',
- 'priority': '107',
- 'priority-override': 'enable',
- 'proxy-captive-portal': 'enable',
- 'redundant-interface': 'test_value_110',
- 'remote-ip': 'test_value_111',
- 'replacemsg-override-group': 'test_value_112',
- 'role': 'lan',
- 'sample-direction': 'tx',
- 'sample-rate': '115',
- 'scan-botnet-connections': 'disable',
- 'secondary-IP': 'enable',
- 'security-exempt-list': 'test_value_118',
- 'security-external-logout': 'test_value_119',
- 'security-external-web': 'test_value_120',
- 'security-mac-auth-bypass': 'enable',
- 'security-mode': 'none',
- 'security-redirect-url': 'test_value_123',
- 'service-name': 'test_value_124',
- 'sflow-sampler': 'enable',
- 'snmp-index': '126',
- 'speed': 'auto',
- 'spillover-threshold': '128',
- 'src-check': 'enable',
- 'status': 'up',
- 'stpforward': 'enable',
- 'stpforward-mode': 'rpl-all-ext-id',
- 'subst': 'enable',
- 'substitute-dst-mac': 'test_value_134',
- 'switch': 'test_value_135',
- 'switch-controller-access-vlan': 'enable',
- 'switch-controller-arp-inspection': 'enable',
- 'switch-controller-dhcp-snooping': 'enable',
- 'switch-controller-dhcp-snooping-option82': 'enable',
- 'switch-controller-dhcp-snooping-verify-mac': 'enable',
- 'switch-controller-igmp-snooping': 'enable',
- 'switch-controller-learning-limit': '142',
- 'tcp-mss': '143',
- 'trust-ip-1': 'test_value_144',
- 'trust-ip-2': 'test_value_145',
- 'trust-ip-3': 'test_value_146',
- 'trust-ip6-1': 'test_value_147',
- 'trust-ip6-2': 'test_value_148',
- 'trust-ip6-3': 'test_value_149',
- 'type': 'physical',
- 'username': 'test_value_151',
- 'vdom': 'test_value_152',
- 'vindex': '153',
- 'vlanforward': 'enable',
- 'vlanid': '155',
- 'vrf': '156',
- 'vrrp-virtual-mac': 'enable',
- 'wccp': 'enable',
- 'weight': '159',
- 'wins-ip': 'test_value_160'
- }
-
- set_method_mock.assert_called_with('system', 'interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_ipip_tunnel.py b/test/units/modules/network/fortios/test_fortios_system_ipip_tunnel.py
deleted file mode 100644
index 4471f61cdd..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_ipip_tunnel.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_ipip_tunnel
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_ipip_tunnel.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_ipip_tunnel_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipip_tunnel': {
- 'interface': 'test_value_3',
- 'local_gw': 'test_value_4',
- 'name': 'default_name_5',
- 'remote_gw': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipip_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interface': 'test_value_3',
- 'local-gw': 'test_value_4',
- 'name': 'default_name_5',
- 'remote-gw': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipip-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ipip_tunnel_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipip_tunnel': {
- 'interface': 'test_value_3',
- 'local_gw': 'test_value_4',
- 'name': 'default_name_5',
- 'remote_gw': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipip_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interface': 'test_value_3',
- 'local-gw': 'test_value_4',
- 'name': 'default_name_5',
- 'remote-gw': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipip-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ipip_tunnel_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ipip_tunnel': {
- 'interface': 'test_value_3',
- 'local_gw': 'test_value_4',
- 'name': 'default_name_5',
- 'remote_gw': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipip_tunnel.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ipip-tunnel', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ipip_tunnel_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ipip_tunnel': {
- 'interface': 'test_value_3',
- 'local_gw': 'test_value_4',
- 'name': 'default_name_5',
- 'remote_gw': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipip_tunnel.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ipip-tunnel', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ipip_tunnel_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipip_tunnel': {
- 'interface': 'test_value_3',
- 'local_gw': 'test_value_4',
- 'name': 'default_name_5',
- 'remote_gw': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipip_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interface': 'test_value_3',
- 'local-gw': 'test_value_4',
- 'name': 'default_name_5',
- 'remote-gw': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipip-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_ipip_tunnel_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipip_tunnel': {
- 'random_attribute_not_valid': 'tag',
- 'interface': 'test_value_3',
- 'local_gw': 'test_value_4',
- 'name': 'default_name_5',
- 'remote_gw': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipip_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interface': 'test_value_3',
- 'local-gw': 'test_value_4',
- 'name': 'default_name_5',
- 'remote-gw': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipip-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_ips_urlfilter_dns.py b/test/units/modules/network/fortios/test_fortios_system_ips_urlfilter_dns.py
deleted file mode 100644
index dd684b3e4d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_ips_urlfilter_dns.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_ips_urlfilter_dns
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_ips_urlfilter_dns.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_ips_urlfilter_dns_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ips_urlfilter_dns': {
- 'address': 'test_value_3',
- 'ipv6_capability': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'ipv6-capability': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ips-urlfilter-dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ips_urlfilter_dns_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ips_urlfilter_dns': {
- 'address': 'test_value_3',
- 'ipv6_capability': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'ipv6-capability': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ips-urlfilter-dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ips_urlfilter_dns_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ips_urlfilter_dns': {
- 'address': 'test_value_3',
- 'ipv6_capability': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ips-urlfilter-dns', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ips_urlfilter_dns_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ips_urlfilter_dns': {
- 'address': 'test_value_3',
- 'ipv6_capability': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ips-urlfilter-dns', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ips_urlfilter_dns_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ips_urlfilter_dns': {
- 'address': 'test_value_3',
- 'ipv6_capability': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'ipv6-capability': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ips-urlfilter-dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_ips_urlfilter_dns_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ips_urlfilter_dns': {
- 'random_attribute_not_valid': 'tag',
- 'address': 'test_value_3',
- 'ipv6_capability': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address': 'test_value_3',
- 'ipv6-capability': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ips-urlfilter-dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_ips_urlfilter_dns6.py b/test/units/modules/network/fortios/test_fortios_system_ips_urlfilter_dns6.py
deleted file mode 100644
index aaa4d87c8c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_ips_urlfilter_dns6.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_ips_urlfilter_dns6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_ips_urlfilter_dns6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_ips_urlfilter_dns6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ips_urlfilter_dns6': {
- 'address6': 'test_value_3',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns6.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address6': 'test_value_3',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ips-urlfilter-dns6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ips_urlfilter_dns6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ips_urlfilter_dns6': {
- 'address6': 'test_value_3',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns6.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address6': 'test_value_3',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ips-urlfilter-dns6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ips_urlfilter_dns6_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ips_urlfilter_dns6': {
- 'address6': 'test_value_3',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns6.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ips-urlfilter-dns6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ips_urlfilter_dns6_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ips_urlfilter_dns6': {
- 'address6': 'test_value_3',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns6.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ips-urlfilter-dns6', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ips_urlfilter_dns6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ips_urlfilter_dns6': {
- 'address6': 'test_value_3',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns6.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address6': 'test_value_3',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ips-urlfilter-dns6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_ips_urlfilter_dns6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ips_urlfilter_dns6': {
- 'random_attribute_not_valid': 'tag',
- 'address6': 'test_value_3',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ips_urlfilter_dns6.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address6': 'test_value_3',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'ips-urlfilter-dns6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_ipv6_neighbor_cache.py b/test/units/modules/network/fortios/test_fortios_system_ipv6_neighbor_cache.py
deleted file mode 100644
index 90dc1dc71d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_ipv6_neighbor_cache.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_ipv6_neighbor_cache
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_ipv6_neighbor_cache.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_ipv6_neighbor_cache_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipv6_neighbor_cache': {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ipv6': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_neighbor_cache.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ipv6': 'test_value_5',
- 'mac': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipv6-neighbor-cache', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ipv6_neighbor_cache_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipv6_neighbor_cache': {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ipv6': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_neighbor_cache.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ipv6': 'test_value_5',
- 'mac': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipv6-neighbor-cache', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ipv6_neighbor_cache_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ipv6_neighbor_cache': {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ipv6': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_neighbor_cache.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ipv6-neighbor-cache', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ipv6_neighbor_cache_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ipv6_neighbor_cache': {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ipv6': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_neighbor_cache.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ipv6-neighbor-cache', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ipv6_neighbor_cache_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipv6_neighbor_cache': {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ipv6': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_neighbor_cache.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ipv6': 'test_value_5',
- 'mac': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipv6-neighbor-cache', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_ipv6_neighbor_cache_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipv6_neighbor_cache': {
- 'random_attribute_not_valid': 'tag',
- 'id': '3',
- 'interface': 'test_value_4',
- 'ipv6': 'test_value_5',
- 'mac': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_neighbor_cache.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'interface': 'test_value_4',
- 'ipv6': 'test_value_5',
- 'mac': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipv6-neighbor-cache', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_ipv6_tunnel.py b/test/units/modules/network/fortios/test_fortios_system_ipv6_tunnel.py
deleted file mode 100644
index b8706ce474..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_ipv6_tunnel.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_ipv6_tunnel
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_ipv6_tunnel.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_ipv6_tunnel_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipv6_tunnel': {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'name': 'default_name_5',
- 'source': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'name': 'default_name_5',
- 'source': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipv6-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ipv6_tunnel_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipv6_tunnel': {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'name': 'default_name_5',
- 'source': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'name': 'default_name_5',
- 'source': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipv6-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ipv6_tunnel_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ipv6_tunnel': {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'name': 'default_name_5',
- 'source': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_tunnel.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ipv6-tunnel', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ipv6_tunnel_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_ipv6_tunnel': {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'name': 'default_name_5',
- 'source': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_tunnel.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'ipv6-tunnel', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ipv6_tunnel_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipv6_tunnel': {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'name': 'default_name_5',
- 'source': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'name': 'default_name_5',
- 'source': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipv6-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_ipv6_tunnel_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ipv6_tunnel': {
- 'random_attribute_not_valid': 'tag',
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'name': 'default_name_5',
- 'source': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ipv6_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'name': 'default_name_5',
- 'source': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'ipv6-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_link_monitor.py b/test/units/modules/network/fortios/test_fortios_system_link_monitor.py
deleted file mode 100644
index db70853745..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_link_monitor.py
+++ /dev/null
@@ -1,409 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_link_monitor
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_link_monitor.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_link_monitor_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_link_monitor': {
- 'addr_mode': 'ipv4',
- 'failtime': '4',
- 'gateway_ip': 'test_value_5',
- 'gateway_ip6': 'test_value_6',
- 'ha_priority': '7',
- 'http_agent': 'test_value_8',
- 'http_get': 'test_value_9',
- 'http_match': 'test_value_10',
- 'interval': '11',
- 'name': 'default_name_12',
- 'packet_size': '13',
- 'password': 'test_value_14',
- 'port': '15',
- 'protocol': 'ping',
- 'recoverytime': '17',
- 'security_mode': 'none',
- 'source_ip': '84.230.14.19',
- 'source_ip6': 'test_value_20',
- 'srcintf': 'test_value_21',
- 'status': 'enable',
- 'update_cascade_interface': 'enable',
- 'update_static_route': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_link_monitor.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'addr-mode': 'ipv4',
- 'failtime': '4',
- 'gateway-ip': 'test_value_5',
- 'gateway-ip6': 'test_value_6',
- 'ha-priority': '7',
- 'http-agent': 'test_value_8',
- 'http-get': 'test_value_9',
- 'http-match': 'test_value_10',
- 'interval': '11',
- 'name': 'default_name_12',
- 'packet-size': '13',
- 'password': 'test_value_14',
- 'port': '15',
- 'protocol': 'ping',
- 'recoverytime': '17',
- 'security-mode': 'none',
- 'source-ip': '84.230.14.19',
- 'source-ip6': 'test_value_20',
- 'srcintf': 'test_value_21',
- 'status': 'enable',
- 'update-cascade-interface': 'enable',
- 'update-static-route': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'link-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_link_monitor_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_link_monitor': {
- 'addr_mode': 'ipv4',
- 'failtime': '4',
- 'gateway_ip': 'test_value_5',
- 'gateway_ip6': 'test_value_6',
- 'ha_priority': '7',
- 'http_agent': 'test_value_8',
- 'http_get': 'test_value_9',
- 'http_match': 'test_value_10',
- 'interval': '11',
- 'name': 'default_name_12',
- 'packet_size': '13',
- 'password': 'test_value_14',
- 'port': '15',
- 'protocol': 'ping',
- 'recoverytime': '17',
- 'security_mode': 'none',
- 'source_ip': '84.230.14.19',
- 'source_ip6': 'test_value_20',
- 'srcintf': 'test_value_21',
- 'status': 'enable',
- 'update_cascade_interface': 'enable',
- 'update_static_route': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_link_monitor.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'addr-mode': 'ipv4',
- 'failtime': '4',
- 'gateway-ip': 'test_value_5',
- 'gateway-ip6': 'test_value_6',
- 'ha-priority': '7',
- 'http-agent': 'test_value_8',
- 'http-get': 'test_value_9',
- 'http-match': 'test_value_10',
- 'interval': '11',
- 'name': 'default_name_12',
- 'packet-size': '13',
- 'password': 'test_value_14',
- 'port': '15',
- 'protocol': 'ping',
- 'recoverytime': '17',
- 'security-mode': 'none',
- 'source-ip': '84.230.14.19',
- 'source-ip6': 'test_value_20',
- 'srcintf': 'test_value_21',
- 'status': 'enable',
- 'update-cascade-interface': 'enable',
- 'update-static-route': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'link-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_link_monitor_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_link_monitor': {
- 'addr_mode': 'ipv4',
- 'failtime': '4',
- 'gateway_ip': 'test_value_5',
- 'gateway_ip6': 'test_value_6',
- 'ha_priority': '7',
- 'http_agent': 'test_value_8',
- 'http_get': 'test_value_9',
- 'http_match': 'test_value_10',
- 'interval': '11',
- 'name': 'default_name_12',
- 'packet_size': '13',
- 'password': 'test_value_14',
- 'port': '15',
- 'protocol': 'ping',
- 'recoverytime': '17',
- 'security_mode': 'none',
- 'source_ip': '84.230.14.19',
- 'source_ip6': 'test_value_20',
- 'srcintf': 'test_value_21',
- 'status': 'enable',
- 'update_cascade_interface': 'enable',
- 'update_static_route': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_link_monitor.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'link-monitor', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_link_monitor_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_link_monitor': {
- 'addr_mode': 'ipv4',
- 'failtime': '4',
- 'gateway_ip': 'test_value_5',
- 'gateway_ip6': 'test_value_6',
- 'ha_priority': '7',
- 'http_agent': 'test_value_8',
- 'http_get': 'test_value_9',
- 'http_match': 'test_value_10',
- 'interval': '11',
- 'name': 'default_name_12',
- 'packet_size': '13',
- 'password': 'test_value_14',
- 'port': '15',
- 'protocol': 'ping',
- 'recoverytime': '17',
- 'security_mode': 'none',
- 'source_ip': '84.230.14.19',
- 'source_ip6': 'test_value_20',
- 'srcintf': 'test_value_21',
- 'status': 'enable',
- 'update_cascade_interface': 'enable',
- 'update_static_route': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_link_monitor.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'link-monitor', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_link_monitor_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_link_monitor': {
- 'addr_mode': 'ipv4',
- 'failtime': '4',
- 'gateway_ip': 'test_value_5',
- 'gateway_ip6': 'test_value_6',
- 'ha_priority': '7',
- 'http_agent': 'test_value_8',
- 'http_get': 'test_value_9',
- 'http_match': 'test_value_10',
- 'interval': '11',
- 'name': 'default_name_12',
- 'packet_size': '13',
- 'password': 'test_value_14',
- 'port': '15',
- 'protocol': 'ping',
- 'recoverytime': '17',
- 'security_mode': 'none',
- 'source_ip': '84.230.14.19',
- 'source_ip6': 'test_value_20',
- 'srcintf': 'test_value_21',
- 'status': 'enable',
- 'update_cascade_interface': 'enable',
- 'update_static_route': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_link_monitor.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'addr-mode': 'ipv4',
- 'failtime': '4',
- 'gateway-ip': 'test_value_5',
- 'gateway-ip6': 'test_value_6',
- 'ha-priority': '7',
- 'http-agent': 'test_value_8',
- 'http-get': 'test_value_9',
- 'http-match': 'test_value_10',
- 'interval': '11',
- 'name': 'default_name_12',
- 'packet-size': '13',
- 'password': 'test_value_14',
- 'port': '15',
- 'protocol': 'ping',
- 'recoverytime': '17',
- 'security-mode': 'none',
- 'source-ip': '84.230.14.19',
- 'source-ip6': 'test_value_20',
- 'srcintf': 'test_value_21',
- 'status': 'enable',
- 'update-cascade-interface': 'enable',
- 'update-static-route': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'link-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_link_monitor_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_link_monitor': {
- 'random_attribute_not_valid': 'tag',
- 'addr_mode': 'ipv4',
- 'failtime': '4',
- 'gateway_ip': 'test_value_5',
- 'gateway_ip6': 'test_value_6',
- 'ha_priority': '7',
- 'http_agent': 'test_value_8',
- 'http_get': 'test_value_9',
- 'http_match': 'test_value_10',
- 'interval': '11',
- 'name': 'default_name_12',
- 'packet_size': '13',
- 'password': 'test_value_14',
- 'port': '15',
- 'protocol': 'ping',
- 'recoverytime': '17',
- 'security_mode': 'none',
- 'source_ip': '84.230.14.19',
- 'source_ip6': 'test_value_20',
- 'srcintf': 'test_value_21',
- 'status': 'enable',
- 'update_cascade_interface': 'enable',
- 'update_static_route': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_link_monitor.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'addr-mode': 'ipv4',
- 'failtime': '4',
- 'gateway-ip': 'test_value_5',
- 'gateway-ip6': 'test_value_6',
- 'ha-priority': '7',
- 'http-agent': 'test_value_8',
- 'http-get': 'test_value_9',
- 'http-match': 'test_value_10',
- 'interval': '11',
- 'name': 'default_name_12',
- 'packet-size': '13',
- 'password': 'test_value_14',
- 'port': '15',
- 'protocol': 'ping',
- 'recoverytime': '17',
- 'security-mode': 'none',
- 'source-ip': '84.230.14.19',
- 'source-ip6': 'test_value_20',
- 'srcintf': 'test_value_21',
- 'status': 'enable',
- 'update-cascade-interface': 'enable',
- 'update-static-route': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'link-monitor', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_mac_address_table.py b/test/units/modules/network/fortios/test_fortios_system_mac_address_table.py
deleted file mode 100644
index ec60a34f8a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_mac_address_table.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_mac_address_table
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_mac_address_table.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_mac_address_table_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_mac_address_table': {
- 'interface': 'test_value_3',
- 'mac': 'test_value_4',
- 'reply_substitute': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mac_address_table.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interface': 'test_value_3',
- 'mac': 'test_value_4',
- 'reply-substitute': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'mac-address-table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_mac_address_table_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_mac_address_table': {
- 'interface': 'test_value_3',
- 'mac': 'test_value_4',
- 'reply_substitute': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mac_address_table.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interface': 'test_value_3',
- 'mac': 'test_value_4',
- 'reply-substitute': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'mac-address-table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_mac_address_table_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_mac_address_table': {
- 'interface': 'test_value_3',
- 'mac': 'test_value_4',
- 'reply_substitute': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mac_address_table.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'mac-address-table', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_mac_address_table_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_mac_address_table': {
- 'interface': 'test_value_3',
- 'mac': 'test_value_4',
- 'reply_substitute': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mac_address_table.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'mac-address-table', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_mac_address_table_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_mac_address_table': {
- 'interface': 'test_value_3',
- 'mac': 'test_value_4',
- 'reply_substitute': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mac_address_table.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interface': 'test_value_3',
- 'mac': 'test_value_4',
- 'reply-substitute': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'mac-address-table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_mac_address_table_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_mac_address_table': {
- 'random_attribute_not_valid': 'tag',
- 'interface': 'test_value_3',
- 'mac': 'test_value_4',
- 'reply_substitute': 'test_value_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mac_address_table.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'interface': 'test_value_3',
- 'mac': 'test_value_4',
- 'reply-substitute': 'test_value_5'
- }
-
- set_method_mock.assert_called_with('system', 'mac-address-table', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_management_tunnel.py b/test/units/modules/network/fortios/test_fortios_system_management_tunnel.py
deleted file mode 100644
index 8eded28426..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_management_tunnel.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_management_tunnel
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_management_tunnel.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_management_tunnel_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_management_tunnel': {
- 'allow_collect_statistics': 'enable',
- 'allow_config_restore': 'enable',
- 'allow_push_configuration': 'enable',
- 'allow_push_firmware': 'enable',
- 'authorized_manager_only': 'enable',
- 'serial_number': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_management_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-collect-statistics': 'enable',
- 'allow-config-restore': 'enable',
- 'allow-push-configuration': 'enable',
- 'allow-push-firmware': 'enable',
- 'authorized-manager-only': 'enable',
- 'serial-number': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'management-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_management_tunnel_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_management_tunnel': {
- 'allow_collect_statistics': 'enable',
- 'allow_config_restore': 'enable',
- 'allow_push_configuration': 'enable',
- 'allow_push_firmware': 'enable',
- 'authorized_manager_only': 'enable',
- 'serial_number': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_management_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-collect-statistics': 'enable',
- 'allow-config-restore': 'enable',
- 'allow-push-configuration': 'enable',
- 'allow-push-firmware': 'enable',
- 'authorized-manager-only': 'enable',
- 'serial-number': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'management-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_management_tunnel_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_management_tunnel': {
- 'allow_collect_statistics': 'enable',
- 'allow_config_restore': 'enable',
- 'allow_push_configuration': 'enable',
- 'allow_push_firmware': 'enable',
- 'authorized_manager_only': 'enable',
- 'serial_number': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_management_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-collect-statistics': 'enable',
- 'allow-config-restore': 'enable',
- 'allow-push-configuration': 'enable',
- 'allow-push-firmware': 'enable',
- 'authorized-manager-only': 'enable',
- 'serial-number': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'management-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_management_tunnel_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_management_tunnel': {
- 'random_attribute_not_valid': 'tag',
- 'allow_collect_statistics': 'enable',
- 'allow_config_restore': 'enable',
- 'allow_push_configuration': 'enable',
- 'allow_push_firmware': 'enable',
- 'authorized_manager_only': 'enable',
- 'serial_number': 'test_value_8',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_management_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-collect-statistics': 'enable',
- 'allow-config-restore': 'enable',
- 'allow-push-configuration': 'enable',
- 'allow-push-firmware': 'enable',
- 'authorized-manager-only': 'enable',
- 'serial-number': 'test_value_8',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'management-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_mobile_tunnel.py b/test/units/modules/network/fortios/test_fortios_system_mobile_tunnel.py
deleted file mode 100644
index 4db3ff2dc9..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_mobile_tunnel.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_mobile_tunnel
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_mobile_tunnel.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_mobile_tunnel_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_mobile_tunnel': {
- 'hash_algorithm': 'hmac-md5',
- 'home_address': 'test_value_4',
- 'home_agent': 'test_value_5',
- 'lifetime': '6',
- 'n_mhae_key': 'test_value_7',
- 'n_mhae_key_type': 'ascii',
- 'n_mhae_spi': '9',
- 'name': 'default_name_10',
- 'reg_interval': '11',
- 'reg_retry': '12',
- 'renew_interval': '13',
- 'roaming_interface': 'test_value_14',
- 'status': 'disable',
- 'tunnel_mode': 'gre'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mobile_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'hash-algorithm': 'hmac-md5',
- 'home-address': 'test_value_4',
- 'home-agent': 'test_value_5',
- 'lifetime': '6',
- 'n-mhae-key': 'test_value_7',
- 'n-mhae-key-type': 'ascii',
- 'n-mhae-spi': '9',
- 'name': 'default_name_10',
- 'reg-interval': '11',
- 'reg-retry': '12',
- 'renew-interval': '13',
- 'roaming-interface': 'test_value_14',
- 'status': 'disable',
- 'tunnel-mode': 'gre'
- }
-
- set_method_mock.assert_called_with('system', 'mobile-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_mobile_tunnel_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_mobile_tunnel': {
- 'hash_algorithm': 'hmac-md5',
- 'home_address': 'test_value_4',
- 'home_agent': 'test_value_5',
- 'lifetime': '6',
- 'n_mhae_key': 'test_value_7',
- 'n_mhae_key_type': 'ascii',
- 'n_mhae_spi': '9',
- 'name': 'default_name_10',
- 'reg_interval': '11',
- 'reg_retry': '12',
- 'renew_interval': '13',
- 'roaming_interface': 'test_value_14',
- 'status': 'disable',
- 'tunnel_mode': 'gre'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mobile_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'hash-algorithm': 'hmac-md5',
- 'home-address': 'test_value_4',
- 'home-agent': 'test_value_5',
- 'lifetime': '6',
- 'n-mhae-key': 'test_value_7',
- 'n-mhae-key-type': 'ascii',
- 'n-mhae-spi': '9',
- 'name': 'default_name_10',
- 'reg-interval': '11',
- 'reg-retry': '12',
- 'renew-interval': '13',
- 'roaming-interface': 'test_value_14',
- 'status': 'disable',
- 'tunnel-mode': 'gre'
- }
-
- set_method_mock.assert_called_with('system', 'mobile-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_mobile_tunnel_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_mobile_tunnel': {
- 'hash_algorithm': 'hmac-md5',
- 'home_address': 'test_value_4',
- 'home_agent': 'test_value_5',
- 'lifetime': '6',
- 'n_mhae_key': 'test_value_7',
- 'n_mhae_key_type': 'ascii',
- 'n_mhae_spi': '9',
- 'name': 'default_name_10',
- 'reg_interval': '11',
- 'reg_retry': '12',
- 'renew_interval': '13',
- 'roaming_interface': 'test_value_14',
- 'status': 'disable',
- 'tunnel_mode': 'gre'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mobile_tunnel.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'mobile-tunnel', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_mobile_tunnel_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_mobile_tunnel': {
- 'hash_algorithm': 'hmac-md5',
- 'home_address': 'test_value_4',
- 'home_agent': 'test_value_5',
- 'lifetime': '6',
- 'n_mhae_key': 'test_value_7',
- 'n_mhae_key_type': 'ascii',
- 'n_mhae_spi': '9',
- 'name': 'default_name_10',
- 'reg_interval': '11',
- 'reg_retry': '12',
- 'renew_interval': '13',
- 'roaming_interface': 'test_value_14',
- 'status': 'disable',
- 'tunnel_mode': 'gre'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mobile_tunnel.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'mobile-tunnel', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_mobile_tunnel_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_mobile_tunnel': {
- 'hash_algorithm': 'hmac-md5',
- 'home_address': 'test_value_4',
- 'home_agent': 'test_value_5',
- 'lifetime': '6',
- 'n_mhae_key': 'test_value_7',
- 'n_mhae_key_type': 'ascii',
- 'n_mhae_spi': '9',
- 'name': 'default_name_10',
- 'reg_interval': '11',
- 'reg_retry': '12',
- 'renew_interval': '13',
- 'roaming_interface': 'test_value_14',
- 'status': 'disable',
- 'tunnel_mode': 'gre'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mobile_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'hash-algorithm': 'hmac-md5',
- 'home-address': 'test_value_4',
- 'home-agent': 'test_value_5',
- 'lifetime': '6',
- 'n-mhae-key': 'test_value_7',
- 'n-mhae-key-type': 'ascii',
- 'n-mhae-spi': '9',
- 'name': 'default_name_10',
- 'reg-interval': '11',
- 'reg-retry': '12',
- 'renew-interval': '13',
- 'roaming-interface': 'test_value_14',
- 'status': 'disable',
- 'tunnel-mode': 'gre'
- }
-
- set_method_mock.assert_called_with('system', 'mobile-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_mobile_tunnel_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_mobile_tunnel': {
- 'random_attribute_not_valid': 'tag',
- 'hash_algorithm': 'hmac-md5',
- 'home_address': 'test_value_4',
- 'home_agent': 'test_value_5',
- 'lifetime': '6',
- 'n_mhae_key': 'test_value_7',
- 'n_mhae_key_type': 'ascii',
- 'n_mhae_spi': '9',
- 'name': 'default_name_10',
- 'reg_interval': '11',
- 'reg_retry': '12',
- 'renew_interval': '13',
- 'roaming_interface': 'test_value_14',
- 'status': 'disable',
- 'tunnel_mode': 'gre'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_mobile_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'hash-algorithm': 'hmac-md5',
- 'home-address': 'test_value_4',
- 'home-agent': 'test_value_5',
- 'lifetime': '6',
- 'n-mhae-key': 'test_value_7',
- 'n-mhae-key-type': 'ascii',
- 'n-mhae-spi': '9',
- 'name': 'default_name_10',
- 'reg-interval': '11',
- 'reg-retry': '12',
- 'renew-interval': '13',
- 'roaming-interface': 'test_value_14',
- 'status': 'disable',
- 'tunnel-mode': 'gre'
- }
-
- set_method_mock.assert_called_with('system', 'mobile-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_nat64.py b/test/units/modules/network/fortios/test_fortios_system_nat64.py
deleted file mode 100644
index ac8e2e2dd0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_nat64.py
+++ /dev/null
@@ -1,191 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_nat64
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_nat64.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_nat64_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_nat64': {
- 'always_synthesize_aaaa_record': 'enable',
- 'generate_ipv6_fragment_header': 'enable',
- 'nat46_force_ipv4_packet_forwarding': 'enable',
- 'nat64_prefix': 'test_value_6',
- 'secondary_prefix_status': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_nat64.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'always-synthesize-aaaa-record': 'enable',
- 'generate-ipv6-fragment-header': 'enable',
- 'nat46-force-ipv4-packet-forwarding': 'enable',
- 'nat64-prefix': 'test_value_6',
- 'secondary-prefix-status': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'nat64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_nat64_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_nat64': {
- 'always_synthesize_aaaa_record': 'enable',
- 'generate_ipv6_fragment_header': 'enable',
- 'nat46_force_ipv4_packet_forwarding': 'enable',
- 'nat64_prefix': 'test_value_6',
- 'secondary_prefix_status': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_nat64.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'always-synthesize-aaaa-record': 'enable',
- 'generate-ipv6-fragment-header': 'enable',
- 'nat46-force-ipv4-packet-forwarding': 'enable',
- 'nat64-prefix': 'test_value_6',
- 'secondary-prefix-status': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'nat64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_nat64_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_nat64': {
- 'always_synthesize_aaaa_record': 'enable',
- 'generate_ipv6_fragment_header': 'enable',
- 'nat46_force_ipv4_packet_forwarding': 'enable',
- 'nat64_prefix': 'test_value_6',
- 'secondary_prefix_status': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_nat64.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'always-synthesize-aaaa-record': 'enable',
- 'generate-ipv6-fragment-header': 'enable',
- 'nat46-force-ipv4-packet-forwarding': 'enable',
- 'nat64-prefix': 'test_value_6',
- 'secondary-prefix-status': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'nat64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_nat64_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_nat64': {
- 'random_attribute_not_valid': 'tag',
- 'always_synthesize_aaaa_record': 'enable',
- 'generate_ipv6_fragment_header': 'enable',
- 'nat46_force_ipv4_packet_forwarding': 'enable',
- 'nat64_prefix': 'test_value_6',
- 'secondary_prefix_status': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_nat64.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'always-synthesize-aaaa-record': 'enable',
- 'generate-ipv6-fragment-header': 'enable',
- 'nat46-force-ipv4-packet-forwarding': 'enable',
- 'nat64-prefix': 'test_value_6',
- 'secondary-prefix-status': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'nat64', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_nd_proxy.py b/test/units/modules/network/fortios/test_fortios_system_nd_proxy.py
deleted file mode 100644
index 68f0c1830c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_nd_proxy.py
+++ /dev/null
@@ -1,143 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_nd_proxy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_nd_proxy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_nd_proxy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_nd_proxy': {'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_nd_proxy.fortios_system(input_data, fos_instance)
-
- expected_data = {'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'nd-proxy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_nd_proxy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_nd_proxy': {'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_nd_proxy.fortios_system(input_data, fos_instance)
-
- expected_data = {'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'nd-proxy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_nd_proxy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_nd_proxy': {'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_nd_proxy.fortios_system(input_data, fos_instance)
-
- expected_data = {'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'nd-proxy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_nd_proxy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_nd_proxy': {
- 'random_attribute_not_valid': 'tag', 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_nd_proxy.fortios_system(input_data, fos_instance)
-
- expected_data = {'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'nd-proxy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_netflow.py b/test/units/modules/network/fortios/test_fortios_system_netflow.py
deleted file mode 100644
index 69baf759d2..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_netflow.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_netflow
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_netflow.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_netflow_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_netflow': {
- 'active_flow_timeout': '3',
- 'collector_ip': 'test_value_4',
- 'collector_port': '5',
- 'inactive_flow_timeout': '6',
- 'source_ip': '84.230.14.7',
- 'template_tx_counter': '8',
- 'template_tx_timeout': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_netflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'active-flow-timeout': '3',
- 'collector-ip': 'test_value_4',
- 'collector-port': '5',
- 'inactive-flow-timeout': '6',
- 'source-ip': '84.230.14.7',
- 'template-tx-counter': '8',
- 'template-tx-timeout': '9'
- }
-
- set_method_mock.assert_called_with('system', 'netflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_netflow_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_netflow': {
- 'active_flow_timeout': '3',
- 'collector_ip': 'test_value_4',
- 'collector_port': '5',
- 'inactive_flow_timeout': '6',
- 'source_ip': '84.230.14.7',
- 'template_tx_counter': '8',
- 'template_tx_timeout': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_netflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'active-flow-timeout': '3',
- 'collector-ip': 'test_value_4',
- 'collector-port': '5',
- 'inactive-flow-timeout': '6',
- 'source-ip': '84.230.14.7',
- 'template-tx-counter': '8',
- 'template-tx-timeout': '9'
- }
-
- set_method_mock.assert_called_with('system', 'netflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_netflow_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_netflow': {
- 'active_flow_timeout': '3',
- 'collector_ip': 'test_value_4',
- 'collector_port': '5',
- 'inactive_flow_timeout': '6',
- 'source_ip': '84.230.14.7',
- 'template_tx_counter': '8',
- 'template_tx_timeout': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_netflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'active-flow-timeout': '3',
- 'collector-ip': 'test_value_4',
- 'collector-port': '5',
- 'inactive-flow-timeout': '6',
- 'source-ip': '84.230.14.7',
- 'template-tx-counter': '8',
- 'template-tx-timeout': '9'
- }
-
- set_method_mock.assert_called_with('system', 'netflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_netflow_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_netflow': {
- 'random_attribute_not_valid': 'tag',
- 'active_flow_timeout': '3',
- 'collector_ip': 'test_value_4',
- 'collector_port': '5',
- 'inactive_flow_timeout': '6',
- 'source_ip': '84.230.14.7',
- 'template_tx_counter': '8',
- 'template_tx_timeout': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_netflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'active-flow-timeout': '3',
- 'collector-ip': 'test_value_4',
- 'collector-port': '5',
- 'inactive-flow-timeout': '6',
- 'source-ip': '84.230.14.7',
- 'template-tx-counter': '8',
- 'template-tx-timeout': '9'
- }
-
- set_method_mock.assert_called_with('system', 'netflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_network_visibility.py b/test/units/modules/network/fortios/test_fortios_system_network_visibility.py
deleted file mode 100644
index c0b2615113..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_network_visibility.py
+++ /dev/null
@@ -1,191 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_network_visibility
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_network_visibility.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_network_visibility_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_network_visibility': {
- 'destination_hostname_visibility': 'disable',
- 'destination_location': 'disable',
- 'destination_visibility': 'disable',
- 'hostname_limit': '6',
- 'hostname_ttl': '7',
- 'source_location': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_network_visibility.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination-hostname-visibility': 'disable',
- 'destination-location': 'disable',
- 'destination-visibility': 'disable',
- 'hostname-limit': '6',
- 'hostname-ttl': '7',
- 'source-location': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'network-visibility', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_network_visibility_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_network_visibility': {
- 'destination_hostname_visibility': 'disable',
- 'destination_location': 'disable',
- 'destination_visibility': 'disable',
- 'hostname_limit': '6',
- 'hostname_ttl': '7',
- 'source_location': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_network_visibility.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination-hostname-visibility': 'disable',
- 'destination-location': 'disable',
- 'destination-visibility': 'disable',
- 'hostname-limit': '6',
- 'hostname-ttl': '7',
- 'source-location': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'network-visibility', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_network_visibility_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_network_visibility': {
- 'destination_hostname_visibility': 'disable',
- 'destination_location': 'disable',
- 'destination_visibility': 'disable',
- 'hostname_limit': '6',
- 'hostname_ttl': '7',
- 'source_location': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_network_visibility.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination-hostname-visibility': 'disable',
- 'destination-location': 'disable',
- 'destination-visibility': 'disable',
- 'hostname-limit': '6',
- 'hostname-ttl': '7',
- 'source-location': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'network-visibility', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_network_visibility_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_network_visibility': {
- 'random_attribute_not_valid': 'tag',
- 'destination_hostname_visibility': 'disable',
- 'destination_location': 'disable',
- 'destination_visibility': 'disable',
- 'hostname_limit': '6',
- 'hostname_ttl': '7',
- 'source_location': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_network_visibility.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination-hostname-visibility': 'disable',
- 'destination-location': 'disable',
- 'destination-visibility': 'disable',
- 'hostname-limit': '6',
- 'hostname-ttl': '7',
- 'source-location': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'network-visibility', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_ntp.py b/test/units/modules/network/fortios/test_fortios_system_ntp.py
deleted file mode 100644
index 9340b0fd18..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_ntp.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_ntp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_ntp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_ntp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ntp': {'ntpsync': 'enable',
- 'server_mode': 'enable',
- 'source_ip': '84.230.14.5',
- 'source_ip6': 'test_value_6',
- 'syncinterval': '7',
- 'type': 'fortiguard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ntp.fortios_system(input_data, fos_instance)
-
- expected_data = {'ntpsync': 'enable',
- 'server-mode': 'enable',
- 'source-ip': '84.230.14.5',
- 'source-ip6': 'test_value_6',
- 'syncinterval': '7',
- 'type': 'fortiguard'
- }
-
- set_method_mock.assert_called_with('system', 'ntp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_ntp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ntp': {'ntpsync': 'enable',
- 'server_mode': 'enable',
- 'source_ip': '84.230.14.5',
- 'source_ip6': 'test_value_6',
- 'syncinterval': '7',
- 'type': 'fortiguard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ntp.fortios_system(input_data, fos_instance)
-
- expected_data = {'ntpsync': 'enable',
- 'server-mode': 'enable',
- 'source-ip': '84.230.14.5',
- 'source-ip6': 'test_value_6',
- 'syncinterval': '7',
- 'type': 'fortiguard'
- }
-
- set_method_mock.assert_called_with('system', 'ntp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_ntp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ntp': {'ntpsync': 'enable',
- 'server_mode': 'enable',
- 'source_ip': '84.230.14.5',
- 'source_ip6': 'test_value_6',
- 'syncinterval': '7',
- 'type': 'fortiguard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ntp.fortios_system(input_data, fos_instance)
-
- expected_data = {'ntpsync': 'enable',
- 'server-mode': 'enable',
- 'source-ip': '84.230.14.5',
- 'source-ip6': 'test_value_6',
- 'syncinterval': '7',
- 'type': 'fortiguard'
- }
-
- set_method_mock.assert_called_with('system', 'ntp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_ntp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_ntp': {
- 'random_attribute_not_valid': 'tag', 'ntpsync': 'enable',
- 'server_mode': 'enable',
- 'source_ip': '84.230.14.5',
- 'source_ip6': 'test_value_6',
- 'syncinterval': '7',
- 'type': 'fortiguard'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_ntp.fortios_system(input_data, fos_instance)
-
- expected_data = {'ntpsync': 'enable',
- 'server-mode': 'enable',
- 'source-ip': '84.230.14.5',
- 'source-ip6': 'test_value_6',
- 'syncinterval': '7',
- 'type': 'fortiguard'
- }
-
- set_method_mock.assert_called_with('system', 'ntp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_object_tagging.py b/test/units/modules/network/fortios/test_fortios_system_object_tagging.py
deleted file mode 100644
index ee8615623e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_object_tagging.py
+++ /dev/null
@@ -1,259 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_object_tagging
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_object_tagging.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_object_tagging_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_object_tagging': {
- 'address': 'disable',
- 'category': 'test_value_4',
- 'color': '5',
- 'device': 'disable',
- 'interface': 'disable',
- 'multiple': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_object_tagging.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address': 'disable',
- 'category': 'test_value_4',
- 'color': '5',
- 'device': 'disable',
- 'interface': 'disable',
- 'multiple': 'enable',
-
- }
-
- set_method_mock.assert_called_with('system', 'object-tagging', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_object_tagging_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_object_tagging': {
- 'address': 'disable',
- 'category': 'test_value_4',
- 'color': '5',
- 'device': 'disable',
- 'interface': 'disable',
- 'multiple': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_object_tagging.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address': 'disable',
- 'category': 'test_value_4',
- 'color': '5',
- 'device': 'disable',
- 'interface': 'disable',
- 'multiple': 'enable',
-
- }
-
- set_method_mock.assert_called_with('system', 'object-tagging', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_object_tagging_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_object_tagging': {
- 'address': 'disable',
- 'category': 'test_value_4',
- 'color': '5',
- 'device': 'disable',
- 'interface': 'disable',
- 'multiple': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_object_tagging.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'object-tagging', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_object_tagging_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_object_tagging': {
- 'address': 'disable',
- 'category': 'test_value_4',
- 'color': '5',
- 'device': 'disable',
- 'interface': 'disable',
- 'multiple': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_object_tagging.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'object-tagging', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_object_tagging_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_object_tagging': {
- 'address': 'disable',
- 'category': 'test_value_4',
- 'color': '5',
- 'device': 'disable',
- 'interface': 'disable',
- 'multiple': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_object_tagging.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address': 'disable',
- 'category': 'test_value_4',
- 'color': '5',
- 'device': 'disable',
- 'interface': 'disable',
- 'multiple': 'enable',
-
- }
-
- set_method_mock.assert_called_with('system', 'object-tagging', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_object_tagging_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_object_tagging': {
- 'random_attribute_not_valid': 'tag',
- 'address': 'disable',
- 'category': 'test_value_4',
- 'color': '5',
- 'device': 'disable',
- 'interface': 'disable',
- 'multiple': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_object_tagging.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'address': 'disable',
- 'category': 'test_value_4',
- 'color': '5',
- 'device': 'disable',
- 'interface': 'disable',
- 'multiple': 'enable',
-
- }
-
- set_method_mock.assert_called_with('system', 'object-tagging', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_password_policy.py b/test/units/modules/network/fortios/test_fortios_system_password_policy.py
deleted file mode 100644
index ff37f67ec8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_password_policy.py
+++ /dev/null
@@ -1,231 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_password_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_password_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_password_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_password_policy': {
- 'apply_to': 'admin-password',
- 'change_4_characters': 'enable',
- 'expire_day': '5',
- 'expire_status': 'enable',
- 'min_lower_case_letter': '7',
- 'min_non_alphanumeric': '8',
- 'min_number': '9',
- 'min_upper_case_letter': '10',
- 'minimum_length': '11',
- 'reuse_password': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_password_policy.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'apply-to': 'admin-password',
- 'change-4-characters': 'enable',
- 'expire-day': '5',
- 'expire-status': 'enable',
- 'min-lower-case-letter': '7',
- 'min-non-alphanumeric': '8',
- 'min-number': '9',
- 'min-upper-case-letter': '10',
- 'minimum-length': '11',
- 'reuse-password': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'password-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_password_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_password_policy': {
- 'apply_to': 'admin-password',
- 'change_4_characters': 'enable',
- 'expire_day': '5',
- 'expire_status': 'enable',
- 'min_lower_case_letter': '7',
- 'min_non_alphanumeric': '8',
- 'min_number': '9',
- 'min_upper_case_letter': '10',
- 'minimum_length': '11',
- 'reuse_password': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_password_policy.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'apply-to': 'admin-password',
- 'change-4-characters': 'enable',
- 'expire-day': '5',
- 'expire-status': 'enable',
- 'min-lower-case-letter': '7',
- 'min-non-alphanumeric': '8',
- 'min-number': '9',
- 'min-upper-case-letter': '10',
- 'minimum-length': '11',
- 'reuse-password': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'password-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_password_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_password_policy': {
- 'apply_to': 'admin-password',
- 'change_4_characters': 'enable',
- 'expire_day': '5',
- 'expire_status': 'enable',
- 'min_lower_case_letter': '7',
- 'min_non_alphanumeric': '8',
- 'min_number': '9',
- 'min_upper_case_letter': '10',
- 'minimum_length': '11',
- 'reuse_password': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_password_policy.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'apply-to': 'admin-password',
- 'change-4-characters': 'enable',
- 'expire-day': '5',
- 'expire-status': 'enable',
- 'min-lower-case-letter': '7',
- 'min-non-alphanumeric': '8',
- 'min-number': '9',
- 'min-upper-case-letter': '10',
- 'minimum-length': '11',
- 'reuse-password': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'password-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_password_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_password_policy': {
- 'random_attribute_not_valid': 'tag',
- 'apply_to': 'admin-password',
- 'change_4_characters': 'enable',
- 'expire_day': '5',
- 'expire_status': 'enable',
- 'min_lower_case_letter': '7',
- 'min_non_alphanumeric': '8',
- 'min_number': '9',
- 'min_upper_case_letter': '10',
- 'minimum_length': '11',
- 'reuse_password': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_password_policy.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'apply-to': 'admin-password',
- 'change-4-characters': 'enable',
- 'expire-day': '5',
- 'expire-status': 'enable',
- 'min-lower-case-letter': '7',
- 'min-non-alphanumeric': '8',
- 'min-number': '9',
- 'min-upper-case-letter': '10',
- 'minimum-length': '11',
- 'reuse-password': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'password-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_password_policy_guest_admin.py b/test/units/modules/network/fortios/test_fortios_system_password_policy_guest_admin.py
deleted file mode 100644
index 862b93f18e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_password_policy_guest_admin.py
+++ /dev/null
@@ -1,231 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_password_policy_guest_admin
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_password_policy_guest_admin.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_password_policy_guest_admin_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_password_policy_guest_admin': {
- 'apply_to': 'guest-admin-password',
- 'change_4_characters': 'enable',
- 'expire_day': '5',
- 'expire_status': 'enable',
- 'min_lower_case_letter': '7',
- 'min_non_alphanumeric': '8',
- 'min_number': '9',
- 'min_upper_case_letter': '10',
- 'minimum_length': '11',
- 'reuse_password': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_password_policy_guest_admin.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'apply-to': 'guest-admin-password',
- 'change-4-characters': 'enable',
- 'expire-day': '5',
- 'expire-status': 'enable',
- 'min-lower-case-letter': '7',
- 'min-non-alphanumeric': '8',
- 'min-number': '9',
- 'min-upper-case-letter': '10',
- 'minimum-length': '11',
- 'reuse-password': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'password-policy-guest-admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_password_policy_guest_admin_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_password_policy_guest_admin': {
- 'apply_to': 'guest-admin-password',
- 'change_4_characters': 'enable',
- 'expire_day': '5',
- 'expire_status': 'enable',
- 'min_lower_case_letter': '7',
- 'min_non_alphanumeric': '8',
- 'min_number': '9',
- 'min_upper_case_letter': '10',
- 'minimum_length': '11',
- 'reuse_password': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_password_policy_guest_admin.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'apply-to': 'guest-admin-password',
- 'change-4-characters': 'enable',
- 'expire-day': '5',
- 'expire-status': 'enable',
- 'min-lower-case-letter': '7',
- 'min-non-alphanumeric': '8',
- 'min-number': '9',
- 'min-upper-case-letter': '10',
- 'minimum-length': '11',
- 'reuse-password': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'password-policy-guest-admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_password_policy_guest_admin_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_password_policy_guest_admin': {
- 'apply_to': 'guest-admin-password',
- 'change_4_characters': 'enable',
- 'expire_day': '5',
- 'expire_status': 'enable',
- 'min_lower_case_letter': '7',
- 'min_non_alphanumeric': '8',
- 'min_number': '9',
- 'min_upper_case_letter': '10',
- 'minimum_length': '11',
- 'reuse_password': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_password_policy_guest_admin.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'apply-to': 'guest-admin-password',
- 'change-4-characters': 'enable',
- 'expire-day': '5',
- 'expire-status': 'enable',
- 'min-lower-case-letter': '7',
- 'min-non-alphanumeric': '8',
- 'min-number': '9',
- 'min-upper-case-letter': '10',
- 'minimum-length': '11',
- 'reuse-password': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'password-policy-guest-admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_password_policy_guest_admin_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_password_policy_guest_admin': {
- 'random_attribute_not_valid': 'tag',
- 'apply_to': 'guest-admin-password',
- 'change_4_characters': 'enable',
- 'expire_day': '5',
- 'expire_status': 'enable',
- 'min_lower_case_letter': '7',
- 'min_non_alphanumeric': '8',
- 'min_number': '9',
- 'min_upper_case_letter': '10',
- 'minimum_length': '11',
- 'reuse_password': 'enable',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_password_policy_guest_admin.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'apply-to': 'guest-admin-password',
- 'change-4-characters': 'enable',
- 'expire-day': '5',
- 'expire-status': 'enable',
- 'min-lower-case-letter': '7',
- 'min-non-alphanumeric': '8',
- 'min-number': '9',
- 'min-upper-case-letter': '10',
- 'minimum-length': '11',
- 'reuse-password': 'enable',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'password-policy-guest-admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_pppoe_interface.py b/test/units/modules/network/fortios/test_fortios_system_pppoe_interface.py
deleted file mode 100644
index 47b9acda92..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_pppoe_interface.py
+++ /dev/null
@@ -1,349 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_pppoe_interface
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_pppoe_interface.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_pppoe_interface_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_pppoe_interface': {
- 'ac_name': 'test_value_3',
- 'auth_type': 'auto',
- 'device': 'test_value_5',
- 'dial_on_demand': 'enable',
- 'disc_retry_timeout': '7',
- 'idle_timeout': '8',
- 'ipunnumbered': 'test_value_9',
- 'ipv6': 'enable',
- 'lcp_echo_interval': '11',
- 'lcp_max_echo_fails': '12',
- 'name': 'default_name_13',
- 'padt_retry_timeout': '14',
- 'password': 'test_value_15',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'service_name': 'test_value_17',
- 'username': 'test_value_18'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_pppoe_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ac-name': 'test_value_3',
- 'auth-type': 'auto',
- 'device': 'test_value_5',
- 'dial-on-demand': 'enable',
- 'disc-retry-timeout': '7',
- 'idle-timeout': '8',
- 'ipunnumbered': 'test_value_9',
- 'ipv6': 'enable',
- 'lcp-echo-interval': '11',
- 'lcp-max-echo-fails': '12',
- 'name': 'default_name_13',
- 'padt-retry-timeout': '14',
- 'password': 'test_value_15',
- 'pppoe-unnumbered-negotiate': 'enable',
- 'service-name': 'test_value_17',
- 'username': 'test_value_18'
- }
-
- set_method_mock.assert_called_with('system', 'pppoe-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_pppoe_interface_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_pppoe_interface': {
- 'ac_name': 'test_value_3',
- 'auth_type': 'auto',
- 'device': 'test_value_5',
- 'dial_on_demand': 'enable',
- 'disc_retry_timeout': '7',
- 'idle_timeout': '8',
- 'ipunnumbered': 'test_value_9',
- 'ipv6': 'enable',
- 'lcp_echo_interval': '11',
- 'lcp_max_echo_fails': '12',
- 'name': 'default_name_13',
- 'padt_retry_timeout': '14',
- 'password': 'test_value_15',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'service_name': 'test_value_17',
- 'username': 'test_value_18'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_pppoe_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ac-name': 'test_value_3',
- 'auth-type': 'auto',
- 'device': 'test_value_5',
- 'dial-on-demand': 'enable',
- 'disc-retry-timeout': '7',
- 'idle-timeout': '8',
- 'ipunnumbered': 'test_value_9',
- 'ipv6': 'enable',
- 'lcp-echo-interval': '11',
- 'lcp-max-echo-fails': '12',
- 'name': 'default_name_13',
- 'padt-retry-timeout': '14',
- 'password': 'test_value_15',
- 'pppoe-unnumbered-negotiate': 'enable',
- 'service-name': 'test_value_17',
- 'username': 'test_value_18'
- }
-
- set_method_mock.assert_called_with('system', 'pppoe-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_pppoe_interface_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_pppoe_interface': {
- 'ac_name': 'test_value_3',
- 'auth_type': 'auto',
- 'device': 'test_value_5',
- 'dial_on_demand': 'enable',
- 'disc_retry_timeout': '7',
- 'idle_timeout': '8',
- 'ipunnumbered': 'test_value_9',
- 'ipv6': 'enable',
- 'lcp_echo_interval': '11',
- 'lcp_max_echo_fails': '12',
- 'name': 'default_name_13',
- 'padt_retry_timeout': '14',
- 'password': 'test_value_15',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'service_name': 'test_value_17',
- 'username': 'test_value_18'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_pppoe_interface.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'pppoe-interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_pppoe_interface_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_pppoe_interface': {
- 'ac_name': 'test_value_3',
- 'auth_type': 'auto',
- 'device': 'test_value_5',
- 'dial_on_demand': 'enable',
- 'disc_retry_timeout': '7',
- 'idle_timeout': '8',
- 'ipunnumbered': 'test_value_9',
- 'ipv6': 'enable',
- 'lcp_echo_interval': '11',
- 'lcp_max_echo_fails': '12',
- 'name': 'default_name_13',
- 'padt_retry_timeout': '14',
- 'password': 'test_value_15',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'service_name': 'test_value_17',
- 'username': 'test_value_18'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_pppoe_interface.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'pppoe-interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_pppoe_interface_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_pppoe_interface': {
- 'ac_name': 'test_value_3',
- 'auth_type': 'auto',
- 'device': 'test_value_5',
- 'dial_on_demand': 'enable',
- 'disc_retry_timeout': '7',
- 'idle_timeout': '8',
- 'ipunnumbered': 'test_value_9',
- 'ipv6': 'enable',
- 'lcp_echo_interval': '11',
- 'lcp_max_echo_fails': '12',
- 'name': 'default_name_13',
- 'padt_retry_timeout': '14',
- 'password': 'test_value_15',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'service_name': 'test_value_17',
- 'username': 'test_value_18'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_pppoe_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ac-name': 'test_value_3',
- 'auth-type': 'auto',
- 'device': 'test_value_5',
- 'dial-on-demand': 'enable',
- 'disc-retry-timeout': '7',
- 'idle-timeout': '8',
- 'ipunnumbered': 'test_value_9',
- 'ipv6': 'enable',
- 'lcp-echo-interval': '11',
- 'lcp-max-echo-fails': '12',
- 'name': 'default_name_13',
- 'padt-retry-timeout': '14',
- 'password': 'test_value_15',
- 'pppoe-unnumbered-negotiate': 'enable',
- 'service-name': 'test_value_17',
- 'username': 'test_value_18'
- }
-
- set_method_mock.assert_called_with('system', 'pppoe-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_pppoe_interface_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_pppoe_interface': {
- 'random_attribute_not_valid': 'tag',
- 'ac_name': 'test_value_3',
- 'auth_type': 'auto',
- 'device': 'test_value_5',
- 'dial_on_demand': 'enable',
- 'disc_retry_timeout': '7',
- 'idle_timeout': '8',
- 'ipunnumbered': 'test_value_9',
- 'ipv6': 'enable',
- 'lcp_echo_interval': '11',
- 'lcp_max_echo_fails': '12',
- 'name': 'default_name_13',
- 'padt_retry_timeout': '14',
- 'password': 'test_value_15',
- 'pppoe_unnumbered_negotiate': 'enable',
- 'service_name': 'test_value_17',
- 'username': 'test_value_18'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_pppoe_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ac-name': 'test_value_3',
- 'auth-type': 'auto',
- 'device': 'test_value_5',
- 'dial-on-demand': 'enable',
- 'disc-retry-timeout': '7',
- 'idle-timeout': '8',
- 'ipunnumbered': 'test_value_9',
- 'ipv6': 'enable',
- 'lcp-echo-interval': '11',
- 'lcp-max-echo-fails': '12',
- 'name': 'default_name_13',
- 'padt-retry-timeout': '14',
- 'password': 'test_value_15',
- 'pppoe-unnumbered-negotiate': 'enable',
- 'service-name': 'test_value_17',
- 'username': 'test_value_18'
- }
-
- set_method_mock.assert_called_with('system', 'pppoe-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_probe_response.py b/test/units/modules/network/fortios/test_fortios_system_probe_response.py
deleted file mode 100644
index 9d1c9713c7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_probe_response.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_probe_response
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_probe_response.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_probe_response_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_probe_response': {
- 'http_probe_value': 'test_value_3',
- 'mode': 'none',
- 'password': 'test_value_5',
- 'port': '6',
- 'security_mode': 'none',
- 'timeout': '8',
- 'ttl_mode': 'reinit'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_probe_response.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'http-probe-value': 'test_value_3',
- 'mode': 'none',
- 'password': 'test_value_5',
- 'port': '6',
- 'security-mode': 'none',
- 'timeout': '8',
- 'ttl-mode': 'reinit'
- }
-
- set_method_mock.assert_called_with('system', 'probe-response', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_probe_response_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_probe_response': {
- 'http_probe_value': 'test_value_3',
- 'mode': 'none',
- 'password': 'test_value_5',
- 'port': '6',
- 'security_mode': 'none',
- 'timeout': '8',
- 'ttl_mode': 'reinit'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_probe_response.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'http-probe-value': 'test_value_3',
- 'mode': 'none',
- 'password': 'test_value_5',
- 'port': '6',
- 'security-mode': 'none',
- 'timeout': '8',
- 'ttl-mode': 'reinit'
- }
-
- set_method_mock.assert_called_with('system', 'probe-response', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_probe_response_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_probe_response': {
- 'http_probe_value': 'test_value_3',
- 'mode': 'none',
- 'password': 'test_value_5',
- 'port': '6',
- 'security_mode': 'none',
- 'timeout': '8',
- 'ttl_mode': 'reinit'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_probe_response.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'http-probe-value': 'test_value_3',
- 'mode': 'none',
- 'password': 'test_value_5',
- 'port': '6',
- 'security-mode': 'none',
- 'timeout': '8',
- 'ttl-mode': 'reinit'
- }
-
- set_method_mock.assert_called_with('system', 'probe-response', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_probe_response_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_probe_response': {
- 'random_attribute_not_valid': 'tag',
- 'http_probe_value': 'test_value_3',
- 'mode': 'none',
- 'password': 'test_value_5',
- 'port': '6',
- 'security_mode': 'none',
- 'timeout': '8',
- 'ttl_mode': 'reinit'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_probe_response.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'http-probe-value': 'test_value_3',
- 'mode': 'none',
- 'password': 'test_value_5',
- 'port': '6',
- 'security-mode': 'none',
- 'timeout': '8',
- 'ttl-mode': 'reinit'
- }
-
- set_method_mock.assert_called_with('system', 'probe-response', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_proxy_arp.py b/test/units/modules/network/fortios/test_fortios_system_proxy_arp.py
deleted file mode 100644
index 6642e43f5a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_proxy_arp.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_proxy_arp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_proxy_arp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_proxy_arp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_proxy_arp': {
- 'end_ip': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'ip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_proxy_arp.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'end-ip': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'ip': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'proxy-arp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_proxy_arp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_proxy_arp': {
- 'end_ip': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'ip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_proxy_arp.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'end-ip': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'ip': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'proxy-arp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_proxy_arp_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_proxy_arp': {
- 'end_ip': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'ip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_proxy_arp.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'proxy-arp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_proxy_arp_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_proxy_arp': {
- 'end_ip': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'ip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_proxy_arp.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'proxy-arp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_proxy_arp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_proxy_arp': {
- 'end_ip': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'ip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_proxy_arp.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'end-ip': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'ip': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'proxy-arp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_proxy_arp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_proxy_arp': {
- 'random_attribute_not_valid': 'tag',
- 'end_ip': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'ip': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_proxy_arp.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'end-ip': 'test_value_3',
- 'id': '4',
- 'interface': 'test_value_5',
- 'ip': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system', 'proxy-arp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_admin.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_admin.py
deleted file mode 100644
index a50bfd9b75..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_admin.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_admin
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_admin.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_admin_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_admin': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_admin.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_admin_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_admin': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_admin.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_admin_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_admin': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_admin.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'admin', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_admin_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_admin': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_admin.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'admin', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_admin_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_admin': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_admin.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_admin_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_admin': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_admin.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'admin', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_alertmail.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_alertmail.py
deleted file mode 100644
index 3d62d1ee37..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_alertmail.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_alertmail
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_alertmail.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_alertmail_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_alertmail': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_alertmail.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'alertmail', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_alertmail_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_alertmail': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_alertmail.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'alertmail', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_alertmail_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_alertmail': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_alertmail.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'alertmail', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_alertmail_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_alertmail': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_alertmail.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'alertmail', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_alertmail_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_alertmail': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_alertmail.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'alertmail', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_alertmail_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_alertmail': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_alertmail.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'alertmail', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_auth.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_auth.py
deleted file mode 100644
index bbf514eb6c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_auth.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_auth
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_auth.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_auth_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_auth': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_auth.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'auth', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_auth_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_auth': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_auth.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'auth', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_auth_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_auth': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_auth.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'auth', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_auth_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_auth': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_auth.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'auth', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_auth_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_auth': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_auth.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'auth', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_auth_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_auth': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_auth.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'auth', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_device_detection_portal.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_device_detection_portal.py
deleted file mode 100644
index 7b4f161f1b..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_device_detection_portal.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_device_detection_portal
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_device_detection_portal.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_device_detection_portal_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_device_detection_portal': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_device_detection_portal.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'device-detection-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_device_detection_portal_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_device_detection_portal': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_device_detection_portal.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'device-detection-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_device_detection_portal_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_device_detection_portal': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_device_detection_portal.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'device-detection-portal', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_device_detection_portal_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_device_detection_portal': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_device_detection_portal.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'device-detection-portal', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_device_detection_portal_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_device_detection_portal': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_device_detection_portal.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'device-detection-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_device_detection_portal_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_device_detection_portal': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_device_detection_portal.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'device-detection-portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_ec.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_ec.py
deleted file mode 100644
index 172fd65bfd..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_ec.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_ec
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_ec.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_ec_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_ec': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ec.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'ec', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_ec_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_ec': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ec.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'ec', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_ec_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_ec': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ec.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'ec', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_ec_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_ec': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ec.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'ec', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_ec_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_ec': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ec.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'ec', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_ec_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_ec': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ec.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'ec', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_fortiguard_wf.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_fortiguard_wf.py
deleted file mode 100644
index dcab7bfd74..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_fortiguard_wf.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_fortiguard_wf
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_fortiguard_wf.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_fortiguard_wf_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_fortiguard_wf': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_fortiguard_wf.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'fortiguard-wf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_fortiguard_wf_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_fortiguard_wf': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_fortiguard_wf.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'fortiguard-wf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_fortiguard_wf_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_fortiguard_wf': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_fortiguard_wf.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'fortiguard-wf', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_fortiguard_wf_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_fortiguard_wf': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_fortiguard_wf.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'fortiguard-wf', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_fortiguard_wf_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_fortiguard_wf': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_fortiguard_wf.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'fortiguard-wf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_fortiguard_wf_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_fortiguard_wf': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_fortiguard_wf.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'fortiguard-wf', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_ftp.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_ftp.py
deleted file mode 100644
index 240c7e0c99..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_ftp.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_ftp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_ftp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_ftp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_ftp': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ftp.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'ftp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_ftp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_ftp': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ftp.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'ftp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_ftp_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_ftp': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ftp.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'ftp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_ftp_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_ftp': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ftp.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'ftp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_ftp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_ftp': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ftp.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'ftp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_ftp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_ftp': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_ftp.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'ftp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_group.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_group.py
deleted file mode 100644
index bea08ed215..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_group.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_group': {'comment': 'Comment.',
- 'group_type': 'default',
- 'name': 'default_name_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_group.fortios_system(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment.',
- 'group-type': 'default',
- 'name': 'default_name_5',
-
- }
-
- set_method_mock.assert_called_with('system', 'replacemsg-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_group': {'comment': 'Comment.',
- 'group_type': 'default',
- 'name': 'default_name_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_group.fortios_system(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment.',
- 'group-type': 'default',
- 'name': 'default_name_5',
-
- }
-
- set_method_mock.assert_called_with('system', 'replacemsg-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_group': {'comment': 'Comment.',
- 'group_type': 'default',
- 'name': 'default_name_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_group.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'replacemsg-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_group': {'comment': 'Comment.',
- 'group_type': 'default',
- 'name': 'default_name_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_group.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'replacemsg-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_group': {'comment': 'Comment.',
- 'group_type': 'default',
- 'name': 'default_name_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_group.fortios_system(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment.',
- 'group-type': 'default',
- 'name': 'default_name_5',
-
- }
-
- set_method_mock.assert_called_with('system', 'replacemsg-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_group': {
- 'random_attribute_not_valid': 'tag', 'comment': 'Comment.',
- 'group_type': 'default',
- 'name': 'default_name_5',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_group.fortios_system(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment.',
- 'group-type': 'default',
- 'name': 'default_name_5',
-
- }
-
- set_method_mock.assert_called_with('system', 'replacemsg-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_http.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_http.py
deleted file mode 100644
index d6651ffed8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_http.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_http
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_http.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_http_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_http': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_http.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'http', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_http_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_http': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_http.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'http', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_http_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_http': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_http.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'http', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_http_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_http': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_http.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'http', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_http_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_http': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_http.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'http', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_http_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_http': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_http.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'http', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_icap.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_icap.py
deleted file mode 100644
index cfc4870724..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_icap.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_icap
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_icap.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_icap_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_icap': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_icap.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'icap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_icap_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_icap': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_icap.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'icap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_icap_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_icap': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_icap.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'icap', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_icap_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_icap': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_icap.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'icap', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_icap_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_icap': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_icap.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'icap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_icap_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_icap': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_icap.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'icap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_image.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_image.py
deleted file mode 100644
index 5b9f0cac42..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_image.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_image
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_image.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_image_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_image': {
- 'image_base64': 'test_value_3',
- 'image_type': 'gif',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_image.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'image-base64': 'test_value_3',
- 'image-type': 'gif',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'replacemsg-image', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_image_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_image': {
- 'image_base64': 'test_value_3',
- 'image_type': 'gif',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_image.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'image-base64': 'test_value_3',
- 'image-type': 'gif',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'replacemsg-image', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_image_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_image': {
- 'image_base64': 'test_value_3',
- 'image_type': 'gif',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_image.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'replacemsg-image', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_image_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_image': {
- 'image_base64': 'test_value_3',
- 'image_type': 'gif',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_image.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'replacemsg-image', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_image_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_image': {
- 'image_base64': 'test_value_3',
- 'image_type': 'gif',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_image.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'image-base64': 'test_value_3',
- 'image-type': 'gif',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'replacemsg-image', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_image_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_image': {
- 'random_attribute_not_valid': 'tag',
- 'image_base64': 'test_value_3',
- 'image_type': 'gif',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_image.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'image-base64': 'test_value_3',
- 'image-type': 'gif',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('system', 'replacemsg-image', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_mail.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_mail.py
deleted file mode 100644
index fffb32512a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_mail.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_mail
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_mail.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_mail_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_mail': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_mail.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'mail', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_mail_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_mail': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_mail.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'mail', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_mail_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_mail': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_mail.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'mail', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_mail_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_mail': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_mail.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'mail', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_mail_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_mail': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_mail.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'mail', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_mail_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_mail': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_mail.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'mail', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_nac_quar.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_nac_quar.py
deleted file mode 100644
index b09bbad08a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_nac_quar.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_nac_quar
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_nac_quar.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_nac_quar_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_nac_quar': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nac_quar.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'nac-quar', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_nac_quar_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_nac_quar': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nac_quar.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'nac-quar', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_nac_quar_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_nac_quar': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nac_quar.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'nac-quar', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_nac_quar_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_nac_quar': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nac_quar.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'nac-quar', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_nac_quar_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_nac_quar': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nac_quar.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'nac-quar', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_nac_quar_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_nac_quar': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nac_quar.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'nac-quar', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_nntp.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_nntp.py
deleted file mode 100644
index ce5b7adef1..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_nntp.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_nntp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_nntp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_nntp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_nntp': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nntp.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'nntp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_nntp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_nntp': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nntp.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'nntp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_nntp_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_nntp': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nntp.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'nntp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_nntp_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_nntp': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nntp.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'nntp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_nntp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_nntp': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nntp.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'nntp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_nntp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_nntp': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_nntp.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'nntp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_spam.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_spam.py
deleted file mode 100644
index 7b2b2c2acf..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_spam.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_spam
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_spam.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_spam_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_spam': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_spam.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'spam', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_spam_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_spam': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_spam.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'spam', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_spam_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_spam': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_spam.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'spam', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_spam_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_spam': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_spam.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'spam', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_spam_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_spam': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_spam.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'spam', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_spam_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_spam': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_spam.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'spam', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_sslvpn.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_sslvpn.py
deleted file mode 100644
index b22ce48b62..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_sslvpn.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_sslvpn
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_sslvpn.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_sslvpn_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_sslvpn': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_sslvpn.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'sslvpn', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_sslvpn_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_sslvpn': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_sslvpn.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'sslvpn', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_sslvpn_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_sslvpn': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_sslvpn.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'sslvpn', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_sslvpn_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_sslvpn': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_sslvpn.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'sslvpn', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_sslvpn_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_sslvpn': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_sslvpn.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'sslvpn', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_sslvpn_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_sslvpn': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_sslvpn.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'sslvpn', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_traffic_quota.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_traffic_quota.py
deleted file mode 100644
index 9ea80be75f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_traffic_quota.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_traffic_quota
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_traffic_quota.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_traffic_quota_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_traffic_quota': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_traffic_quota.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'traffic-quota', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_traffic_quota_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_traffic_quota': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_traffic_quota.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'traffic-quota', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_traffic_quota_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_traffic_quota': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_traffic_quota.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'traffic-quota', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_traffic_quota_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_traffic_quota': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_traffic_quota.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'traffic-quota', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_traffic_quota_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_traffic_quota': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_traffic_quota.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'traffic-quota', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_traffic_quota_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_traffic_quota': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_traffic_quota.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'traffic-quota', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_utm.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_utm.py
deleted file mode 100644
index 5448f054d7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_utm.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_utm
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_utm.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_utm_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_utm': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_utm.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'utm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_utm_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_utm': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_utm.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'utm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_utm_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_utm': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_utm.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'utm', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_utm_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_utm': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_utm.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'utm', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_utm_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_utm': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_utm.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'utm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_utm_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_utm': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_utm.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'utm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_replacemsg_webproxy.py b/test/units/modules/network/fortios/test_fortios_system_replacemsg_webproxy.py
deleted file mode 100644
index 60b1469432..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_replacemsg_webproxy.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_replacemsg_webproxy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_replacemsg_webproxy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_replacemsg_webproxy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_webproxy': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_webproxy.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'webproxy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_webproxy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_webproxy': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_webproxy.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'webproxy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_webproxy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_webproxy': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_webproxy.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'webproxy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_replacemsg_webproxy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_replacemsg_webproxy': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_webproxy.fortios_system_replacemsg(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.replacemsg', 'webproxy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_replacemsg_webproxy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_webproxy': {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_webproxy.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'webproxy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_replacemsg_webproxy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_replacemsg_webproxy': {
- 'random_attribute_not_valid': 'tag',
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg_type': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_replacemsg_webproxy.fortios_system_replacemsg(input_data, fos_instance)
-
- expected_data = {
- 'buffer': 'test_value_3',
- 'format': 'none',
- 'header': 'none',
- 'msg-type': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('system.replacemsg', 'webproxy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_resource_limits.py b/test/units/modules/network/fortios/test_fortios_system_resource_limits.py
deleted file mode 100644
index da1f19f694..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_resource_limits.py
+++ /dev/null
@@ -1,287 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_resource_limits
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_resource_limits.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_resource_limits_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_resource_limits': {
- 'custom_service': '3',
- 'dialup_tunnel': '4',
- 'firewall_address': '5',
- 'firewall_addrgrp': '6',
- 'firewall_policy': '7',
- 'ipsec_phase1': '8',
- 'ipsec_phase1_interface': '9',
- 'ipsec_phase2': '10',
- 'ipsec_phase2_interface': '11',
- 'log_disk_quota': '12',
- 'onetime_schedule': '13',
- 'proxy': '14',
- 'recurring_schedule': '15',
- 'service_group': '16',
- 'session': '17',
- 'sslvpn': '18',
- 'user': '19',
- 'user_group': '20'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_resource_limits.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'custom-service': '3',
- 'dialup-tunnel': '4',
- 'firewall-address': '5',
- 'firewall-addrgrp': '6',
- 'firewall-policy': '7',
- 'ipsec-phase1': '8',
- 'ipsec-phase1-interface': '9',
- 'ipsec-phase2': '10',
- 'ipsec-phase2-interface': '11',
- 'log-disk-quota': '12',
- 'onetime-schedule': '13',
- 'proxy': '14',
- 'recurring-schedule': '15',
- 'service-group': '16',
- 'session': '17',
- 'sslvpn': '18',
- 'user': '19',
- 'user-group': '20'
- }
-
- set_method_mock.assert_called_with('system', 'resource-limits', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_resource_limits_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_resource_limits': {
- 'custom_service': '3',
- 'dialup_tunnel': '4',
- 'firewall_address': '5',
- 'firewall_addrgrp': '6',
- 'firewall_policy': '7',
- 'ipsec_phase1': '8',
- 'ipsec_phase1_interface': '9',
- 'ipsec_phase2': '10',
- 'ipsec_phase2_interface': '11',
- 'log_disk_quota': '12',
- 'onetime_schedule': '13',
- 'proxy': '14',
- 'recurring_schedule': '15',
- 'service_group': '16',
- 'session': '17',
- 'sslvpn': '18',
- 'user': '19',
- 'user_group': '20'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_resource_limits.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'custom-service': '3',
- 'dialup-tunnel': '4',
- 'firewall-address': '5',
- 'firewall-addrgrp': '6',
- 'firewall-policy': '7',
- 'ipsec-phase1': '8',
- 'ipsec-phase1-interface': '9',
- 'ipsec-phase2': '10',
- 'ipsec-phase2-interface': '11',
- 'log-disk-quota': '12',
- 'onetime-schedule': '13',
- 'proxy': '14',
- 'recurring-schedule': '15',
- 'service-group': '16',
- 'session': '17',
- 'sslvpn': '18',
- 'user': '19',
- 'user-group': '20'
- }
-
- set_method_mock.assert_called_with('system', 'resource-limits', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_resource_limits_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_resource_limits': {
- 'custom_service': '3',
- 'dialup_tunnel': '4',
- 'firewall_address': '5',
- 'firewall_addrgrp': '6',
- 'firewall_policy': '7',
- 'ipsec_phase1': '8',
- 'ipsec_phase1_interface': '9',
- 'ipsec_phase2': '10',
- 'ipsec_phase2_interface': '11',
- 'log_disk_quota': '12',
- 'onetime_schedule': '13',
- 'proxy': '14',
- 'recurring_schedule': '15',
- 'service_group': '16',
- 'session': '17',
- 'sslvpn': '18',
- 'user': '19',
- 'user_group': '20'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_resource_limits.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'custom-service': '3',
- 'dialup-tunnel': '4',
- 'firewall-address': '5',
- 'firewall-addrgrp': '6',
- 'firewall-policy': '7',
- 'ipsec-phase1': '8',
- 'ipsec-phase1-interface': '9',
- 'ipsec-phase2': '10',
- 'ipsec-phase2-interface': '11',
- 'log-disk-quota': '12',
- 'onetime-schedule': '13',
- 'proxy': '14',
- 'recurring-schedule': '15',
- 'service-group': '16',
- 'session': '17',
- 'sslvpn': '18',
- 'user': '19',
- 'user-group': '20'
- }
-
- set_method_mock.assert_called_with('system', 'resource-limits', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_resource_limits_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_resource_limits': {
- 'random_attribute_not_valid': 'tag',
- 'custom_service': '3',
- 'dialup_tunnel': '4',
- 'firewall_address': '5',
- 'firewall_addrgrp': '6',
- 'firewall_policy': '7',
- 'ipsec_phase1': '8',
- 'ipsec_phase1_interface': '9',
- 'ipsec_phase2': '10',
- 'ipsec_phase2_interface': '11',
- 'log_disk_quota': '12',
- 'onetime_schedule': '13',
- 'proxy': '14',
- 'recurring_schedule': '15',
- 'service_group': '16',
- 'session': '17',
- 'sslvpn': '18',
- 'user': '19',
- 'user_group': '20'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_resource_limits.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'custom-service': '3',
- 'dialup-tunnel': '4',
- 'firewall-address': '5',
- 'firewall-addrgrp': '6',
- 'firewall-policy': '7',
- 'ipsec-phase1': '8',
- 'ipsec-phase1-interface': '9',
- 'ipsec-phase2': '10',
- 'ipsec-phase2-interface': '11',
- 'log-disk-quota': '12',
- 'onetime-schedule': '13',
- 'proxy': '14',
- 'recurring-schedule': '15',
- 'service-group': '16',
- 'session': '17',
- 'sslvpn': '18',
- 'user': '19',
- 'user-group': '20'
- }
-
- set_method_mock.assert_called_with('system', 'resource-limits', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_sdn_connector.py b/test/units/modules/network/fortios/test_fortios_system_sdn_connector.py
deleted file mode 100644
index 7d4ef82a43..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_sdn_connector.py
+++ /dev/null
@@ -1,489 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_sdn_connector
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_sdn_connector.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_sdn_connector_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sdn_connector': {
- 'access_key': 'test_value_3',
- 'azure_region': 'global',
- 'client_id': 'test_value_5',
- 'client_secret': 'test_value_6',
- 'compartment_id': 'test_value_7',
- 'gcp_project': 'test_value_8',
- 'key_passwd': 'test_value_9',
- 'login_endpoint': 'test_value_10',
- 'name': 'default_name_11',
- 'oci_cert': 'test_value_12',
- 'oci_fingerprint': 'test_value_13',
- 'oci_region': 'phoenix',
- 'password': 'test_value_15',
- 'private_key': 'test_value_16',
- 'region': 'test_value_17',
- 'resource_group': 'test_value_18',
- 'resource_url': 'test_value_19',
- 'secret_key': 'test_value_20',
- 'server': '192.168.100.21',
- 'server_port': '22',
- 'service_account': 'test_value_23',
- 'status': 'disable',
- 'subscription_id': 'test_value_25',
- 'tenant_id': 'test_value_26',
- 'type': 'aci',
- 'update_interval': '28',
- 'use_metadata_iam': 'disable',
- 'user_id': 'test_value_30',
- 'username': 'test_value_31',
- 'vpc_id': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sdn_connector.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'access-key': 'test_value_3',
- 'azure-region': 'global',
- 'client-id': 'test_value_5',
- 'client-secret': 'test_value_6',
- 'compartment-id': 'test_value_7',
- 'gcp-project': 'test_value_8',
- 'key-passwd': 'test_value_9',
- 'login-endpoint': 'test_value_10',
- 'name': 'default_name_11',
- 'oci-cert': 'test_value_12',
- 'oci-fingerprint': 'test_value_13',
- 'oci-region': 'phoenix',
- 'password': 'test_value_15',
- 'private-key': 'test_value_16',
- 'region': 'test_value_17',
- 'resource-group': 'test_value_18',
- 'resource-url': 'test_value_19',
- 'secret-key': 'test_value_20',
- 'server': '192.168.100.21',
- 'server-port': '22',
- 'service-account': 'test_value_23',
- 'status': 'disable',
- 'subscription-id': 'test_value_25',
- 'tenant-id': 'test_value_26',
- 'type': 'aci',
- 'update-interval': '28',
- 'use-metadata-iam': 'disable',
- 'user-id': 'test_value_30',
- 'username': 'test_value_31',
- 'vpc-id': 'test_value_32'
- }
-
- set_method_mock.assert_called_with('system', 'sdn-connector', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_sdn_connector_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sdn_connector': {
- 'access_key': 'test_value_3',
- 'azure_region': 'global',
- 'client_id': 'test_value_5',
- 'client_secret': 'test_value_6',
- 'compartment_id': 'test_value_7',
- 'gcp_project': 'test_value_8',
- 'key_passwd': 'test_value_9',
- 'login_endpoint': 'test_value_10',
- 'name': 'default_name_11',
- 'oci_cert': 'test_value_12',
- 'oci_fingerprint': 'test_value_13',
- 'oci_region': 'phoenix',
- 'password': 'test_value_15',
- 'private_key': 'test_value_16',
- 'region': 'test_value_17',
- 'resource_group': 'test_value_18',
- 'resource_url': 'test_value_19',
- 'secret_key': 'test_value_20',
- 'server': '192.168.100.21',
- 'server_port': '22',
- 'service_account': 'test_value_23',
- 'status': 'disable',
- 'subscription_id': 'test_value_25',
- 'tenant_id': 'test_value_26',
- 'type': 'aci',
- 'update_interval': '28',
- 'use_metadata_iam': 'disable',
- 'user_id': 'test_value_30',
- 'username': 'test_value_31',
- 'vpc_id': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sdn_connector.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'access-key': 'test_value_3',
- 'azure-region': 'global',
- 'client-id': 'test_value_5',
- 'client-secret': 'test_value_6',
- 'compartment-id': 'test_value_7',
- 'gcp-project': 'test_value_8',
- 'key-passwd': 'test_value_9',
- 'login-endpoint': 'test_value_10',
- 'name': 'default_name_11',
- 'oci-cert': 'test_value_12',
- 'oci-fingerprint': 'test_value_13',
- 'oci-region': 'phoenix',
- 'password': 'test_value_15',
- 'private-key': 'test_value_16',
- 'region': 'test_value_17',
- 'resource-group': 'test_value_18',
- 'resource-url': 'test_value_19',
- 'secret-key': 'test_value_20',
- 'server': '192.168.100.21',
- 'server-port': '22',
- 'service-account': 'test_value_23',
- 'status': 'disable',
- 'subscription-id': 'test_value_25',
- 'tenant-id': 'test_value_26',
- 'type': 'aci',
- 'update-interval': '28',
- 'use-metadata-iam': 'disable',
- 'user-id': 'test_value_30',
- 'username': 'test_value_31',
- 'vpc-id': 'test_value_32'
- }
-
- set_method_mock.assert_called_with('system', 'sdn-connector', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_sdn_connector_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_sdn_connector': {
- 'access_key': 'test_value_3',
- 'azure_region': 'global',
- 'client_id': 'test_value_5',
- 'client_secret': 'test_value_6',
- 'compartment_id': 'test_value_7',
- 'gcp_project': 'test_value_8',
- 'key_passwd': 'test_value_9',
- 'login_endpoint': 'test_value_10',
- 'name': 'default_name_11',
- 'oci_cert': 'test_value_12',
- 'oci_fingerprint': 'test_value_13',
- 'oci_region': 'phoenix',
- 'password': 'test_value_15',
- 'private_key': 'test_value_16',
- 'region': 'test_value_17',
- 'resource_group': 'test_value_18',
- 'resource_url': 'test_value_19',
- 'secret_key': 'test_value_20',
- 'server': '192.168.100.21',
- 'server_port': '22',
- 'service_account': 'test_value_23',
- 'status': 'disable',
- 'subscription_id': 'test_value_25',
- 'tenant_id': 'test_value_26',
- 'type': 'aci',
- 'update_interval': '28',
- 'use_metadata_iam': 'disable',
- 'user_id': 'test_value_30',
- 'username': 'test_value_31',
- 'vpc_id': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sdn_connector.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'sdn-connector', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_sdn_connector_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_sdn_connector': {
- 'access_key': 'test_value_3',
- 'azure_region': 'global',
- 'client_id': 'test_value_5',
- 'client_secret': 'test_value_6',
- 'compartment_id': 'test_value_7',
- 'gcp_project': 'test_value_8',
- 'key_passwd': 'test_value_9',
- 'login_endpoint': 'test_value_10',
- 'name': 'default_name_11',
- 'oci_cert': 'test_value_12',
- 'oci_fingerprint': 'test_value_13',
- 'oci_region': 'phoenix',
- 'password': 'test_value_15',
- 'private_key': 'test_value_16',
- 'region': 'test_value_17',
- 'resource_group': 'test_value_18',
- 'resource_url': 'test_value_19',
- 'secret_key': 'test_value_20',
- 'server': '192.168.100.21',
- 'server_port': '22',
- 'service_account': 'test_value_23',
- 'status': 'disable',
- 'subscription_id': 'test_value_25',
- 'tenant_id': 'test_value_26',
- 'type': 'aci',
- 'update_interval': '28',
- 'use_metadata_iam': 'disable',
- 'user_id': 'test_value_30',
- 'username': 'test_value_31',
- 'vpc_id': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sdn_connector.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'sdn-connector', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_sdn_connector_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sdn_connector': {
- 'access_key': 'test_value_3',
- 'azure_region': 'global',
- 'client_id': 'test_value_5',
- 'client_secret': 'test_value_6',
- 'compartment_id': 'test_value_7',
- 'gcp_project': 'test_value_8',
- 'key_passwd': 'test_value_9',
- 'login_endpoint': 'test_value_10',
- 'name': 'default_name_11',
- 'oci_cert': 'test_value_12',
- 'oci_fingerprint': 'test_value_13',
- 'oci_region': 'phoenix',
- 'password': 'test_value_15',
- 'private_key': 'test_value_16',
- 'region': 'test_value_17',
- 'resource_group': 'test_value_18',
- 'resource_url': 'test_value_19',
- 'secret_key': 'test_value_20',
- 'server': '192.168.100.21',
- 'server_port': '22',
- 'service_account': 'test_value_23',
- 'status': 'disable',
- 'subscription_id': 'test_value_25',
- 'tenant_id': 'test_value_26',
- 'type': 'aci',
- 'update_interval': '28',
- 'use_metadata_iam': 'disable',
- 'user_id': 'test_value_30',
- 'username': 'test_value_31',
- 'vpc_id': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sdn_connector.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'access-key': 'test_value_3',
- 'azure-region': 'global',
- 'client-id': 'test_value_5',
- 'client-secret': 'test_value_6',
- 'compartment-id': 'test_value_7',
- 'gcp-project': 'test_value_8',
- 'key-passwd': 'test_value_9',
- 'login-endpoint': 'test_value_10',
- 'name': 'default_name_11',
- 'oci-cert': 'test_value_12',
- 'oci-fingerprint': 'test_value_13',
- 'oci-region': 'phoenix',
- 'password': 'test_value_15',
- 'private-key': 'test_value_16',
- 'region': 'test_value_17',
- 'resource-group': 'test_value_18',
- 'resource-url': 'test_value_19',
- 'secret-key': 'test_value_20',
- 'server': '192.168.100.21',
- 'server-port': '22',
- 'service-account': 'test_value_23',
- 'status': 'disable',
- 'subscription-id': 'test_value_25',
- 'tenant-id': 'test_value_26',
- 'type': 'aci',
- 'update-interval': '28',
- 'use-metadata-iam': 'disable',
- 'user-id': 'test_value_30',
- 'username': 'test_value_31',
- 'vpc-id': 'test_value_32'
- }
-
- set_method_mock.assert_called_with('system', 'sdn-connector', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_sdn_connector_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sdn_connector': {
- 'random_attribute_not_valid': 'tag',
- 'access_key': 'test_value_3',
- 'azure_region': 'global',
- 'client_id': 'test_value_5',
- 'client_secret': 'test_value_6',
- 'compartment_id': 'test_value_7',
- 'gcp_project': 'test_value_8',
- 'key_passwd': 'test_value_9',
- 'login_endpoint': 'test_value_10',
- 'name': 'default_name_11',
- 'oci_cert': 'test_value_12',
- 'oci_fingerprint': 'test_value_13',
- 'oci_region': 'phoenix',
- 'password': 'test_value_15',
- 'private_key': 'test_value_16',
- 'region': 'test_value_17',
- 'resource_group': 'test_value_18',
- 'resource_url': 'test_value_19',
- 'secret_key': 'test_value_20',
- 'server': '192.168.100.21',
- 'server_port': '22',
- 'service_account': 'test_value_23',
- 'status': 'disable',
- 'subscription_id': 'test_value_25',
- 'tenant_id': 'test_value_26',
- 'type': 'aci',
- 'update_interval': '28',
- 'use_metadata_iam': 'disable',
- 'user_id': 'test_value_30',
- 'username': 'test_value_31',
- 'vpc_id': 'test_value_32'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sdn_connector.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'access-key': 'test_value_3',
- 'azure-region': 'global',
- 'client-id': 'test_value_5',
- 'client-secret': 'test_value_6',
- 'compartment-id': 'test_value_7',
- 'gcp-project': 'test_value_8',
- 'key-passwd': 'test_value_9',
- 'login-endpoint': 'test_value_10',
- 'name': 'default_name_11',
- 'oci-cert': 'test_value_12',
- 'oci-fingerprint': 'test_value_13',
- 'oci-region': 'phoenix',
- 'password': 'test_value_15',
- 'private-key': 'test_value_16',
- 'region': 'test_value_17',
- 'resource-group': 'test_value_18',
- 'resource-url': 'test_value_19',
- 'secret-key': 'test_value_20',
- 'server': '192.168.100.21',
- 'server-port': '22',
- 'service-account': 'test_value_23',
- 'status': 'disable',
- 'subscription-id': 'test_value_25',
- 'tenant-id': 'test_value_26',
- 'type': 'aci',
- 'update-interval': '28',
- 'use-metadata-iam': 'disable',
- 'user-id': 'test_value_30',
- 'username': 'test_value_31',
- 'vpc-id': 'test_value_32'
- }
-
- set_method_mock.assert_called_with('system', 'sdn-connector', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_session_helper.py b/test/units/modules/network/fortios/test_fortios_system_session_helper.py
deleted file mode 100644
index b50e6789b8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_session_helper.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_session_helper
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_session_helper.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_session_helper_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_session_helper': {
- 'id': '3',
- 'name': 'default_name_4',
- 'port': '5',
- 'protocol': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_session_helper.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4',
- 'port': '5',
- 'protocol': '6'
- }
-
- set_method_mock.assert_called_with('system', 'session-helper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_session_helper_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_session_helper': {
- 'id': '3',
- 'name': 'default_name_4',
- 'port': '5',
- 'protocol': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_session_helper.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4',
- 'port': '5',
- 'protocol': '6'
- }
-
- set_method_mock.assert_called_with('system', 'session-helper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_session_helper_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_session_helper': {
- 'id': '3',
- 'name': 'default_name_4',
- 'port': '5',
- 'protocol': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_session_helper.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'session-helper', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_session_helper_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_session_helper': {
- 'id': '3',
- 'name': 'default_name_4',
- 'port': '5',
- 'protocol': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_session_helper.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'session-helper', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_session_helper_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_session_helper': {
- 'id': '3',
- 'name': 'default_name_4',
- 'port': '5',
- 'protocol': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_session_helper.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4',
- 'port': '5',
- 'protocol': '6'
- }
-
- set_method_mock.assert_called_with('system', 'session-helper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_session_helper_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_session_helper': {
- 'random_attribute_not_valid': 'tag',
- 'id': '3',
- 'name': 'default_name_4',
- 'port': '5',
- 'protocol': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_session_helper.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4',
- 'port': '5',
- 'protocol': '6'
- }
-
- set_method_mock.assert_called_with('system', 'session-helper', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_session_ttl.py b/test/units/modules/network/fortios/test_fortios_system_session_ttl.py
deleted file mode 100644
index 0896416363..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_session_ttl.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_session_ttl
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_session_ttl.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_session_ttl_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_session_ttl': {
- 'default': 'test_value_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_session_ttl.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'default': 'test_value_3',
-
- }
-
- set_method_mock.assert_called_with('system', 'session-ttl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_session_ttl_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_session_ttl': {
- 'default': 'test_value_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_session_ttl.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'default': 'test_value_3',
-
- }
-
- set_method_mock.assert_called_with('system', 'session-ttl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_session_ttl_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_session_ttl': {
- 'default': 'test_value_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_session_ttl.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'default': 'test_value_3',
-
- }
-
- set_method_mock.assert_called_with('system', 'session-ttl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_session_ttl_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_session_ttl': {
- 'random_attribute_not_valid': 'tag',
- 'default': 'test_value_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_session_ttl.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'default': 'test_value_3',
-
- }
-
- set_method_mock.assert_called_with('system', 'session-ttl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_settings.py b/test/units/modules/network/fortios/test_fortios_system_settings.py
deleted file mode 100644
index 8e81a70c63..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_settings.py
+++ /dev/null
@@ -1,1031 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_settings': {
- 'allow_linkdown_path': 'enable',
- 'allow_subnet_overlap': 'enable',
- 'asymroute': 'enable',
- 'asymroute_icmp': 'enable',
- 'asymroute6': 'enable',
- 'asymroute6_icmp': 'enable',
- 'bfd': 'enable',
- 'bfd_desired_min_tx': '10',
- 'bfd_detect_mult': '11',
- 'bfd_dont_enforce_src_port': 'enable',
- 'bfd_required_min_rx': '13',
- 'block_land_attack': 'disable',
- 'central_nat': 'enable',
- 'comments': 'test_value_16',
- 'compliance_check': 'enable',
- 'default_voip_alg_mode': 'proxy-based',
- 'deny_tcp_with_icmp': 'enable',
- 'device': 'test_value_20',
- 'dhcp_proxy': 'enable',
- 'dhcp_server_ip': 'test_value_22',
- 'dhcp6_server_ip': 'test_value_23',
- 'discovered_device_timeout': '24',
- 'ecmp_max_paths': '25',
- 'email_portal_check_dns': 'disable',
- 'firewall_session_dirty': 'check-all',
- 'fw_session_hairpin': 'enable',
- 'gateway': 'test_value_29',
- 'gateway6': 'test_value_30',
- 'gui_advanced_policy': 'enable',
- 'gui_allow_unnamed_policy': 'enable',
- 'gui_antivirus': 'enable',
- 'gui_ap_profile': 'enable',
- 'gui_application_control': 'enable',
- 'gui_dhcp_advanced': 'enable',
- 'gui_dlp': 'enable',
- 'gui_dns_database': 'enable',
- 'gui_dnsfilter': 'enable',
- 'gui_domain_ip_reputation': 'enable',
- 'gui_dos_policy': 'enable',
- 'gui_dynamic_profile_display': 'enable',
- 'gui_dynamic_routing': 'enable',
- 'gui_email_collection': 'enable',
- 'gui_endpoint_control': 'enable',
- 'gui_endpoint_control_advanced': 'enable',
- 'gui_explicit_proxy': 'enable',
- 'gui_fortiap_split_tunneling': 'enable',
- 'gui_fortiextender_controller': 'enable',
- 'gui_icap': 'enable',
- 'gui_implicit_policy': 'enable',
- 'gui_ips': 'enable',
- 'gui_load_balance': 'enable',
- 'gui_local_in_policy': 'enable',
- 'gui_local_reports': 'enable',
- 'gui_multicast_policy': 'enable',
- 'gui_multiple_interface_policy': 'enable',
- 'gui_multiple_utm_profiles': 'enable',
- 'gui_nat46_64': 'enable',
- 'gui_object_colors': 'enable',
- 'gui_policy_based_ipsec': 'enable',
- 'gui_policy_learning': 'enable',
- 'gui_replacement_message_groups': 'enable',
- 'gui_spamfilter': 'enable',
- 'gui_sslvpn_personal_bookmarks': 'enable',
- 'gui_sslvpn_realms': 'enable',
- 'gui_switch_controller': 'enable',
- 'gui_threat_weight': 'enable',
- 'gui_traffic_shaping': 'enable',
- 'gui_voip_profile': 'enable',
- 'gui_vpn': 'enable',
- 'gui_waf_profile': 'enable',
- 'gui_wan_load_balancing': 'enable',
- 'gui_wanopt_cache': 'enable',
- 'gui_webfilter': 'enable',
- 'gui_webfilter_advanced': 'enable',
- 'gui_wireless_controller': 'enable',
- 'http_external_dest': 'fortiweb',
- 'ike_dn_format': 'with-space',
- 'ike_quick_crash_detect': 'enable',
- 'ike_session_resume': 'enable',
- 'implicit_allow_dns': 'enable',
- 'inspection_mode': 'proxy',
- 'ip': 'test_value_84',
- 'ip6': 'test_value_85',
- 'link_down_access': 'enable',
- 'lldp_transmission': 'enable',
- 'mac_ttl': '88',
- 'manageip': 'test_value_89',
- 'manageip6': 'test_value_90',
- 'multicast_forward': 'enable',
- 'multicast_skip_policy': 'enable',
- 'multicast_ttl_notchange': 'enable',
- 'ngfw_mode': 'profile-based',
- 'opmode': 'nat',
- 'prp_trailer_action': 'enable',
- 'sccp_port': '97',
- 'ses_denied_traffic': 'enable',
- 'sip_helper': 'enable',
- 'sip_nat_trace': 'enable',
- 'sip_ssl_port': '101',
- 'sip_tcp_port': '102',
- 'sip_udp_port': '103',
- 'snat_hairpin_traffic': 'enable',
- 'ssl_ssh_profile': 'test_value_105',
- 'status': 'enable',
- 'strict_src_check': 'enable',
- 'tcp_session_without_syn': 'enable',
- 'utf8_spam_tagging': 'enable',
- 'v4_ecmp_mode': 'source-ip-based',
- 'vpn_stats_log': 'ipsec',
- 'vpn_stats_period': '112',
- 'wccp_cache_engine': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_settings.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-linkdown-path': 'enable',
- 'allow-subnet-overlap': 'enable',
- 'asymroute': 'enable',
- 'asymroute-icmp': 'enable',
- 'asymroute6': 'enable',
- 'asymroute6-icmp': 'enable',
- 'bfd': 'enable',
- 'bfd-desired-min-tx': '10',
- 'bfd-detect-mult': '11',
- 'bfd-dont-enforce-src-port': 'enable',
- 'bfd-required-min-rx': '13',
- 'block-land-attack': 'disable',
- 'central-nat': 'enable',
- 'comments': 'test_value_16',
- 'compliance-check': 'enable',
- 'default-voip-alg-mode': 'proxy-based',
- 'deny-tcp-with-icmp': 'enable',
- 'device': 'test_value_20',
- 'dhcp-proxy': 'enable',
- 'dhcp-server-ip': 'test_value_22',
- 'dhcp6-server-ip': 'test_value_23',
- 'discovered-device-timeout': '24',
- 'ecmp-max-paths': '25',
- 'email-portal-check-dns': 'disable',
- 'firewall-session-dirty': 'check-all',
- 'fw-session-hairpin': 'enable',
- 'gateway': 'test_value_29',
- 'gateway6': 'test_value_30',
- 'gui-advanced-policy': 'enable',
- 'gui-allow-unnamed-policy': 'enable',
- 'gui-antivirus': 'enable',
- 'gui-ap-profile': 'enable',
- 'gui-application-control': 'enable',
- 'gui-dhcp-advanced': 'enable',
- 'gui-dlp': 'enable',
- 'gui-dns-database': 'enable',
- 'gui-dnsfilter': 'enable',
- 'gui-domain-ip-reputation': 'enable',
- 'gui-dos-policy': 'enable',
- 'gui-dynamic-profile-display': 'enable',
- 'gui-dynamic-routing': 'enable',
- 'gui-email-collection': 'enable',
- 'gui-endpoint-control': 'enable',
- 'gui-endpoint-control-advanced': 'enable',
- 'gui-explicit-proxy': 'enable',
- 'gui-fortiap-split-tunneling': 'enable',
- 'gui-fortiextender-controller': 'enable',
- 'gui-icap': 'enable',
- 'gui-implicit-policy': 'enable',
- 'gui-ips': 'enable',
- 'gui-load-balance': 'enable',
- 'gui-local-in-policy': 'enable',
- 'gui-local-reports': 'enable',
- 'gui-multicast-policy': 'enable',
- 'gui-multiple-interface-policy': 'enable',
- 'gui-multiple-utm-profiles': 'enable',
- 'gui-nat46-64': 'enable',
- 'gui-object-colors': 'enable',
- 'gui-policy-based-ipsec': 'enable',
- 'gui-policy-learning': 'enable',
- 'gui-replacement-message-groups': 'enable',
- 'gui-spamfilter': 'enable',
- 'gui-sslvpn-personal-bookmarks': 'enable',
- 'gui-sslvpn-realms': 'enable',
- 'gui-switch-controller': 'enable',
- 'gui-threat-weight': 'enable',
- 'gui-traffic-shaping': 'enable',
- 'gui-voip-profile': 'enable',
- 'gui-vpn': 'enable',
- 'gui-waf-profile': 'enable',
- 'gui-wan-load-balancing': 'enable',
- 'gui-wanopt-cache': 'enable',
- 'gui-webfilter': 'enable',
- 'gui-webfilter-advanced': 'enable',
- 'gui-wireless-controller': 'enable',
- 'http-external-dest': 'fortiweb',
- 'ike-dn-format': 'with-space',
- 'ike-quick-crash-detect': 'enable',
- 'ike-session-resume': 'enable',
- 'implicit-allow-dns': 'enable',
- 'inspection-mode': 'proxy',
- 'ip': 'test_value_84',
- 'ip6': 'test_value_85',
- 'link-down-access': 'enable',
- 'lldp-transmission': 'enable',
- 'mac-ttl': '88',
- 'manageip': 'test_value_89',
- 'manageip6': 'test_value_90',
- 'multicast-forward': 'enable',
- 'multicast-skip-policy': 'enable',
- 'multicast-ttl-notchange': 'enable',
- 'ngfw-mode': 'profile-based',
- 'opmode': 'nat',
- 'prp-trailer-action': 'enable',
- 'sccp-port': '97',
- 'ses-denied-traffic': 'enable',
- 'sip-helper': 'enable',
- 'sip-nat-trace': 'enable',
- 'sip-ssl-port': '101',
- 'sip-tcp-port': '102',
- 'sip-udp-port': '103',
- 'snat-hairpin-traffic': 'enable',
- 'ssl-ssh-profile': 'test_value_105',
- 'status': 'enable',
- 'strict-src-check': 'enable',
- 'tcp-session-without-syn': 'enable',
- 'utf8-spam-tagging': 'enable',
- 'v4-ecmp-mode': 'source-ip-based',
- 'vpn-stats-log': 'ipsec',
- 'vpn-stats-period': '112',
- 'wccp-cache-engine': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_settings': {
- 'allow_linkdown_path': 'enable',
- 'allow_subnet_overlap': 'enable',
- 'asymroute': 'enable',
- 'asymroute_icmp': 'enable',
- 'asymroute6': 'enable',
- 'asymroute6_icmp': 'enable',
- 'bfd': 'enable',
- 'bfd_desired_min_tx': '10',
- 'bfd_detect_mult': '11',
- 'bfd_dont_enforce_src_port': 'enable',
- 'bfd_required_min_rx': '13',
- 'block_land_attack': 'disable',
- 'central_nat': 'enable',
- 'comments': 'test_value_16',
- 'compliance_check': 'enable',
- 'default_voip_alg_mode': 'proxy-based',
- 'deny_tcp_with_icmp': 'enable',
- 'device': 'test_value_20',
- 'dhcp_proxy': 'enable',
- 'dhcp_server_ip': 'test_value_22',
- 'dhcp6_server_ip': 'test_value_23',
- 'discovered_device_timeout': '24',
- 'ecmp_max_paths': '25',
- 'email_portal_check_dns': 'disable',
- 'firewall_session_dirty': 'check-all',
- 'fw_session_hairpin': 'enable',
- 'gateway': 'test_value_29',
- 'gateway6': 'test_value_30',
- 'gui_advanced_policy': 'enable',
- 'gui_allow_unnamed_policy': 'enable',
- 'gui_antivirus': 'enable',
- 'gui_ap_profile': 'enable',
- 'gui_application_control': 'enable',
- 'gui_dhcp_advanced': 'enable',
- 'gui_dlp': 'enable',
- 'gui_dns_database': 'enable',
- 'gui_dnsfilter': 'enable',
- 'gui_domain_ip_reputation': 'enable',
- 'gui_dos_policy': 'enable',
- 'gui_dynamic_profile_display': 'enable',
- 'gui_dynamic_routing': 'enable',
- 'gui_email_collection': 'enable',
- 'gui_endpoint_control': 'enable',
- 'gui_endpoint_control_advanced': 'enable',
- 'gui_explicit_proxy': 'enable',
- 'gui_fortiap_split_tunneling': 'enable',
- 'gui_fortiextender_controller': 'enable',
- 'gui_icap': 'enable',
- 'gui_implicit_policy': 'enable',
- 'gui_ips': 'enable',
- 'gui_load_balance': 'enable',
- 'gui_local_in_policy': 'enable',
- 'gui_local_reports': 'enable',
- 'gui_multicast_policy': 'enable',
- 'gui_multiple_interface_policy': 'enable',
- 'gui_multiple_utm_profiles': 'enable',
- 'gui_nat46_64': 'enable',
- 'gui_object_colors': 'enable',
- 'gui_policy_based_ipsec': 'enable',
- 'gui_policy_learning': 'enable',
- 'gui_replacement_message_groups': 'enable',
- 'gui_spamfilter': 'enable',
- 'gui_sslvpn_personal_bookmarks': 'enable',
- 'gui_sslvpn_realms': 'enable',
- 'gui_switch_controller': 'enable',
- 'gui_threat_weight': 'enable',
- 'gui_traffic_shaping': 'enable',
- 'gui_voip_profile': 'enable',
- 'gui_vpn': 'enable',
- 'gui_waf_profile': 'enable',
- 'gui_wan_load_balancing': 'enable',
- 'gui_wanopt_cache': 'enable',
- 'gui_webfilter': 'enable',
- 'gui_webfilter_advanced': 'enable',
- 'gui_wireless_controller': 'enable',
- 'http_external_dest': 'fortiweb',
- 'ike_dn_format': 'with-space',
- 'ike_quick_crash_detect': 'enable',
- 'ike_session_resume': 'enable',
- 'implicit_allow_dns': 'enable',
- 'inspection_mode': 'proxy',
- 'ip': 'test_value_84',
- 'ip6': 'test_value_85',
- 'link_down_access': 'enable',
- 'lldp_transmission': 'enable',
- 'mac_ttl': '88',
- 'manageip': 'test_value_89',
- 'manageip6': 'test_value_90',
- 'multicast_forward': 'enable',
- 'multicast_skip_policy': 'enable',
- 'multicast_ttl_notchange': 'enable',
- 'ngfw_mode': 'profile-based',
- 'opmode': 'nat',
- 'prp_trailer_action': 'enable',
- 'sccp_port': '97',
- 'ses_denied_traffic': 'enable',
- 'sip_helper': 'enable',
- 'sip_nat_trace': 'enable',
- 'sip_ssl_port': '101',
- 'sip_tcp_port': '102',
- 'sip_udp_port': '103',
- 'snat_hairpin_traffic': 'enable',
- 'ssl_ssh_profile': 'test_value_105',
- 'status': 'enable',
- 'strict_src_check': 'enable',
- 'tcp_session_without_syn': 'enable',
- 'utf8_spam_tagging': 'enable',
- 'v4_ecmp_mode': 'source-ip-based',
- 'vpn_stats_log': 'ipsec',
- 'vpn_stats_period': '112',
- 'wccp_cache_engine': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_settings.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-linkdown-path': 'enable',
- 'allow-subnet-overlap': 'enable',
- 'asymroute': 'enable',
- 'asymroute-icmp': 'enable',
- 'asymroute6': 'enable',
- 'asymroute6-icmp': 'enable',
- 'bfd': 'enable',
- 'bfd-desired-min-tx': '10',
- 'bfd-detect-mult': '11',
- 'bfd-dont-enforce-src-port': 'enable',
- 'bfd-required-min-rx': '13',
- 'block-land-attack': 'disable',
- 'central-nat': 'enable',
- 'comments': 'test_value_16',
- 'compliance-check': 'enable',
- 'default-voip-alg-mode': 'proxy-based',
- 'deny-tcp-with-icmp': 'enable',
- 'device': 'test_value_20',
- 'dhcp-proxy': 'enable',
- 'dhcp-server-ip': 'test_value_22',
- 'dhcp6-server-ip': 'test_value_23',
- 'discovered-device-timeout': '24',
- 'ecmp-max-paths': '25',
- 'email-portal-check-dns': 'disable',
- 'firewall-session-dirty': 'check-all',
- 'fw-session-hairpin': 'enable',
- 'gateway': 'test_value_29',
- 'gateway6': 'test_value_30',
- 'gui-advanced-policy': 'enable',
- 'gui-allow-unnamed-policy': 'enable',
- 'gui-antivirus': 'enable',
- 'gui-ap-profile': 'enable',
- 'gui-application-control': 'enable',
- 'gui-dhcp-advanced': 'enable',
- 'gui-dlp': 'enable',
- 'gui-dns-database': 'enable',
- 'gui-dnsfilter': 'enable',
- 'gui-domain-ip-reputation': 'enable',
- 'gui-dos-policy': 'enable',
- 'gui-dynamic-profile-display': 'enable',
- 'gui-dynamic-routing': 'enable',
- 'gui-email-collection': 'enable',
- 'gui-endpoint-control': 'enable',
- 'gui-endpoint-control-advanced': 'enable',
- 'gui-explicit-proxy': 'enable',
- 'gui-fortiap-split-tunneling': 'enable',
- 'gui-fortiextender-controller': 'enable',
- 'gui-icap': 'enable',
- 'gui-implicit-policy': 'enable',
- 'gui-ips': 'enable',
- 'gui-load-balance': 'enable',
- 'gui-local-in-policy': 'enable',
- 'gui-local-reports': 'enable',
- 'gui-multicast-policy': 'enable',
- 'gui-multiple-interface-policy': 'enable',
- 'gui-multiple-utm-profiles': 'enable',
- 'gui-nat46-64': 'enable',
- 'gui-object-colors': 'enable',
- 'gui-policy-based-ipsec': 'enable',
- 'gui-policy-learning': 'enable',
- 'gui-replacement-message-groups': 'enable',
- 'gui-spamfilter': 'enable',
- 'gui-sslvpn-personal-bookmarks': 'enable',
- 'gui-sslvpn-realms': 'enable',
- 'gui-switch-controller': 'enable',
- 'gui-threat-weight': 'enable',
- 'gui-traffic-shaping': 'enable',
- 'gui-voip-profile': 'enable',
- 'gui-vpn': 'enable',
- 'gui-waf-profile': 'enable',
- 'gui-wan-load-balancing': 'enable',
- 'gui-wanopt-cache': 'enable',
- 'gui-webfilter': 'enable',
- 'gui-webfilter-advanced': 'enable',
- 'gui-wireless-controller': 'enable',
- 'http-external-dest': 'fortiweb',
- 'ike-dn-format': 'with-space',
- 'ike-quick-crash-detect': 'enable',
- 'ike-session-resume': 'enable',
- 'implicit-allow-dns': 'enable',
- 'inspection-mode': 'proxy',
- 'ip': 'test_value_84',
- 'ip6': 'test_value_85',
- 'link-down-access': 'enable',
- 'lldp-transmission': 'enable',
- 'mac-ttl': '88',
- 'manageip': 'test_value_89',
- 'manageip6': 'test_value_90',
- 'multicast-forward': 'enable',
- 'multicast-skip-policy': 'enable',
- 'multicast-ttl-notchange': 'enable',
- 'ngfw-mode': 'profile-based',
- 'opmode': 'nat',
- 'prp-trailer-action': 'enable',
- 'sccp-port': '97',
- 'ses-denied-traffic': 'enable',
- 'sip-helper': 'enable',
- 'sip-nat-trace': 'enable',
- 'sip-ssl-port': '101',
- 'sip-tcp-port': '102',
- 'sip-udp-port': '103',
- 'snat-hairpin-traffic': 'enable',
- 'ssl-ssh-profile': 'test_value_105',
- 'status': 'enable',
- 'strict-src-check': 'enable',
- 'tcp-session-without-syn': 'enable',
- 'utf8-spam-tagging': 'enable',
- 'v4-ecmp-mode': 'source-ip-based',
- 'vpn-stats-log': 'ipsec',
- 'vpn-stats-period': '112',
- 'wccp-cache-engine': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_settings': {
- 'allow_linkdown_path': 'enable',
- 'allow_subnet_overlap': 'enable',
- 'asymroute': 'enable',
- 'asymroute_icmp': 'enable',
- 'asymroute6': 'enable',
- 'asymroute6_icmp': 'enable',
- 'bfd': 'enable',
- 'bfd_desired_min_tx': '10',
- 'bfd_detect_mult': '11',
- 'bfd_dont_enforce_src_port': 'enable',
- 'bfd_required_min_rx': '13',
- 'block_land_attack': 'disable',
- 'central_nat': 'enable',
- 'comments': 'test_value_16',
- 'compliance_check': 'enable',
- 'default_voip_alg_mode': 'proxy-based',
- 'deny_tcp_with_icmp': 'enable',
- 'device': 'test_value_20',
- 'dhcp_proxy': 'enable',
- 'dhcp_server_ip': 'test_value_22',
- 'dhcp6_server_ip': 'test_value_23',
- 'discovered_device_timeout': '24',
- 'ecmp_max_paths': '25',
- 'email_portal_check_dns': 'disable',
- 'firewall_session_dirty': 'check-all',
- 'fw_session_hairpin': 'enable',
- 'gateway': 'test_value_29',
- 'gateway6': 'test_value_30',
- 'gui_advanced_policy': 'enable',
- 'gui_allow_unnamed_policy': 'enable',
- 'gui_antivirus': 'enable',
- 'gui_ap_profile': 'enable',
- 'gui_application_control': 'enable',
- 'gui_dhcp_advanced': 'enable',
- 'gui_dlp': 'enable',
- 'gui_dns_database': 'enable',
- 'gui_dnsfilter': 'enable',
- 'gui_domain_ip_reputation': 'enable',
- 'gui_dos_policy': 'enable',
- 'gui_dynamic_profile_display': 'enable',
- 'gui_dynamic_routing': 'enable',
- 'gui_email_collection': 'enable',
- 'gui_endpoint_control': 'enable',
- 'gui_endpoint_control_advanced': 'enable',
- 'gui_explicit_proxy': 'enable',
- 'gui_fortiap_split_tunneling': 'enable',
- 'gui_fortiextender_controller': 'enable',
- 'gui_icap': 'enable',
- 'gui_implicit_policy': 'enable',
- 'gui_ips': 'enable',
- 'gui_load_balance': 'enable',
- 'gui_local_in_policy': 'enable',
- 'gui_local_reports': 'enable',
- 'gui_multicast_policy': 'enable',
- 'gui_multiple_interface_policy': 'enable',
- 'gui_multiple_utm_profiles': 'enable',
- 'gui_nat46_64': 'enable',
- 'gui_object_colors': 'enable',
- 'gui_policy_based_ipsec': 'enable',
- 'gui_policy_learning': 'enable',
- 'gui_replacement_message_groups': 'enable',
- 'gui_spamfilter': 'enable',
- 'gui_sslvpn_personal_bookmarks': 'enable',
- 'gui_sslvpn_realms': 'enable',
- 'gui_switch_controller': 'enable',
- 'gui_threat_weight': 'enable',
- 'gui_traffic_shaping': 'enable',
- 'gui_voip_profile': 'enable',
- 'gui_vpn': 'enable',
- 'gui_waf_profile': 'enable',
- 'gui_wan_load_balancing': 'enable',
- 'gui_wanopt_cache': 'enable',
- 'gui_webfilter': 'enable',
- 'gui_webfilter_advanced': 'enable',
- 'gui_wireless_controller': 'enable',
- 'http_external_dest': 'fortiweb',
- 'ike_dn_format': 'with-space',
- 'ike_quick_crash_detect': 'enable',
- 'ike_session_resume': 'enable',
- 'implicit_allow_dns': 'enable',
- 'inspection_mode': 'proxy',
- 'ip': 'test_value_84',
- 'ip6': 'test_value_85',
- 'link_down_access': 'enable',
- 'lldp_transmission': 'enable',
- 'mac_ttl': '88',
- 'manageip': 'test_value_89',
- 'manageip6': 'test_value_90',
- 'multicast_forward': 'enable',
- 'multicast_skip_policy': 'enable',
- 'multicast_ttl_notchange': 'enable',
- 'ngfw_mode': 'profile-based',
- 'opmode': 'nat',
- 'prp_trailer_action': 'enable',
- 'sccp_port': '97',
- 'ses_denied_traffic': 'enable',
- 'sip_helper': 'enable',
- 'sip_nat_trace': 'enable',
- 'sip_ssl_port': '101',
- 'sip_tcp_port': '102',
- 'sip_udp_port': '103',
- 'snat_hairpin_traffic': 'enable',
- 'ssl_ssh_profile': 'test_value_105',
- 'status': 'enable',
- 'strict_src_check': 'enable',
- 'tcp_session_without_syn': 'enable',
- 'utf8_spam_tagging': 'enable',
- 'v4_ecmp_mode': 'source-ip-based',
- 'vpn_stats_log': 'ipsec',
- 'vpn_stats_period': '112',
- 'wccp_cache_engine': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_settings.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-linkdown-path': 'enable',
- 'allow-subnet-overlap': 'enable',
- 'asymroute': 'enable',
- 'asymroute-icmp': 'enable',
- 'asymroute6': 'enable',
- 'asymroute6-icmp': 'enable',
- 'bfd': 'enable',
- 'bfd-desired-min-tx': '10',
- 'bfd-detect-mult': '11',
- 'bfd-dont-enforce-src-port': 'enable',
- 'bfd-required-min-rx': '13',
- 'block-land-attack': 'disable',
- 'central-nat': 'enable',
- 'comments': 'test_value_16',
- 'compliance-check': 'enable',
- 'default-voip-alg-mode': 'proxy-based',
- 'deny-tcp-with-icmp': 'enable',
- 'device': 'test_value_20',
- 'dhcp-proxy': 'enable',
- 'dhcp-server-ip': 'test_value_22',
- 'dhcp6-server-ip': 'test_value_23',
- 'discovered-device-timeout': '24',
- 'ecmp-max-paths': '25',
- 'email-portal-check-dns': 'disable',
- 'firewall-session-dirty': 'check-all',
- 'fw-session-hairpin': 'enable',
- 'gateway': 'test_value_29',
- 'gateway6': 'test_value_30',
- 'gui-advanced-policy': 'enable',
- 'gui-allow-unnamed-policy': 'enable',
- 'gui-antivirus': 'enable',
- 'gui-ap-profile': 'enable',
- 'gui-application-control': 'enable',
- 'gui-dhcp-advanced': 'enable',
- 'gui-dlp': 'enable',
- 'gui-dns-database': 'enable',
- 'gui-dnsfilter': 'enable',
- 'gui-domain-ip-reputation': 'enable',
- 'gui-dos-policy': 'enable',
- 'gui-dynamic-profile-display': 'enable',
- 'gui-dynamic-routing': 'enable',
- 'gui-email-collection': 'enable',
- 'gui-endpoint-control': 'enable',
- 'gui-endpoint-control-advanced': 'enable',
- 'gui-explicit-proxy': 'enable',
- 'gui-fortiap-split-tunneling': 'enable',
- 'gui-fortiextender-controller': 'enable',
- 'gui-icap': 'enable',
- 'gui-implicit-policy': 'enable',
- 'gui-ips': 'enable',
- 'gui-load-balance': 'enable',
- 'gui-local-in-policy': 'enable',
- 'gui-local-reports': 'enable',
- 'gui-multicast-policy': 'enable',
- 'gui-multiple-interface-policy': 'enable',
- 'gui-multiple-utm-profiles': 'enable',
- 'gui-nat46-64': 'enable',
- 'gui-object-colors': 'enable',
- 'gui-policy-based-ipsec': 'enable',
- 'gui-policy-learning': 'enable',
- 'gui-replacement-message-groups': 'enable',
- 'gui-spamfilter': 'enable',
- 'gui-sslvpn-personal-bookmarks': 'enable',
- 'gui-sslvpn-realms': 'enable',
- 'gui-switch-controller': 'enable',
- 'gui-threat-weight': 'enable',
- 'gui-traffic-shaping': 'enable',
- 'gui-voip-profile': 'enable',
- 'gui-vpn': 'enable',
- 'gui-waf-profile': 'enable',
- 'gui-wan-load-balancing': 'enable',
- 'gui-wanopt-cache': 'enable',
- 'gui-webfilter': 'enable',
- 'gui-webfilter-advanced': 'enable',
- 'gui-wireless-controller': 'enable',
- 'http-external-dest': 'fortiweb',
- 'ike-dn-format': 'with-space',
- 'ike-quick-crash-detect': 'enable',
- 'ike-session-resume': 'enable',
- 'implicit-allow-dns': 'enable',
- 'inspection-mode': 'proxy',
- 'ip': 'test_value_84',
- 'ip6': 'test_value_85',
- 'link-down-access': 'enable',
- 'lldp-transmission': 'enable',
- 'mac-ttl': '88',
- 'manageip': 'test_value_89',
- 'manageip6': 'test_value_90',
- 'multicast-forward': 'enable',
- 'multicast-skip-policy': 'enable',
- 'multicast-ttl-notchange': 'enable',
- 'ngfw-mode': 'profile-based',
- 'opmode': 'nat',
- 'prp-trailer-action': 'enable',
- 'sccp-port': '97',
- 'ses-denied-traffic': 'enable',
- 'sip-helper': 'enable',
- 'sip-nat-trace': 'enable',
- 'sip-ssl-port': '101',
- 'sip-tcp-port': '102',
- 'sip-udp-port': '103',
- 'snat-hairpin-traffic': 'enable',
- 'ssl-ssh-profile': 'test_value_105',
- 'status': 'enable',
- 'strict-src-check': 'enable',
- 'tcp-session-without-syn': 'enable',
- 'utf8-spam-tagging': 'enable',
- 'v4-ecmp-mode': 'source-ip-based',
- 'vpn-stats-log': 'ipsec',
- 'vpn-stats-period': '112',
- 'wccp-cache-engine': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_settings': {
- 'random_attribute_not_valid': 'tag',
- 'allow_linkdown_path': 'enable',
- 'allow_subnet_overlap': 'enable',
- 'asymroute': 'enable',
- 'asymroute_icmp': 'enable',
- 'asymroute6': 'enable',
- 'asymroute6_icmp': 'enable',
- 'bfd': 'enable',
- 'bfd_desired_min_tx': '10',
- 'bfd_detect_mult': '11',
- 'bfd_dont_enforce_src_port': 'enable',
- 'bfd_required_min_rx': '13',
- 'block_land_attack': 'disable',
- 'central_nat': 'enable',
- 'comments': 'test_value_16',
- 'compliance_check': 'enable',
- 'default_voip_alg_mode': 'proxy-based',
- 'deny_tcp_with_icmp': 'enable',
- 'device': 'test_value_20',
- 'dhcp_proxy': 'enable',
- 'dhcp_server_ip': 'test_value_22',
- 'dhcp6_server_ip': 'test_value_23',
- 'discovered_device_timeout': '24',
- 'ecmp_max_paths': '25',
- 'email_portal_check_dns': 'disable',
- 'firewall_session_dirty': 'check-all',
- 'fw_session_hairpin': 'enable',
- 'gateway': 'test_value_29',
- 'gateway6': 'test_value_30',
- 'gui_advanced_policy': 'enable',
- 'gui_allow_unnamed_policy': 'enable',
- 'gui_antivirus': 'enable',
- 'gui_ap_profile': 'enable',
- 'gui_application_control': 'enable',
- 'gui_dhcp_advanced': 'enable',
- 'gui_dlp': 'enable',
- 'gui_dns_database': 'enable',
- 'gui_dnsfilter': 'enable',
- 'gui_domain_ip_reputation': 'enable',
- 'gui_dos_policy': 'enable',
- 'gui_dynamic_profile_display': 'enable',
- 'gui_dynamic_routing': 'enable',
- 'gui_email_collection': 'enable',
- 'gui_endpoint_control': 'enable',
- 'gui_endpoint_control_advanced': 'enable',
- 'gui_explicit_proxy': 'enable',
- 'gui_fortiap_split_tunneling': 'enable',
- 'gui_fortiextender_controller': 'enable',
- 'gui_icap': 'enable',
- 'gui_implicit_policy': 'enable',
- 'gui_ips': 'enable',
- 'gui_load_balance': 'enable',
- 'gui_local_in_policy': 'enable',
- 'gui_local_reports': 'enable',
- 'gui_multicast_policy': 'enable',
- 'gui_multiple_interface_policy': 'enable',
- 'gui_multiple_utm_profiles': 'enable',
- 'gui_nat46_64': 'enable',
- 'gui_object_colors': 'enable',
- 'gui_policy_based_ipsec': 'enable',
- 'gui_policy_learning': 'enable',
- 'gui_replacement_message_groups': 'enable',
- 'gui_spamfilter': 'enable',
- 'gui_sslvpn_personal_bookmarks': 'enable',
- 'gui_sslvpn_realms': 'enable',
- 'gui_switch_controller': 'enable',
- 'gui_threat_weight': 'enable',
- 'gui_traffic_shaping': 'enable',
- 'gui_voip_profile': 'enable',
- 'gui_vpn': 'enable',
- 'gui_waf_profile': 'enable',
- 'gui_wan_load_balancing': 'enable',
- 'gui_wanopt_cache': 'enable',
- 'gui_webfilter': 'enable',
- 'gui_webfilter_advanced': 'enable',
- 'gui_wireless_controller': 'enable',
- 'http_external_dest': 'fortiweb',
- 'ike_dn_format': 'with-space',
- 'ike_quick_crash_detect': 'enable',
- 'ike_session_resume': 'enable',
- 'implicit_allow_dns': 'enable',
- 'inspection_mode': 'proxy',
- 'ip': 'test_value_84',
- 'ip6': 'test_value_85',
- 'link_down_access': 'enable',
- 'lldp_transmission': 'enable',
- 'mac_ttl': '88',
- 'manageip': 'test_value_89',
- 'manageip6': 'test_value_90',
- 'multicast_forward': 'enable',
- 'multicast_skip_policy': 'enable',
- 'multicast_ttl_notchange': 'enable',
- 'ngfw_mode': 'profile-based',
- 'opmode': 'nat',
- 'prp_trailer_action': 'enable',
- 'sccp_port': '97',
- 'ses_denied_traffic': 'enable',
- 'sip_helper': 'enable',
- 'sip_nat_trace': 'enable',
- 'sip_ssl_port': '101',
- 'sip_tcp_port': '102',
- 'sip_udp_port': '103',
- 'snat_hairpin_traffic': 'enable',
- 'ssl_ssh_profile': 'test_value_105',
- 'status': 'enable',
- 'strict_src_check': 'enable',
- 'tcp_session_without_syn': 'enable',
- 'utf8_spam_tagging': 'enable',
- 'v4_ecmp_mode': 'source-ip-based',
- 'vpn_stats_log': 'ipsec',
- 'vpn_stats_period': '112',
- 'wccp_cache_engine': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_settings.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'allow-linkdown-path': 'enable',
- 'allow-subnet-overlap': 'enable',
- 'asymroute': 'enable',
- 'asymroute-icmp': 'enable',
- 'asymroute6': 'enable',
- 'asymroute6-icmp': 'enable',
- 'bfd': 'enable',
- 'bfd-desired-min-tx': '10',
- 'bfd-detect-mult': '11',
- 'bfd-dont-enforce-src-port': 'enable',
- 'bfd-required-min-rx': '13',
- 'block-land-attack': 'disable',
- 'central-nat': 'enable',
- 'comments': 'test_value_16',
- 'compliance-check': 'enable',
- 'default-voip-alg-mode': 'proxy-based',
- 'deny-tcp-with-icmp': 'enable',
- 'device': 'test_value_20',
- 'dhcp-proxy': 'enable',
- 'dhcp-server-ip': 'test_value_22',
- 'dhcp6-server-ip': 'test_value_23',
- 'discovered-device-timeout': '24',
- 'ecmp-max-paths': '25',
- 'email-portal-check-dns': 'disable',
- 'firewall-session-dirty': 'check-all',
- 'fw-session-hairpin': 'enable',
- 'gateway': 'test_value_29',
- 'gateway6': 'test_value_30',
- 'gui-advanced-policy': 'enable',
- 'gui-allow-unnamed-policy': 'enable',
- 'gui-antivirus': 'enable',
- 'gui-ap-profile': 'enable',
- 'gui-application-control': 'enable',
- 'gui-dhcp-advanced': 'enable',
- 'gui-dlp': 'enable',
- 'gui-dns-database': 'enable',
- 'gui-dnsfilter': 'enable',
- 'gui-domain-ip-reputation': 'enable',
- 'gui-dos-policy': 'enable',
- 'gui-dynamic-profile-display': 'enable',
- 'gui-dynamic-routing': 'enable',
- 'gui-email-collection': 'enable',
- 'gui-endpoint-control': 'enable',
- 'gui-endpoint-control-advanced': 'enable',
- 'gui-explicit-proxy': 'enable',
- 'gui-fortiap-split-tunneling': 'enable',
- 'gui-fortiextender-controller': 'enable',
- 'gui-icap': 'enable',
- 'gui-implicit-policy': 'enable',
- 'gui-ips': 'enable',
- 'gui-load-balance': 'enable',
- 'gui-local-in-policy': 'enable',
- 'gui-local-reports': 'enable',
- 'gui-multicast-policy': 'enable',
- 'gui-multiple-interface-policy': 'enable',
- 'gui-multiple-utm-profiles': 'enable',
- 'gui-nat46-64': 'enable',
- 'gui-object-colors': 'enable',
- 'gui-policy-based-ipsec': 'enable',
- 'gui-policy-learning': 'enable',
- 'gui-replacement-message-groups': 'enable',
- 'gui-spamfilter': 'enable',
- 'gui-sslvpn-personal-bookmarks': 'enable',
- 'gui-sslvpn-realms': 'enable',
- 'gui-switch-controller': 'enable',
- 'gui-threat-weight': 'enable',
- 'gui-traffic-shaping': 'enable',
- 'gui-voip-profile': 'enable',
- 'gui-vpn': 'enable',
- 'gui-waf-profile': 'enable',
- 'gui-wan-load-balancing': 'enable',
- 'gui-wanopt-cache': 'enable',
- 'gui-webfilter': 'enable',
- 'gui-webfilter-advanced': 'enable',
- 'gui-wireless-controller': 'enable',
- 'http-external-dest': 'fortiweb',
- 'ike-dn-format': 'with-space',
- 'ike-quick-crash-detect': 'enable',
- 'ike-session-resume': 'enable',
- 'implicit-allow-dns': 'enable',
- 'inspection-mode': 'proxy',
- 'ip': 'test_value_84',
- 'ip6': 'test_value_85',
- 'link-down-access': 'enable',
- 'lldp-transmission': 'enable',
- 'mac-ttl': '88',
- 'manageip': 'test_value_89',
- 'manageip6': 'test_value_90',
- 'multicast-forward': 'enable',
- 'multicast-skip-policy': 'enable',
- 'multicast-ttl-notchange': 'enable',
- 'ngfw-mode': 'profile-based',
- 'opmode': 'nat',
- 'prp-trailer-action': 'enable',
- 'sccp-port': '97',
- 'ses-denied-traffic': 'enable',
- 'sip-helper': 'enable',
- 'sip-nat-trace': 'enable',
- 'sip-ssl-port': '101',
- 'sip-tcp-port': '102',
- 'sip-udp-port': '103',
- 'snat-hairpin-traffic': 'enable',
- 'ssl-ssh-profile': 'test_value_105',
- 'status': 'enable',
- 'strict-src-check': 'enable',
- 'tcp-session-without-syn': 'enable',
- 'utf8-spam-tagging': 'enable',
- 'v4-ecmp-mode': 'source-ip-based',
- 'vpn-stats-log': 'ipsec',
- 'vpn-stats-period': '112',
- 'wccp-cache-engine': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_sflow.py b/test/units/modules/network/fortios/test_fortios_system_sflow.py
deleted file mode 100644
index 20ba2b3f20..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_sflow.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_sflow
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_sflow.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_sflow_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5'
- }
-
- set_method_mock.assert_called_with('system', 'sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_sflow_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5'
- }
-
- set_method_mock.assert_called_with('system', 'sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_sflow_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5'
- }
-
- set_method_mock.assert_called_with('system', 'sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_sflow_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sflow': {
- 'random_attribute_not_valid': 'tag',
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5'
- }
-
- set_method_mock.assert_called_with('system', 'sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_sit_tunnel.py b/test/units/modules/network/fortios/test_fortios_system_sit_tunnel.py
deleted file mode 100644
index 1fac572945..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_sit_tunnel.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_sit_tunnel
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_sit_tunnel.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_sit_tunnel_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sit_tunnel': {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'source': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sit_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'source': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('system', 'sit-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_sit_tunnel_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sit_tunnel': {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'source': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sit_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'source': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('system', 'sit-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_sit_tunnel_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_sit_tunnel': {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'source': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sit_tunnel.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'sit-tunnel', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_sit_tunnel_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_sit_tunnel': {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'source': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sit_tunnel.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'sit-tunnel', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_sit_tunnel_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sit_tunnel': {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'source': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sit_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'source': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('system', 'sit-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_sit_tunnel_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sit_tunnel': {
- 'random_attribute_not_valid': 'tag',
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'source': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sit_tunnel.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'destination': 'test_value_3',
- 'interface': 'test_value_4',
- 'ip6': 'test_value_5',
- 'name': 'default_name_6',
- 'source': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('system', 'sit-tunnel', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_sms_server.py b/test/units/modules/network/fortios/test_fortios_system_sms_server.py
deleted file mode 100644
index 350db03c3a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_sms_server.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_sms_server
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_sms_server.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_sms_server_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sms_server': {
- 'mail_server': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sms_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'mail-server': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('system', 'sms-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_sms_server_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sms_server': {
- 'mail_server': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sms_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'mail-server': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('system', 'sms-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_sms_server_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_sms_server': {
- 'mail_server': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sms_server.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'sms-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_sms_server_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_sms_server': {
- 'mail_server': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sms_server.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'sms-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_sms_server_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sms_server': {
- 'mail_server': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sms_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'mail-server': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('system', 'sms-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_sms_server_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_sms_server': {
- 'random_attribute_not_valid': 'tag',
- 'mail_server': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_sms_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'mail-server': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('system', 'sms-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_snmp_community.py b/test/units/modules/network/fortios/test_fortios_system_snmp_community.py
deleted file mode 100644
index e3c39a45b0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_snmp_community.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_snmp_community
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_snmp_community.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_snmp_community_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_community': {
- 'events': 'cpu-high',
- 'id': '4',
- 'name': 'default_name_5',
- 'query_v1_port': '6',
- 'query_v1_status': 'enable',
- 'query_v2c_port': '8',
- 'query_v2c_status': 'enable',
- 'status': 'enable',
- 'trap_v1_lport': '11',
- 'trap_v1_rport': '12',
- 'trap_v1_status': 'enable',
- 'trap_v2c_lport': '14',
- 'trap_v2c_rport': '15',
- 'trap_v2c_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_community.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'events': 'cpu-high',
- 'id': '4',
- 'name': 'default_name_5',
- 'query-v1-port': '6',
- 'query-v1-status': 'enable',
- 'query-v2c-port': '8',
- 'query-v2c-status': 'enable',
- 'status': 'enable',
- 'trap-v1-lport': '11',
- 'trap-v1-rport': '12',
- 'trap-v1-status': 'enable',
- 'trap-v2c-lport': '14',
- 'trap-v2c-rport': '15',
- 'trap-v2c-status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'community', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_snmp_community_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_community': {
- 'events': 'cpu-high',
- 'id': '4',
- 'name': 'default_name_5',
- 'query_v1_port': '6',
- 'query_v1_status': 'enable',
- 'query_v2c_port': '8',
- 'query_v2c_status': 'enable',
- 'status': 'enable',
- 'trap_v1_lport': '11',
- 'trap_v1_rport': '12',
- 'trap_v1_status': 'enable',
- 'trap_v2c_lport': '14',
- 'trap_v2c_rport': '15',
- 'trap_v2c_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_community.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'events': 'cpu-high',
- 'id': '4',
- 'name': 'default_name_5',
- 'query-v1-port': '6',
- 'query-v1-status': 'enable',
- 'query-v2c-port': '8',
- 'query-v2c-status': 'enable',
- 'status': 'enable',
- 'trap-v1-lport': '11',
- 'trap-v1-rport': '12',
- 'trap-v1-status': 'enable',
- 'trap-v2c-lport': '14',
- 'trap-v2c-rport': '15',
- 'trap-v2c-status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'community', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_snmp_community_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_snmp_community': {
- 'events': 'cpu-high',
- 'id': '4',
- 'name': 'default_name_5',
- 'query_v1_port': '6',
- 'query_v1_status': 'enable',
- 'query_v2c_port': '8',
- 'query_v2c_status': 'enable',
- 'status': 'enable',
- 'trap_v1_lport': '11',
- 'trap_v1_rport': '12',
- 'trap_v1_status': 'enable',
- 'trap_v2c_lport': '14',
- 'trap_v2c_rport': '15',
- 'trap_v2c_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_community.fortios_system_snmp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.snmp', 'community', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_snmp_community_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_snmp_community': {
- 'events': 'cpu-high',
- 'id': '4',
- 'name': 'default_name_5',
- 'query_v1_port': '6',
- 'query_v1_status': 'enable',
- 'query_v2c_port': '8',
- 'query_v2c_status': 'enable',
- 'status': 'enable',
- 'trap_v1_lport': '11',
- 'trap_v1_rport': '12',
- 'trap_v1_status': 'enable',
- 'trap_v2c_lport': '14',
- 'trap_v2c_rport': '15',
- 'trap_v2c_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_community.fortios_system_snmp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.snmp', 'community', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_snmp_community_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_community': {
- 'events': 'cpu-high',
- 'id': '4',
- 'name': 'default_name_5',
- 'query_v1_port': '6',
- 'query_v1_status': 'enable',
- 'query_v2c_port': '8',
- 'query_v2c_status': 'enable',
- 'status': 'enable',
- 'trap_v1_lport': '11',
- 'trap_v1_rport': '12',
- 'trap_v1_status': 'enable',
- 'trap_v2c_lport': '14',
- 'trap_v2c_rport': '15',
- 'trap_v2c_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_community.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'events': 'cpu-high',
- 'id': '4',
- 'name': 'default_name_5',
- 'query-v1-port': '6',
- 'query-v1-status': 'enable',
- 'query-v2c-port': '8',
- 'query-v2c-status': 'enable',
- 'status': 'enable',
- 'trap-v1-lport': '11',
- 'trap-v1-rport': '12',
- 'trap-v1-status': 'enable',
- 'trap-v2c-lport': '14',
- 'trap-v2c-rport': '15',
- 'trap-v2c-status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'community', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_snmp_community_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_community': {
- 'random_attribute_not_valid': 'tag',
- 'events': 'cpu-high',
- 'id': '4',
- 'name': 'default_name_5',
- 'query_v1_port': '6',
- 'query_v1_status': 'enable',
- 'query_v2c_port': '8',
- 'query_v2c_status': 'enable',
- 'status': 'enable',
- 'trap_v1_lport': '11',
- 'trap_v1_rport': '12',
- 'trap_v1_status': 'enable',
- 'trap_v2c_lport': '14',
- 'trap_v2c_rport': '15',
- 'trap_v2c_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_community.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'events': 'cpu-high',
- 'id': '4',
- 'name': 'default_name_5',
- 'query-v1-port': '6',
- 'query-v1-status': 'enable',
- 'query-v2c-port': '8',
- 'query-v2c-status': 'enable',
- 'status': 'enable',
- 'trap-v1-lport': '11',
- 'trap-v1-rport': '12',
- 'trap-v1-status': 'enable',
- 'trap-v2c-lport': '14',
- 'trap-v2c-rport': '15',
- 'trap-v2c-status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'community', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_snmp_sysinfo.py b/test/units/modules/network/fortios/test_fortios_system_snmp_sysinfo.py
deleted file mode 100644
index 1c6ea0c2ec..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_snmp_sysinfo.py
+++ /dev/null
@@ -1,207 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_snmp_sysinfo
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_snmp_sysinfo.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_snmp_sysinfo_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_sysinfo': {
- 'contact_info': 'test_value_3',
- 'description': 'test_value_4',
- 'engine_id': 'test_value_5',
- 'location': 'test_value_6',
- 'status': 'enable',
- 'trap_high_cpu_threshold': '8',
- 'trap_log_full_threshold': '9',
- 'trap_low_memory_threshold': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_sysinfo.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'contact-info': 'test_value_3',
- 'description': 'test_value_4',
- 'engine-id': 'test_value_5',
- 'location': 'test_value_6',
- 'status': 'enable',
- 'trap-high-cpu-threshold': '8',
- 'trap-log-full-threshold': '9',
- 'trap-low-memory-threshold': '10'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'sysinfo', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_snmp_sysinfo_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_sysinfo': {
- 'contact_info': 'test_value_3',
- 'description': 'test_value_4',
- 'engine_id': 'test_value_5',
- 'location': 'test_value_6',
- 'status': 'enable',
- 'trap_high_cpu_threshold': '8',
- 'trap_log_full_threshold': '9',
- 'trap_low_memory_threshold': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_sysinfo.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'contact-info': 'test_value_3',
- 'description': 'test_value_4',
- 'engine-id': 'test_value_5',
- 'location': 'test_value_6',
- 'status': 'enable',
- 'trap-high-cpu-threshold': '8',
- 'trap-log-full-threshold': '9',
- 'trap-low-memory-threshold': '10'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'sysinfo', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_snmp_sysinfo_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_sysinfo': {
- 'contact_info': 'test_value_3',
- 'description': 'test_value_4',
- 'engine_id': 'test_value_5',
- 'location': 'test_value_6',
- 'status': 'enable',
- 'trap_high_cpu_threshold': '8',
- 'trap_log_full_threshold': '9',
- 'trap_low_memory_threshold': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_sysinfo.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'contact-info': 'test_value_3',
- 'description': 'test_value_4',
- 'engine-id': 'test_value_5',
- 'location': 'test_value_6',
- 'status': 'enable',
- 'trap-high-cpu-threshold': '8',
- 'trap-log-full-threshold': '9',
- 'trap-low-memory-threshold': '10'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'sysinfo', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_snmp_sysinfo_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_sysinfo': {
- 'random_attribute_not_valid': 'tag',
- 'contact_info': 'test_value_3',
- 'description': 'test_value_4',
- 'engine_id': 'test_value_5',
- 'location': 'test_value_6',
- 'status': 'enable',
- 'trap_high_cpu_threshold': '8',
- 'trap_log_full_threshold': '9',
- 'trap_low_memory_threshold': '10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_sysinfo.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'contact-info': 'test_value_3',
- 'description': 'test_value_4',
- 'engine-id': 'test_value_5',
- 'location': 'test_value_6',
- 'status': 'enable',
- 'trap-high-cpu-threshold': '8',
- 'trap-log-full-threshold': '9',
- 'trap-low-memory-threshold': '10'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'sysinfo', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_snmp_user.py b/test/units/modules/network/fortios/test_fortios_system_snmp_user.py
deleted file mode 100644
index 07488cf9f4..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_snmp_user.py
+++ /dev/null
@@ -1,339 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_snmp_user
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_snmp_user.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_snmp_user_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_user': {
- 'auth_proto': 'md5',
- 'auth_pwd': 'test_value_4',
- 'ha_direct': 'enable',
- 'name': 'default_name_6',
- 'priv_proto': 'aes',
- 'priv_pwd': 'test_value_8',
- 'queries': 'enable',
- 'query_port': '10',
- 'security_level': 'no-auth-no-priv',
- 'source_ip': '84.230.14.12',
- 'source_ipv6': 'test_value_13',
- 'status': 'enable',
- 'trap_lport': '15',
- 'trap_rport': '16',
- 'trap_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_user.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'auth-proto': 'md5',
- 'auth-pwd': 'test_value_4',
- 'ha-direct': 'enable',
- 'name': 'default_name_6',
- 'priv-proto': 'aes',
- 'priv-pwd': 'test_value_8',
- 'queries': 'enable',
- 'query-port': '10',
- 'security-level': 'no-auth-no-priv',
- 'source-ip': '84.230.14.12',
- 'source-ipv6': 'test_value_13',
- 'status': 'enable',
- 'trap-lport': '15',
- 'trap-rport': '16',
- 'trap-status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'user', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_snmp_user_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_user': {
- 'auth_proto': 'md5',
- 'auth_pwd': 'test_value_4',
- 'ha_direct': 'enable',
- 'name': 'default_name_6',
- 'priv_proto': 'aes',
- 'priv_pwd': 'test_value_8',
- 'queries': 'enable',
- 'query_port': '10',
- 'security_level': 'no-auth-no-priv',
- 'source_ip': '84.230.14.12',
- 'source_ipv6': 'test_value_13',
- 'status': 'enable',
- 'trap_lport': '15',
- 'trap_rport': '16',
- 'trap_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_user.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'auth-proto': 'md5',
- 'auth-pwd': 'test_value_4',
- 'ha-direct': 'enable',
- 'name': 'default_name_6',
- 'priv-proto': 'aes',
- 'priv-pwd': 'test_value_8',
- 'queries': 'enable',
- 'query-port': '10',
- 'security-level': 'no-auth-no-priv',
- 'source-ip': '84.230.14.12',
- 'source-ipv6': 'test_value_13',
- 'status': 'enable',
- 'trap-lport': '15',
- 'trap-rport': '16',
- 'trap-status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'user', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_snmp_user_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_snmp_user': {
- 'auth_proto': 'md5',
- 'auth_pwd': 'test_value_4',
- 'ha_direct': 'enable',
- 'name': 'default_name_6',
- 'priv_proto': 'aes',
- 'priv_pwd': 'test_value_8',
- 'queries': 'enable',
- 'query_port': '10',
- 'security_level': 'no-auth-no-priv',
- 'source_ip': '84.230.14.12',
- 'source_ipv6': 'test_value_13',
- 'status': 'enable',
- 'trap_lport': '15',
- 'trap_rport': '16',
- 'trap_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_user.fortios_system_snmp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.snmp', 'user', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_snmp_user_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_snmp_user': {
- 'auth_proto': 'md5',
- 'auth_pwd': 'test_value_4',
- 'ha_direct': 'enable',
- 'name': 'default_name_6',
- 'priv_proto': 'aes',
- 'priv_pwd': 'test_value_8',
- 'queries': 'enable',
- 'query_port': '10',
- 'security_level': 'no-auth-no-priv',
- 'source_ip': '84.230.14.12',
- 'source_ipv6': 'test_value_13',
- 'status': 'enable',
- 'trap_lport': '15',
- 'trap_rport': '16',
- 'trap_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_user.fortios_system_snmp(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system.snmp', 'user', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_snmp_user_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_user': {
- 'auth_proto': 'md5',
- 'auth_pwd': 'test_value_4',
- 'ha_direct': 'enable',
- 'name': 'default_name_6',
- 'priv_proto': 'aes',
- 'priv_pwd': 'test_value_8',
- 'queries': 'enable',
- 'query_port': '10',
- 'security_level': 'no-auth-no-priv',
- 'source_ip': '84.230.14.12',
- 'source_ipv6': 'test_value_13',
- 'status': 'enable',
- 'trap_lport': '15',
- 'trap_rport': '16',
- 'trap_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_user.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'auth-proto': 'md5',
- 'auth-pwd': 'test_value_4',
- 'ha-direct': 'enable',
- 'name': 'default_name_6',
- 'priv-proto': 'aes',
- 'priv-pwd': 'test_value_8',
- 'queries': 'enable',
- 'query-port': '10',
- 'security-level': 'no-auth-no-priv',
- 'source-ip': '84.230.14.12',
- 'source-ipv6': 'test_value_13',
- 'status': 'enable',
- 'trap-lport': '15',
- 'trap-rport': '16',
- 'trap-status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'user', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_snmp_user_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_snmp_user': {
- 'random_attribute_not_valid': 'tag',
- 'auth_proto': 'md5',
- 'auth_pwd': 'test_value_4',
- 'ha_direct': 'enable',
- 'name': 'default_name_6',
- 'priv_proto': 'aes',
- 'priv_pwd': 'test_value_8',
- 'queries': 'enable',
- 'query_port': '10',
- 'security_level': 'no-auth-no-priv',
- 'source_ip': '84.230.14.12',
- 'source_ipv6': 'test_value_13',
- 'status': 'enable',
- 'trap_lport': '15',
- 'trap_rport': '16',
- 'trap_status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_snmp_user.fortios_system_snmp(input_data, fos_instance)
-
- expected_data = {
- 'auth-proto': 'md5',
- 'auth-pwd': 'test_value_4',
- 'ha-direct': 'enable',
- 'name': 'default_name_6',
- 'priv-proto': 'aes',
- 'priv-pwd': 'test_value_8',
- 'queries': 'enable',
- 'query-port': '10',
- 'security-level': 'no-auth-no-priv',
- 'source-ip': '84.230.14.12',
- 'source-ipv6': 'test_value_13',
- 'status': 'enable',
- 'trap-lport': '15',
- 'trap-rport': '16',
- 'trap-status': 'enable'
- }
-
- set_method_mock.assert_called_with('system.snmp', 'user', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_storage.py b/test/units/modules/network/fortios/test_fortios_system_storage.py
deleted file mode 100644
index 31988e0bbe..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_storage.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_storage
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_storage.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_storage_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_storage': {
- 'device': 'test_value_3',
- 'media_status': 'enable',
- 'name': 'default_name_5',
- 'order': '6',
- 'partition': 'test_value_7',
- 'size': '8',
- 'status': 'enable',
- 'usage': 'log',
- 'wanopt_mode': 'mix'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_storage.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'media-status': 'enable',
- 'name': 'default_name_5',
- 'order': '6',
- 'partition': 'test_value_7',
- 'size': '8',
- 'status': 'enable',
- 'usage': 'log',
- 'wanopt-mode': 'mix'
- }
-
- set_method_mock.assert_called_with('system', 'storage', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_storage_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_storage': {
- 'device': 'test_value_3',
- 'media_status': 'enable',
- 'name': 'default_name_5',
- 'order': '6',
- 'partition': 'test_value_7',
- 'size': '8',
- 'status': 'enable',
- 'usage': 'log',
- 'wanopt_mode': 'mix'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_storage.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'media-status': 'enable',
- 'name': 'default_name_5',
- 'order': '6',
- 'partition': 'test_value_7',
- 'size': '8',
- 'status': 'enable',
- 'usage': 'log',
- 'wanopt-mode': 'mix'
- }
-
- set_method_mock.assert_called_with('system', 'storage', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_storage_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_storage': {
- 'device': 'test_value_3',
- 'media_status': 'enable',
- 'name': 'default_name_5',
- 'order': '6',
- 'partition': 'test_value_7',
- 'size': '8',
- 'status': 'enable',
- 'usage': 'log',
- 'wanopt_mode': 'mix'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_storage.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'storage', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_storage_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_storage': {
- 'device': 'test_value_3',
- 'media_status': 'enable',
- 'name': 'default_name_5',
- 'order': '6',
- 'partition': 'test_value_7',
- 'size': '8',
- 'status': 'enable',
- 'usage': 'log',
- 'wanopt_mode': 'mix'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_storage.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'storage', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_storage_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_storage': {
- 'device': 'test_value_3',
- 'media_status': 'enable',
- 'name': 'default_name_5',
- 'order': '6',
- 'partition': 'test_value_7',
- 'size': '8',
- 'status': 'enable',
- 'usage': 'log',
- 'wanopt_mode': 'mix'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_storage.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'media-status': 'enable',
- 'name': 'default_name_5',
- 'order': '6',
- 'partition': 'test_value_7',
- 'size': '8',
- 'status': 'enable',
- 'usage': 'log',
- 'wanopt-mode': 'mix'
- }
-
- set_method_mock.assert_called_with('system', 'storage', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_storage_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_storage': {
- 'random_attribute_not_valid': 'tag',
- 'device': 'test_value_3',
- 'media_status': 'enable',
- 'name': 'default_name_5',
- 'order': '6',
- 'partition': 'test_value_7',
- 'size': '8',
- 'status': 'enable',
- 'usage': 'log',
- 'wanopt_mode': 'mix'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_storage.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'media-status': 'enable',
- 'name': 'default_name_5',
- 'order': '6',
- 'partition': 'test_value_7',
- 'size': '8',
- 'status': 'enable',
- 'usage': 'log',
- 'wanopt-mode': 'mix'
- }
-
- set_method_mock.assert_called_with('system', 'storage', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_switch_interface.py b/test/units/modules/network/fortios/test_fortios_system_switch_interface.py
deleted file mode 100644
index db4bb7499f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_switch_interface.py
+++ /dev/null
@@ -1,259 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_switch_interface
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_switch_interface.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_switch_interface_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_switch_interface': {
- 'intra_switch_policy': 'implicit',
- 'name': 'default_name_4',
- 'span': 'disable',
- 'span_dest_port': 'test_value_6',
- 'span_direction': 'rx',
- 'type': 'switch',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_switch_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'intra-switch-policy': 'implicit',
- 'name': 'default_name_4',
- 'span': 'disable',
- 'span-dest-port': 'test_value_6',
- 'span-direction': 'rx',
- 'type': 'switch',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'switch-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_switch_interface_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_switch_interface': {
- 'intra_switch_policy': 'implicit',
- 'name': 'default_name_4',
- 'span': 'disable',
- 'span_dest_port': 'test_value_6',
- 'span_direction': 'rx',
- 'type': 'switch',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_switch_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'intra-switch-policy': 'implicit',
- 'name': 'default_name_4',
- 'span': 'disable',
- 'span-dest-port': 'test_value_6',
- 'span-direction': 'rx',
- 'type': 'switch',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'switch-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_switch_interface_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_switch_interface': {
- 'intra_switch_policy': 'implicit',
- 'name': 'default_name_4',
- 'span': 'disable',
- 'span_dest_port': 'test_value_6',
- 'span_direction': 'rx',
- 'type': 'switch',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_switch_interface.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'switch-interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_switch_interface_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_switch_interface': {
- 'intra_switch_policy': 'implicit',
- 'name': 'default_name_4',
- 'span': 'disable',
- 'span_dest_port': 'test_value_6',
- 'span_direction': 'rx',
- 'type': 'switch',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_switch_interface.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'switch-interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_switch_interface_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_switch_interface': {
- 'intra_switch_policy': 'implicit',
- 'name': 'default_name_4',
- 'span': 'disable',
- 'span_dest_port': 'test_value_6',
- 'span_direction': 'rx',
- 'type': 'switch',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_switch_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'intra-switch-policy': 'implicit',
- 'name': 'default_name_4',
- 'span': 'disable',
- 'span-dest-port': 'test_value_6',
- 'span-direction': 'rx',
- 'type': 'switch',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'switch-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_switch_interface_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_switch_interface': {
- 'random_attribute_not_valid': 'tag',
- 'intra_switch_policy': 'implicit',
- 'name': 'default_name_4',
- 'span': 'disable',
- 'span_dest_port': 'test_value_6',
- 'span_direction': 'rx',
- 'type': 'switch',
- 'vdom': 'test_value_9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_switch_interface.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'intra-switch-policy': 'implicit',
- 'name': 'default_name_4',
- 'span': 'disable',
- 'span-dest-port': 'test_value_6',
- 'span-direction': 'rx',
- 'type': 'switch',
- 'vdom': 'test_value_9'
- }
-
- set_method_mock.assert_called_with('system', 'switch-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_tos_based_priority.py b/test/units/modules/network/fortios/test_fortios_system_tos_based_priority.py
deleted file mode 100644
index 2631debba9..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_tos_based_priority.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_tos_based_priority
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_tos_based_priority.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_tos_based_priority_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_tos_based_priority': {
- 'id': '3',
- 'priority': 'low',
- 'tos': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_tos_based_priority.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'priority': 'low',
- 'tos': '5'
- }
-
- set_method_mock.assert_called_with('system', 'tos-based-priority', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_tos_based_priority_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_tos_based_priority': {
- 'id': '3',
- 'priority': 'low',
- 'tos': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_tos_based_priority.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'priority': 'low',
- 'tos': '5'
- }
-
- set_method_mock.assert_called_with('system', 'tos-based-priority', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_tos_based_priority_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_tos_based_priority': {
- 'id': '3',
- 'priority': 'low',
- 'tos': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_tos_based_priority.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'tos-based-priority', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_tos_based_priority_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_tos_based_priority': {
- 'id': '3',
- 'priority': 'low',
- 'tos': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_tos_based_priority.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'tos-based-priority', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_tos_based_priority_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_tos_based_priority': {
- 'id': '3',
- 'priority': 'low',
- 'tos': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_tos_based_priority.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'priority': 'low',
- 'tos': '5'
- }
-
- set_method_mock.assert_called_with('system', 'tos-based-priority', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_tos_based_priority_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_tos_based_priority': {
- 'random_attribute_not_valid': 'tag',
- 'id': '3',
- 'priority': 'low',
- 'tos': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_tos_based_priority.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'priority': 'low',
- 'tos': '5'
- }
-
- set_method_mock.assert_called_with('system', 'tos-based-priority', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_vdom.py b/test/units/modules/network/fortios/test_fortios_system_vdom.py
deleted file mode 100644
index 131f125ff0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_vdom.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_vdom
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_vdom.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_vdom_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom': {
- 'name': 'default_name_3',
- 'short_name': 'test_value_4',
- 'temporary': '5',
- 'vcluster_id': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'short-name': 'test_value_4',
- 'temporary': '5',
- 'vcluster-id': '6'
- }
-
- set_method_mock.assert_called_with('system', 'vdom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom': {
- 'name': 'default_name_3',
- 'short_name': 'test_value_4',
- 'temporary': '5',
- 'vcluster_id': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'short-name': 'test_value_4',
- 'temporary': '5',
- 'vcluster-id': '6'
- }
-
- set_method_mock.assert_called_with('system', 'vdom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vdom': {
- 'name': 'default_name_3',
- 'short_name': 'test_value_4',
- 'temporary': '5',
- 'vcluster_id': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vdom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vdom': {
- 'name': 'default_name_3',
- 'short_name': 'test_value_4',
- 'temporary': '5',
- 'vcluster_id': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vdom', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom': {
- 'name': 'default_name_3',
- 'short_name': 'test_value_4',
- 'temporary': '5',
- 'vcluster_id': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'short-name': 'test_value_4',
- 'temporary': '5',
- 'vcluster-id': '6'
- }
-
- set_method_mock.assert_called_with('system', 'vdom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_vdom_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
- 'short_name': 'test_value_4',
- 'temporary': '5',
- 'vcluster_id': '6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'short-name': 'test_value_4',
- 'temporary': '5',
- 'vcluster-id': '6'
- }
-
- set_method_mock.assert_called_with('system', 'vdom', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_vdom_dns.py b/test/units/modules/network/fortios/test_fortios_system_vdom_dns.py
deleted file mode 100644
index 35484cd53b..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_vdom_dns.py
+++ /dev/null
@@ -1,191 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_vdom_dns
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_vdom_dns.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_vdom_dns_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_dns': {
- 'ip6_primary': 'test_value_3',
- 'ip6_secondary': 'test_value_4',
- 'primary': 'test_value_5',
- 'secondary': 'test_value_6',
- 'source_ip': '84.230.14.7',
- 'vdom_dns': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ip6-primary': 'test_value_3',
- 'ip6-secondary': 'test_value_4',
- 'primary': 'test_value_5',
- 'secondary': 'test_value_6',
- 'source-ip': '84.230.14.7',
- 'vdom-dns': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_dns_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_dns': {
- 'ip6_primary': 'test_value_3',
- 'ip6_secondary': 'test_value_4',
- 'primary': 'test_value_5',
- 'secondary': 'test_value_6',
- 'source_ip': '84.230.14.7',
- 'vdom_dns': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ip6-primary': 'test_value_3',
- 'ip6-secondary': 'test_value_4',
- 'primary': 'test_value_5',
- 'secondary': 'test_value_6',
- 'source-ip': '84.230.14.7',
- 'vdom-dns': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_dns_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_dns': {
- 'ip6_primary': 'test_value_3',
- 'ip6_secondary': 'test_value_4',
- 'primary': 'test_value_5',
- 'secondary': 'test_value_6',
- 'source_ip': '84.230.14.7',
- 'vdom_dns': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ip6-primary': 'test_value_3',
- 'ip6-secondary': 'test_value_4',
- 'primary': 'test_value_5',
- 'secondary': 'test_value_6',
- 'source-ip': '84.230.14.7',
- 'vdom-dns': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_vdom_dns_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_dns': {
- 'random_attribute_not_valid': 'tag',
- 'ip6_primary': 'test_value_3',
- 'ip6_secondary': 'test_value_4',
- 'primary': 'test_value_5',
- 'secondary': 'test_value_6',
- 'source_ip': '84.230.14.7',
- 'vdom_dns': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_dns.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'ip6-primary': 'test_value_3',
- 'ip6-secondary': 'test_value_4',
- 'primary': 'test_value_5',
- 'secondary': 'test_value_6',
- 'source-ip': '84.230.14.7',
- 'vdom-dns': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-dns', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_vdom_exception.py b/test/units/modules/network/fortios/test_fortios_system_vdom_exception.py
deleted file mode 100644
index aecea72e75..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_vdom_exception.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_vdom_exception
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_vdom_exception.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_vdom_exception_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_exception': {
- 'id': '3',
- 'object': 'log.fortianalyzer.setting',
- 'oid': '5',
- 'scope': 'all',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_exception.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'object': 'log.fortianalyzer.setting',
- 'oid': '5',
- 'scope': 'all',
-
- }
-
- set_method_mock.assert_called_with('system', 'vdom-exception', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_exception_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_exception': {
- 'id': '3',
- 'object': 'log.fortianalyzer.setting',
- 'oid': '5',
- 'scope': 'all',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_exception.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'object': 'log.fortianalyzer.setting',
- 'oid': '5',
- 'scope': 'all',
-
- }
-
- set_method_mock.assert_called_with('system', 'vdom-exception', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_exception_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vdom_exception': {
- 'id': '3',
- 'object': 'log.fortianalyzer.setting',
- 'oid': '5',
- 'scope': 'all',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_exception.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vdom-exception', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_exception_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vdom_exception': {
- 'id': '3',
- 'object': 'log.fortianalyzer.setting',
- 'oid': '5',
- 'scope': 'all',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_exception.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vdom-exception', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_exception_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_exception': {
- 'id': '3',
- 'object': 'log.fortianalyzer.setting',
- 'oid': '5',
- 'scope': 'all',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_exception.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'object': 'log.fortianalyzer.setting',
- 'oid': '5',
- 'scope': 'all',
-
- }
-
- set_method_mock.assert_called_with('system', 'vdom-exception', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_vdom_exception_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_exception': {
- 'random_attribute_not_valid': 'tag',
- 'id': '3',
- 'object': 'log.fortianalyzer.setting',
- 'oid': '5',
- 'scope': 'all',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_exception.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'object': 'log.fortianalyzer.setting',
- 'oid': '5',
- 'scope': 'all',
-
- }
-
- set_method_mock.assert_called_with('system', 'vdom-exception', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_vdom_link.py b/test/units/modules/network/fortios/test_fortios_system_vdom_link.py
deleted file mode 100644
index 19a7045aff..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_vdom_link.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_vdom_link
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_vdom_link.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_vdom_link_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_link': {
- 'name': 'default_name_3',
- 'type': 'ppp',
- 'vcluster': 'vcluster1'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_link.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'type': 'ppp',
- 'vcluster': 'vcluster1'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-link', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_link_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_link': {
- 'name': 'default_name_3',
- 'type': 'ppp',
- 'vcluster': 'vcluster1'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_link.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'type': 'ppp',
- 'vcluster': 'vcluster1'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-link', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_link_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vdom_link': {
- 'name': 'default_name_3',
- 'type': 'ppp',
- 'vcluster': 'vcluster1'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_link.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vdom-link', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_link_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vdom_link': {
- 'name': 'default_name_3',
- 'type': 'ppp',
- 'vcluster': 'vcluster1'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_link.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vdom-link', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_link_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_link': {
- 'name': 'default_name_3',
- 'type': 'ppp',
- 'vcluster': 'vcluster1'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_link.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'type': 'ppp',
- 'vcluster': 'vcluster1'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-link', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_vdom_link_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_link': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
- 'type': 'ppp',
- 'vcluster': 'vcluster1'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_link.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'type': 'ppp',
- 'vcluster': 'vcluster1'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-link', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_vdom_netflow.py b/test/units/modules/network/fortios/test_fortios_system_vdom_netflow.py
deleted file mode 100644
index 5d776847ed..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_vdom_netflow.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_vdom_netflow
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_vdom_netflow.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_vdom_netflow_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_netflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5',
- 'vdom_netflow': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_netflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5',
- 'vdom-netflow': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-netflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_netflow_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_netflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5',
- 'vdom_netflow': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_netflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5',
- 'vdom-netflow': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-netflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_netflow_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_netflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5',
- 'vdom_netflow': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_netflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5',
- 'vdom-netflow': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-netflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_vdom_netflow_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_netflow': {
- 'random_attribute_not_valid': 'tag',
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5',
- 'vdom_netflow': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_netflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5',
- 'vdom-netflow': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-netflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_vdom_property.py b/test/units/modules/network/fortios/test_fortios_system_vdom_property.py
deleted file mode 100644
index f8103f1ba8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_vdom_property.py
+++ /dev/null
@@ -1,399 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_vdom_property
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_vdom_property.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_vdom_property_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_property': {
- 'custom_service': 'test_value_3',
- 'description': 'test_value_4',
- 'dialup_tunnel': 'test_value_5',
- 'firewall_address': 'test_value_6',
- 'firewall_addrgrp': 'test_value_7',
- 'firewall_policy': 'test_value_8',
- 'ipsec_phase1': 'test_value_9',
- 'ipsec_phase1_interface': 'test_value_10',
- 'ipsec_phase2': 'test_value_11',
- 'ipsec_phase2_interface': 'test_value_12',
- 'log_disk_quota': 'test_value_13',
- 'name': 'default_name_14',
- 'onetime_schedule': 'test_value_15',
- 'proxy': 'test_value_16',
- 'recurring_schedule': 'test_value_17',
- 'service_group': 'test_value_18',
- 'session': 'test_value_19',
- 'snmp_index': '20',
- 'sslvpn': 'test_value_21',
- 'user': 'test_value_22',
- 'user_group': 'test_value_23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_property.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'custom-service': 'test_value_3',
- 'description': 'test_value_4',
- 'dialup-tunnel': 'test_value_5',
- 'firewall-address': 'test_value_6',
- 'firewall-addrgrp': 'test_value_7',
- 'firewall-policy': 'test_value_8',
- 'ipsec-phase1': 'test_value_9',
- 'ipsec-phase1-interface': 'test_value_10',
- 'ipsec-phase2': 'test_value_11',
- 'ipsec-phase2-interface': 'test_value_12',
- 'log-disk-quota': 'test_value_13',
- 'name': 'default_name_14',
- 'onetime-schedule': 'test_value_15',
- 'proxy': 'test_value_16',
- 'recurring-schedule': 'test_value_17',
- 'service-group': 'test_value_18',
- 'session': 'test_value_19',
- 'snmp-index': '20',
- 'sslvpn': 'test_value_21',
- 'user': 'test_value_22',
- 'user-group': 'test_value_23'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-property', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_property_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_property': {
- 'custom_service': 'test_value_3',
- 'description': 'test_value_4',
- 'dialup_tunnel': 'test_value_5',
- 'firewall_address': 'test_value_6',
- 'firewall_addrgrp': 'test_value_7',
- 'firewall_policy': 'test_value_8',
- 'ipsec_phase1': 'test_value_9',
- 'ipsec_phase1_interface': 'test_value_10',
- 'ipsec_phase2': 'test_value_11',
- 'ipsec_phase2_interface': 'test_value_12',
- 'log_disk_quota': 'test_value_13',
- 'name': 'default_name_14',
- 'onetime_schedule': 'test_value_15',
- 'proxy': 'test_value_16',
- 'recurring_schedule': 'test_value_17',
- 'service_group': 'test_value_18',
- 'session': 'test_value_19',
- 'snmp_index': '20',
- 'sslvpn': 'test_value_21',
- 'user': 'test_value_22',
- 'user_group': 'test_value_23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_property.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'custom-service': 'test_value_3',
- 'description': 'test_value_4',
- 'dialup-tunnel': 'test_value_5',
- 'firewall-address': 'test_value_6',
- 'firewall-addrgrp': 'test_value_7',
- 'firewall-policy': 'test_value_8',
- 'ipsec-phase1': 'test_value_9',
- 'ipsec-phase1-interface': 'test_value_10',
- 'ipsec-phase2': 'test_value_11',
- 'ipsec-phase2-interface': 'test_value_12',
- 'log-disk-quota': 'test_value_13',
- 'name': 'default_name_14',
- 'onetime-schedule': 'test_value_15',
- 'proxy': 'test_value_16',
- 'recurring-schedule': 'test_value_17',
- 'service-group': 'test_value_18',
- 'session': 'test_value_19',
- 'snmp-index': '20',
- 'sslvpn': 'test_value_21',
- 'user': 'test_value_22',
- 'user-group': 'test_value_23'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-property', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_property_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vdom_property': {
- 'custom_service': 'test_value_3',
- 'description': 'test_value_4',
- 'dialup_tunnel': 'test_value_5',
- 'firewall_address': 'test_value_6',
- 'firewall_addrgrp': 'test_value_7',
- 'firewall_policy': 'test_value_8',
- 'ipsec_phase1': 'test_value_9',
- 'ipsec_phase1_interface': 'test_value_10',
- 'ipsec_phase2': 'test_value_11',
- 'ipsec_phase2_interface': 'test_value_12',
- 'log_disk_quota': 'test_value_13',
- 'name': 'default_name_14',
- 'onetime_schedule': 'test_value_15',
- 'proxy': 'test_value_16',
- 'recurring_schedule': 'test_value_17',
- 'service_group': 'test_value_18',
- 'session': 'test_value_19',
- 'snmp_index': '20',
- 'sslvpn': 'test_value_21',
- 'user': 'test_value_22',
- 'user_group': 'test_value_23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_property.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vdom-property', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_property_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vdom_property': {
- 'custom_service': 'test_value_3',
- 'description': 'test_value_4',
- 'dialup_tunnel': 'test_value_5',
- 'firewall_address': 'test_value_6',
- 'firewall_addrgrp': 'test_value_7',
- 'firewall_policy': 'test_value_8',
- 'ipsec_phase1': 'test_value_9',
- 'ipsec_phase1_interface': 'test_value_10',
- 'ipsec_phase2': 'test_value_11',
- 'ipsec_phase2_interface': 'test_value_12',
- 'log_disk_quota': 'test_value_13',
- 'name': 'default_name_14',
- 'onetime_schedule': 'test_value_15',
- 'proxy': 'test_value_16',
- 'recurring_schedule': 'test_value_17',
- 'service_group': 'test_value_18',
- 'session': 'test_value_19',
- 'snmp_index': '20',
- 'sslvpn': 'test_value_21',
- 'user': 'test_value_22',
- 'user_group': 'test_value_23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_property.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vdom-property', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_property_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_property': {
- 'custom_service': 'test_value_3',
- 'description': 'test_value_4',
- 'dialup_tunnel': 'test_value_5',
- 'firewall_address': 'test_value_6',
- 'firewall_addrgrp': 'test_value_7',
- 'firewall_policy': 'test_value_8',
- 'ipsec_phase1': 'test_value_9',
- 'ipsec_phase1_interface': 'test_value_10',
- 'ipsec_phase2': 'test_value_11',
- 'ipsec_phase2_interface': 'test_value_12',
- 'log_disk_quota': 'test_value_13',
- 'name': 'default_name_14',
- 'onetime_schedule': 'test_value_15',
- 'proxy': 'test_value_16',
- 'recurring_schedule': 'test_value_17',
- 'service_group': 'test_value_18',
- 'session': 'test_value_19',
- 'snmp_index': '20',
- 'sslvpn': 'test_value_21',
- 'user': 'test_value_22',
- 'user_group': 'test_value_23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_property.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'custom-service': 'test_value_3',
- 'description': 'test_value_4',
- 'dialup-tunnel': 'test_value_5',
- 'firewall-address': 'test_value_6',
- 'firewall-addrgrp': 'test_value_7',
- 'firewall-policy': 'test_value_8',
- 'ipsec-phase1': 'test_value_9',
- 'ipsec-phase1-interface': 'test_value_10',
- 'ipsec-phase2': 'test_value_11',
- 'ipsec-phase2-interface': 'test_value_12',
- 'log-disk-quota': 'test_value_13',
- 'name': 'default_name_14',
- 'onetime-schedule': 'test_value_15',
- 'proxy': 'test_value_16',
- 'recurring-schedule': 'test_value_17',
- 'service-group': 'test_value_18',
- 'session': 'test_value_19',
- 'snmp-index': '20',
- 'sslvpn': 'test_value_21',
- 'user': 'test_value_22',
- 'user-group': 'test_value_23'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-property', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_vdom_property_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_property': {
- 'random_attribute_not_valid': 'tag',
- 'custom_service': 'test_value_3',
- 'description': 'test_value_4',
- 'dialup_tunnel': 'test_value_5',
- 'firewall_address': 'test_value_6',
- 'firewall_addrgrp': 'test_value_7',
- 'firewall_policy': 'test_value_8',
- 'ipsec_phase1': 'test_value_9',
- 'ipsec_phase1_interface': 'test_value_10',
- 'ipsec_phase2': 'test_value_11',
- 'ipsec_phase2_interface': 'test_value_12',
- 'log_disk_quota': 'test_value_13',
- 'name': 'default_name_14',
- 'onetime_schedule': 'test_value_15',
- 'proxy': 'test_value_16',
- 'recurring_schedule': 'test_value_17',
- 'service_group': 'test_value_18',
- 'session': 'test_value_19',
- 'snmp_index': '20',
- 'sslvpn': 'test_value_21',
- 'user': 'test_value_22',
- 'user_group': 'test_value_23'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_property.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'custom-service': 'test_value_3',
- 'description': 'test_value_4',
- 'dialup-tunnel': 'test_value_5',
- 'firewall-address': 'test_value_6',
- 'firewall-addrgrp': 'test_value_7',
- 'firewall-policy': 'test_value_8',
- 'ipsec-phase1': 'test_value_9',
- 'ipsec-phase1-interface': 'test_value_10',
- 'ipsec-phase2': 'test_value_11',
- 'ipsec-phase2-interface': 'test_value_12',
- 'log-disk-quota': 'test_value_13',
- 'name': 'default_name_14',
- 'onetime-schedule': 'test_value_15',
- 'proxy': 'test_value_16',
- 'recurring-schedule': 'test_value_17',
- 'service-group': 'test_value_18',
- 'session': 'test_value_19',
- 'snmp-index': '20',
- 'sslvpn': 'test_value_21',
- 'user': 'test_value_22',
- 'user-group': 'test_value_23'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-property', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_vdom_radius_server.py b/test/units/modules/network/fortios/test_fortios_system_vdom_radius_server.py
deleted file mode 100644
index ea96bca294..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_vdom_radius_server.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_vdom_radius_server
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_vdom_radius_server.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_vdom_radius_server_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_radius_server': {
- 'name': 'default_name_3',
- 'radius_server_vdom': 'test_value_4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_radius_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'radius-server-vdom': 'test_value_4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-radius-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_radius_server_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_radius_server': {
- 'name': 'default_name_3',
- 'radius_server_vdom': 'test_value_4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_radius_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'radius-server-vdom': 'test_value_4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-radius-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_radius_server_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vdom_radius_server': {
- 'name': 'default_name_3',
- 'radius_server_vdom': 'test_value_4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_radius_server.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vdom-radius-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_radius_server_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vdom_radius_server': {
- 'name': 'default_name_3',
- 'radius_server_vdom': 'test_value_4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_radius_server.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vdom-radius-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_radius_server_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_radius_server': {
- 'name': 'default_name_3',
- 'radius_server_vdom': 'test_value_4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_radius_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'radius-server-vdom': 'test_value_4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-radius-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_vdom_radius_server_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_radius_server': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
- 'radius_server_vdom': 'test_value_4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_radius_server.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'radius-server-vdom': 'test_value_4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-radius-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_vdom_sflow.py b/test/units/modules/network/fortios/test_fortios_system_vdom_sflow.py
deleted file mode 100644
index e2ffaf07ee..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_vdom_sflow.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_vdom_sflow
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_vdom_sflow.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_vdom_sflow_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_sflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5',
- 'vdom_sflow': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_sflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5',
- 'vdom-sflow': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vdom_sflow_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_sflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5',
- 'vdom_sflow': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_sflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5',
- 'vdom-sflow': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vdom_sflow_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_sflow': {
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5',
- 'vdom_sflow': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_sflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5',
- 'vdom-sflow': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_vdom_sflow_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vdom_sflow': {
- 'random_attribute_not_valid': 'tag',
- 'collector_ip': 'test_value_3',
- 'collector_port': '4',
- 'source_ip': '84.230.14.5',
- 'vdom_sflow': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vdom_sflow.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'collector-ip': 'test_value_3',
- 'collector-port': '4',
- 'source-ip': '84.230.14.5',
- 'vdom-sflow': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'vdom-sflow', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_virtual_wan_link.py b/test/units/modules/network/fortios/test_fortios_system_virtual_wan_link.py
deleted file mode 100644
index a9c329ef1e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_virtual_wan_link.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_virtual_wan_link
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_virtual_wan_link.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_virtual_wan_link_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_virtual_wan_link': {'fail_detect': 'enable',
- 'load_balance_mode': 'source-ip-based',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_virtual_wan_link.fortios_system(input_data, fos_instance)
-
- expected_data = {'fail-detect': 'enable',
- 'load-balance-mode': 'source-ip-based',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'virtual-wan-link', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_virtual_wan_link_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_virtual_wan_link': {'fail_detect': 'enable',
- 'load_balance_mode': 'source-ip-based',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_virtual_wan_link.fortios_system(input_data, fos_instance)
-
- expected_data = {'fail-detect': 'enable',
- 'load-balance-mode': 'source-ip-based',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'virtual-wan-link', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_virtual_wan_link_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_virtual_wan_link': {'fail_detect': 'enable',
- 'load_balance_mode': 'source-ip-based',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_virtual_wan_link.fortios_system(input_data, fos_instance)
-
- expected_data = {'fail-detect': 'enable',
- 'load-balance-mode': 'source-ip-based',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'virtual-wan-link', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_virtual_wan_link_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_virtual_wan_link': {
- 'random_attribute_not_valid': 'tag', 'fail_detect': 'enable',
- 'load_balance_mode': 'source-ip-based',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_virtual_wan_link.fortios_system(input_data, fos_instance)
-
- expected_data = {'fail-detect': 'enable',
- 'load-balance-mode': 'source-ip-based',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('system', 'virtual-wan-link', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_virtual_wire_pair.py b/test/units/modules/network/fortios/test_fortios_system_virtual_wire_pair.py
deleted file mode 100644
index 91106b5b1e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_virtual_wire_pair.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_virtual_wire_pair
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_virtual_wire_pair.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_virtual_wire_pair_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_virtual_wire_pair': {'name': 'default_name_3',
- 'vlan_filter': 'test_value_4',
- 'wildcard_vlan': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_virtual_wire_pair.fortios_system(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'vlan-filter': 'test_value_4',
- 'wildcard-vlan': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'virtual-wire-pair', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_virtual_wire_pair_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_virtual_wire_pair': {'name': 'default_name_3',
- 'vlan_filter': 'test_value_4',
- 'wildcard_vlan': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_virtual_wire_pair.fortios_system(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'vlan-filter': 'test_value_4',
- 'wildcard-vlan': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'virtual-wire-pair', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_virtual_wire_pair_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_virtual_wire_pair': {'name': 'default_name_3',
- 'vlan_filter': 'test_value_4',
- 'wildcard_vlan': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_virtual_wire_pair.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'virtual-wire-pair', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_virtual_wire_pair_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_virtual_wire_pair': {'name': 'default_name_3',
- 'vlan_filter': 'test_value_4',
- 'wildcard_vlan': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_virtual_wire_pair.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'virtual-wire-pair', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_virtual_wire_pair_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_virtual_wire_pair': {'name': 'default_name_3',
- 'vlan_filter': 'test_value_4',
- 'wildcard_vlan': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_virtual_wire_pair.fortios_system(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'vlan-filter': 'test_value_4',
- 'wildcard-vlan': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'virtual-wire-pair', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_virtual_wire_pair_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_virtual_wire_pair': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3',
- 'vlan_filter': 'test_value_4',
- 'wildcard_vlan': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_virtual_wire_pair.fortios_system(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'vlan-filter': 'test_value_4',
- 'wildcard-vlan': 'enable'
- }
-
- set_method_mock.assert_called_with('system', 'virtual-wire-pair', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_vxlan.py b/test/units/modules/network/fortios/test_fortios_system_vxlan.py
deleted file mode 100644
index 1a8817a000..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_vxlan.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_vxlan
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_vxlan.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_vxlan_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vxlan': {
- 'dstport': '3',
- 'interface': 'test_value_4',
- 'ip_version': 'ipv4-unicast',
- 'multicast_ttl': '6',
- 'name': 'default_name_7',
- 'vni': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vxlan.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'dstport': '3',
- 'interface': 'test_value_4',
- 'ip-version': 'ipv4-unicast',
- 'multicast-ttl': '6',
- 'name': 'default_name_7',
- 'vni': '8'
- }
-
- set_method_mock.assert_called_with('system', 'vxlan', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vxlan_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vxlan': {
- 'dstport': '3',
- 'interface': 'test_value_4',
- 'ip_version': 'ipv4-unicast',
- 'multicast_ttl': '6',
- 'name': 'default_name_7',
- 'vni': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vxlan.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'dstport': '3',
- 'interface': 'test_value_4',
- 'ip-version': 'ipv4-unicast',
- 'multicast-ttl': '6',
- 'name': 'default_name_7',
- 'vni': '8'
- }
-
- set_method_mock.assert_called_with('system', 'vxlan', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vxlan_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vxlan': {
- 'dstport': '3',
- 'interface': 'test_value_4',
- 'ip_version': 'ipv4-unicast',
- 'multicast_ttl': '6',
- 'name': 'default_name_7',
- 'vni': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vxlan.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vxlan', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_vxlan_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_vxlan': {
- 'dstport': '3',
- 'interface': 'test_value_4',
- 'ip_version': 'ipv4-unicast',
- 'multicast_ttl': '6',
- 'name': 'default_name_7',
- 'vni': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vxlan.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'vxlan', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_vxlan_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vxlan': {
- 'dstport': '3',
- 'interface': 'test_value_4',
- 'ip_version': 'ipv4-unicast',
- 'multicast_ttl': '6',
- 'name': 'default_name_7',
- 'vni': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vxlan.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'dstport': '3',
- 'interface': 'test_value_4',
- 'ip-version': 'ipv4-unicast',
- 'multicast-ttl': '6',
- 'name': 'default_name_7',
- 'vni': '8'
- }
-
- set_method_mock.assert_called_with('system', 'vxlan', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_vxlan_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_vxlan': {
- 'random_attribute_not_valid': 'tag',
- 'dstport': '3',
- 'interface': 'test_value_4',
- 'ip_version': 'ipv4-unicast',
- 'multicast_ttl': '6',
- 'name': 'default_name_7',
- 'vni': '8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_vxlan.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'dstport': '3',
- 'interface': 'test_value_4',
- 'ip-version': 'ipv4-unicast',
- 'multicast-ttl': '6',
- 'name': 'default_name_7',
- 'vni': '8'
- }
-
- set_method_mock.assert_called_with('system', 'vxlan', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_wccp.py b/test/units/modules/network/fortios/test_fortios_system_wccp.py
deleted file mode 100644
index 855fbddba6..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_wccp.py
+++ /dev/null
@@ -1,419 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_wccp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_wccp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_wccp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_wccp': {
- 'assignment_bucket_format': 'wccp-v2',
- 'assignment_dstaddr_mask': 'test_value_4',
- 'assignment_method': 'HASH',
- 'assignment_srcaddr_mask': 'test_value_6',
- 'assignment_weight': '7',
- 'authentication': 'enable',
- 'cache_engine_method': 'GRE',
- 'cache_id': 'test_value_10',
- 'forward_method': 'GRE',
- 'group_address': 'test_value_12',
- 'password': 'test_value_13',
- 'ports': 'test_value_14',
- 'ports_defined': 'source',
- 'primary_hash': 'src-ip',
- 'priority': '17',
- 'protocol': '18',
- 'return_method': 'GRE',
- 'router_id': 'test_value_20',
- 'router_list': 'test_value_21',
- 'server_list': 'test_value_22',
- 'server_type': 'forward',
- 'service_id': 'test_value_24',
- 'service_type': 'auto'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_wccp.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'assignment-bucket-format': 'wccp-v2',
- 'assignment-dstaddr-mask': 'test_value_4',
- 'assignment-method': 'HASH',
- 'assignment-srcaddr-mask': 'test_value_6',
- 'assignment-weight': '7',
- 'authentication': 'enable',
- 'cache-engine-method': 'GRE',
- 'cache-id': 'test_value_10',
- 'forward-method': 'GRE',
- 'group-address': 'test_value_12',
- 'password': 'test_value_13',
- 'ports': 'test_value_14',
- 'ports-defined': 'source',
- 'primary-hash': 'src-ip',
- 'priority': '17',
- 'protocol': '18',
- 'return-method': 'GRE',
- 'router-id': 'test_value_20',
- 'router-list': 'test_value_21',
- 'server-list': 'test_value_22',
- 'server-type': 'forward',
- 'service-id': 'test_value_24',
- 'service-type': 'auto'
- }
-
- set_method_mock.assert_called_with('system', 'wccp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_wccp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_wccp': {
- 'assignment_bucket_format': 'wccp-v2',
- 'assignment_dstaddr_mask': 'test_value_4',
- 'assignment_method': 'HASH',
- 'assignment_srcaddr_mask': 'test_value_6',
- 'assignment_weight': '7',
- 'authentication': 'enable',
- 'cache_engine_method': 'GRE',
- 'cache_id': 'test_value_10',
- 'forward_method': 'GRE',
- 'group_address': 'test_value_12',
- 'password': 'test_value_13',
- 'ports': 'test_value_14',
- 'ports_defined': 'source',
- 'primary_hash': 'src-ip',
- 'priority': '17',
- 'protocol': '18',
- 'return_method': 'GRE',
- 'router_id': 'test_value_20',
- 'router_list': 'test_value_21',
- 'server_list': 'test_value_22',
- 'server_type': 'forward',
- 'service_id': 'test_value_24',
- 'service_type': 'auto'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_wccp.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'assignment-bucket-format': 'wccp-v2',
- 'assignment-dstaddr-mask': 'test_value_4',
- 'assignment-method': 'HASH',
- 'assignment-srcaddr-mask': 'test_value_6',
- 'assignment-weight': '7',
- 'authentication': 'enable',
- 'cache-engine-method': 'GRE',
- 'cache-id': 'test_value_10',
- 'forward-method': 'GRE',
- 'group-address': 'test_value_12',
- 'password': 'test_value_13',
- 'ports': 'test_value_14',
- 'ports-defined': 'source',
- 'primary-hash': 'src-ip',
- 'priority': '17',
- 'protocol': '18',
- 'return-method': 'GRE',
- 'router-id': 'test_value_20',
- 'router-list': 'test_value_21',
- 'server-list': 'test_value_22',
- 'server-type': 'forward',
- 'service-id': 'test_value_24',
- 'service-type': 'auto'
- }
-
- set_method_mock.assert_called_with('system', 'wccp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_wccp_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_wccp': {
- 'assignment_bucket_format': 'wccp-v2',
- 'assignment_dstaddr_mask': 'test_value_4',
- 'assignment_method': 'HASH',
- 'assignment_srcaddr_mask': 'test_value_6',
- 'assignment_weight': '7',
- 'authentication': 'enable',
- 'cache_engine_method': 'GRE',
- 'cache_id': 'test_value_10',
- 'forward_method': 'GRE',
- 'group_address': 'test_value_12',
- 'password': 'test_value_13',
- 'ports': 'test_value_14',
- 'ports_defined': 'source',
- 'primary_hash': 'src-ip',
- 'priority': '17',
- 'protocol': '18',
- 'return_method': 'GRE',
- 'router_id': 'test_value_20',
- 'router_list': 'test_value_21',
- 'server_list': 'test_value_22',
- 'server_type': 'forward',
- 'service_id': 'test_value_24',
- 'service_type': 'auto'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_wccp.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'wccp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_wccp_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_wccp': {
- 'assignment_bucket_format': 'wccp-v2',
- 'assignment_dstaddr_mask': 'test_value_4',
- 'assignment_method': 'HASH',
- 'assignment_srcaddr_mask': 'test_value_6',
- 'assignment_weight': '7',
- 'authentication': 'enable',
- 'cache_engine_method': 'GRE',
- 'cache_id': 'test_value_10',
- 'forward_method': 'GRE',
- 'group_address': 'test_value_12',
- 'password': 'test_value_13',
- 'ports': 'test_value_14',
- 'ports_defined': 'source',
- 'primary_hash': 'src-ip',
- 'priority': '17',
- 'protocol': '18',
- 'return_method': 'GRE',
- 'router_id': 'test_value_20',
- 'router_list': 'test_value_21',
- 'server_list': 'test_value_22',
- 'server_type': 'forward',
- 'service_id': 'test_value_24',
- 'service_type': 'auto'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_wccp.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'wccp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_wccp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_wccp': {
- 'assignment_bucket_format': 'wccp-v2',
- 'assignment_dstaddr_mask': 'test_value_4',
- 'assignment_method': 'HASH',
- 'assignment_srcaddr_mask': 'test_value_6',
- 'assignment_weight': '7',
- 'authentication': 'enable',
- 'cache_engine_method': 'GRE',
- 'cache_id': 'test_value_10',
- 'forward_method': 'GRE',
- 'group_address': 'test_value_12',
- 'password': 'test_value_13',
- 'ports': 'test_value_14',
- 'ports_defined': 'source',
- 'primary_hash': 'src-ip',
- 'priority': '17',
- 'protocol': '18',
- 'return_method': 'GRE',
- 'router_id': 'test_value_20',
- 'router_list': 'test_value_21',
- 'server_list': 'test_value_22',
- 'server_type': 'forward',
- 'service_id': 'test_value_24',
- 'service_type': 'auto'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_wccp.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'assignment-bucket-format': 'wccp-v2',
- 'assignment-dstaddr-mask': 'test_value_4',
- 'assignment-method': 'HASH',
- 'assignment-srcaddr-mask': 'test_value_6',
- 'assignment-weight': '7',
- 'authentication': 'enable',
- 'cache-engine-method': 'GRE',
- 'cache-id': 'test_value_10',
- 'forward-method': 'GRE',
- 'group-address': 'test_value_12',
- 'password': 'test_value_13',
- 'ports': 'test_value_14',
- 'ports-defined': 'source',
- 'primary-hash': 'src-ip',
- 'priority': '17',
- 'protocol': '18',
- 'return-method': 'GRE',
- 'router-id': 'test_value_20',
- 'router-list': 'test_value_21',
- 'server-list': 'test_value_22',
- 'server-type': 'forward',
- 'service-id': 'test_value_24',
- 'service-type': 'auto'
- }
-
- set_method_mock.assert_called_with('system', 'wccp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_wccp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_wccp': {
- 'random_attribute_not_valid': 'tag',
- 'assignment_bucket_format': 'wccp-v2',
- 'assignment_dstaddr_mask': 'test_value_4',
- 'assignment_method': 'HASH',
- 'assignment_srcaddr_mask': 'test_value_6',
- 'assignment_weight': '7',
- 'authentication': 'enable',
- 'cache_engine_method': 'GRE',
- 'cache_id': 'test_value_10',
- 'forward_method': 'GRE',
- 'group_address': 'test_value_12',
- 'password': 'test_value_13',
- 'ports': 'test_value_14',
- 'ports_defined': 'source',
- 'primary_hash': 'src-ip',
- 'priority': '17',
- 'protocol': '18',
- 'return_method': 'GRE',
- 'router_id': 'test_value_20',
- 'router_list': 'test_value_21',
- 'server_list': 'test_value_22',
- 'server_type': 'forward',
- 'service_id': 'test_value_24',
- 'service_type': 'auto'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_wccp.fortios_system(input_data, fos_instance)
-
- expected_data = {
- 'assignment-bucket-format': 'wccp-v2',
- 'assignment-dstaddr-mask': 'test_value_4',
- 'assignment-method': 'HASH',
- 'assignment-srcaddr-mask': 'test_value_6',
- 'assignment-weight': '7',
- 'authentication': 'enable',
- 'cache-engine-method': 'GRE',
- 'cache-id': 'test_value_10',
- 'forward-method': 'GRE',
- 'group-address': 'test_value_12',
- 'password': 'test_value_13',
- 'ports': 'test_value_14',
- 'ports-defined': 'source',
- 'primary-hash': 'src-ip',
- 'priority': '17',
- 'protocol': '18',
- 'return-method': 'GRE',
- 'router-id': 'test_value_20',
- 'router-list': 'test_value_21',
- 'server-list': 'test_value_22',
- 'server-type': 'forward',
- 'service-id': 'test_value_24',
- 'service-type': 'auto'
- }
-
- set_method_mock.assert_called_with('system', 'wccp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_system_zone.py b/test/units/modules/network/fortios/test_fortios_system_zone.py
deleted file mode 100644
index b56546dcc7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_system_zone.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_system_zone
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_zone.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_system_zone_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_zone': {'intrazone': 'allow',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_zone.fortios_system(input_data, fos_instance)
-
- expected_data = {'intrazone': 'allow',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('system', 'zone', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_zone_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_zone': {'intrazone': 'allow',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_zone.fortios_system(input_data, fos_instance)
-
- expected_data = {'intrazone': 'allow',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('system', 'zone', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_zone_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_zone': {'intrazone': 'allow',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_zone.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'zone', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_system_zone_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'system_zone': {'intrazone': 'allow',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_zone.fortios_system(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('system', 'zone', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_system_zone_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_zone': {'intrazone': 'allow',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_zone.fortios_system(input_data, fos_instance)
-
- expected_data = {'intrazone': 'allow',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('system', 'zone', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_system_zone_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'system_zone': {
- 'random_attribute_not_valid': 'tag', 'intrazone': 'allow',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_system_zone.fortios_system(input_data, fos_instance)
-
- expected_data = {'intrazone': 'allow',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('system', 'zone', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_adgrp.py b/test/units/modules/network/fortios/test_fortios_user_adgrp.py
deleted file mode 100644
index 198ef2cb69..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_adgrp.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_adgrp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_adgrp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_adgrp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_adgrp': {
- 'name': 'default_name_3',
- 'server_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_adgrp.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'server-name': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('user', 'adgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_adgrp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_adgrp': {
- 'name': 'default_name_3',
- 'server_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_adgrp.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'server-name': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('user', 'adgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_adgrp_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_adgrp': {
- 'name': 'default_name_3',
- 'server_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_adgrp.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'adgrp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_adgrp_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_adgrp': {
- 'name': 'default_name_3',
- 'server_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_adgrp.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'adgrp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_adgrp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_adgrp': {
- 'name': 'default_name_3',
- 'server_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_adgrp.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'server-name': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('user', 'adgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_adgrp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_adgrp': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
- 'server_name': 'test_value_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_adgrp.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'server-name': 'test_value_4'
- }
-
- set_method_mock.assert_called_with('user', 'adgrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_device.py b/test/units/modules/network/fortios/test_fortios_user_device.py
deleted file mode 100644
index 1a21c50416..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_device.py
+++ /dev/null
@@ -1,269 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_device
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_device.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_device_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device': {
- 'alias': 'test_value_3',
- 'avatar': 'test_value_4',
- 'category': 'none',
- 'comment': 'Comment.',
- 'mac': 'test_value_7',
- 'master_device': 'test_value_8',
- 'type': 'unknown',
- 'user': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'alias': 'test_value_3',
- 'avatar': 'test_value_4',
- 'category': 'none',
- 'comment': 'Comment.',
- 'mac': 'test_value_7',
- 'master-device': 'test_value_8',
- 'type': 'unknown',
- 'user': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('user', 'device', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_device_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device': {
- 'alias': 'test_value_3',
- 'avatar': 'test_value_4',
- 'category': 'none',
- 'comment': 'Comment.',
- 'mac': 'test_value_7',
- 'master_device': 'test_value_8',
- 'type': 'unknown',
- 'user': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'alias': 'test_value_3',
- 'avatar': 'test_value_4',
- 'category': 'none',
- 'comment': 'Comment.',
- 'mac': 'test_value_7',
- 'master-device': 'test_value_8',
- 'type': 'unknown',
- 'user': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('user', 'device', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_device_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_device': {
- 'alias': 'test_value_3',
- 'avatar': 'test_value_4',
- 'category': 'none',
- 'comment': 'Comment.',
- 'mac': 'test_value_7',
- 'master_device': 'test_value_8',
- 'type': 'unknown',
- 'user': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'device', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_device_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_device': {
- 'alias': 'test_value_3',
- 'avatar': 'test_value_4',
- 'category': 'none',
- 'comment': 'Comment.',
- 'mac': 'test_value_7',
- 'master_device': 'test_value_8',
- 'type': 'unknown',
- 'user': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'device', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_device_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device': {
- 'alias': 'test_value_3',
- 'avatar': 'test_value_4',
- 'category': 'none',
- 'comment': 'Comment.',
- 'mac': 'test_value_7',
- 'master_device': 'test_value_8',
- 'type': 'unknown',
- 'user': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'alias': 'test_value_3',
- 'avatar': 'test_value_4',
- 'category': 'none',
- 'comment': 'Comment.',
- 'mac': 'test_value_7',
- 'master-device': 'test_value_8',
- 'type': 'unknown',
- 'user': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('user', 'device', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_device_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device': {
- 'random_attribute_not_valid': 'tag',
- 'alias': 'test_value_3',
- 'avatar': 'test_value_4',
- 'category': 'none',
- 'comment': 'Comment.',
- 'mac': 'test_value_7',
- 'master_device': 'test_value_8',
- 'type': 'unknown',
- 'user': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'alias': 'test_value_3',
- 'avatar': 'test_value_4',
- 'category': 'none',
- 'comment': 'Comment.',
- 'mac': 'test_value_7',
- 'master-device': 'test_value_8',
- 'type': 'unknown',
- 'user': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('user', 'device', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_device_access_list.py b/test/units/modules/network/fortios/test_fortios_user_device_access_list.py
deleted file mode 100644
index dde15c65e8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_device_access_list.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_device_access_list
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_device_access_list.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_device_access_list_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_access_list': {
- 'default_action': 'accept',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_access_list.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'default-action': 'accept',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('user', 'device-access-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_device_access_list_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_access_list': {
- 'default_action': 'accept',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_access_list.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'default-action': 'accept',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('user', 'device-access-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_device_access_list_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_device_access_list': {
- 'default_action': 'accept',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_access_list.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'device-access-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_device_access_list_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_device_access_list': {
- 'default_action': 'accept',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_access_list.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'device-access-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_device_access_list_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_access_list': {
- 'default_action': 'accept',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_access_list.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'default-action': 'accept',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('user', 'device-access-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_device_access_list_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_access_list': {
- 'random_attribute_not_valid': 'tag',
- 'default_action': 'accept',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_access_list.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'default-action': 'accept',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('user', 'device-access-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_device_category.py b/test/units/modules/network/fortios/test_fortios_user_device_category.py
deleted file mode 100644
index dc09ede1c9..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_device_category.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_device_category
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_device_category.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_device_category_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_category': {
- 'comment': 'Comment.',
- 'desc': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_category.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'desc': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('user', 'device-category', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_device_category_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_category': {
- 'comment': 'Comment.',
- 'desc': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_category.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'desc': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('user', 'device-category', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_device_category_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_device_category': {
- 'comment': 'Comment.',
- 'desc': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_category.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'device-category', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_device_category_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_device_category': {
- 'comment': 'Comment.',
- 'desc': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_category.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'device-category', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_device_category_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_category': {
- 'comment': 'Comment.',
- 'desc': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_category.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'desc': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('user', 'device-category', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_device_category_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_category': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'desc': 'test_value_4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_category.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'desc': 'test_value_4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('user', 'device-category', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_device_group.py b/test/units/modules/network/fortios/test_fortios_user_device_group.py
deleted file mode 100644
index c5f79f6c4c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_device_group.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_device_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_device_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_device_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_group.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('user', 'device-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_device_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_group.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('user', 'device-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_device_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_device_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_group.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'device-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_device_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_device_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_group.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'device-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_device_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_group.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('user', 'device-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_device_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_device_group': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_device_group.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('user', 'device-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_domain_controller.py b/test/units/modules/network/fortios/test_fortios_user_domain_controller.py
deleted file mode 100644
index 920da8a04a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_domain_controller.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_domain_controller
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_domain_controller.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_domain_controller_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_domain_controller': {
- 'domain_name': 'test_value_3',
- 'ip_address': 'test_value_4',
- 'ldap_server': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_domain_controller.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'domain-name': 'test_value_3',
- 'ip-address': 'test_value_4',
- 'ldap-server': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7'
- }
-
- set_method_mock.assert_called_with('user', 'domain-controller', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_domain_controller_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_domain_controller': {
- 'domain_name': 'test_value_3',
- 'ip_address': 'test_value_4',
- 'ldap_server': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_domain_controller.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'domain-name': 'test_value_3',
- 'ip-address': 'test_value_4',
- 'ldap-server': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7'
- }
-
- set_method_mock.assert_called_with('user', 'domain-controller', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_domain_controller_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_domain_controller': {
- 'domain_name': 'test_value_3',
- 'ip_address': 'test_value_4',
- 'ldap_server': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_domain_controller.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'domain-controller', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_domain_controller_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_domain_controller': {
- 'domain_name': 'test_value_3',
- 'ip_address': 'test_value_4',
- 'ldap_server': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_domain_controller.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'domain-controller', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_domain_controller_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_domain_controller': {
- 'domain_name': 'test_value_3',
- 'ip_address': 'test_value_4',
- 'ldap_server': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_domain_controller.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'domain-name': 'test_value_3',
- 'ip-address': 'test_value_4',
- 'ldap-server': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7'
- }
-
- set_method_mock.assert_called_with('user', 'domain-controller', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_domain_controller_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_domain_controller': {
- 'random_attribute_not_valid': 'tag',
- 'domain_name': 'test_value_3',
- 'ip_address': 'test_value_4',
- 'ldap_server': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_domain_controller.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'domain-name': 'test_value_3',
- 'ip-address': 'test_value_4',
- 'ldap-server': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7'
- }
-
- set_method_mock.assert_called_with('user', 'domain-controller', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_fortitoken.py b/test/units/modules/network/fortios/test_fortios_user_fortitoken.py
deleted file mode 100644
index 265f82624e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_fortitoken.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_fortitoken
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_fortitoken.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_fortitoken_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fortitoken': {
- 'activation_code': 'test_value_3',
- 'activation_expire': '4',
- 'comments': 'test_value_5',
- 'license': 'test_value_6',
- 'os_ver': 'test_value_7',
- 'reg_id': 'test_value_8',
- 'seed': 'test_value_9',
- 'serial_number': 'test_value_10',
- 'status': 'active'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fortitoken.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'activation-code': 'test_value_3',
- 'activation-expire': '4',
- 'comments': 'test_value_5',
- 'license': 'test_value_6',
- 'os-ver': 'test_value_7',
- 'reg-id': 'test_value_8',
- 'seed': 'test_value_9',
- 'serial-number': 'test_value_10',
- 'status': 'active'
- }
-
- set_method_mock.assert_called_with('user', 'fortitoken', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_fortitoken_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fortitoken': {
- 'activation_code': 'test_value_3',
- 'activation_expire': '4',
- 'comments': 'test_value_5',
- 'license': 'test_value_6',
- 'os_ver': 'test_value_7',
- 'reg_id': 'test_value_8',
- 'seed': 'test_value_9',
- 'serial_number': 'test_value_10',
- 'status': 'active'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fortitoken.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'activation-code': 'test_value_3',
- 'activation-expire': '4',
- 'comments': 'test_value_5',
- 'license': 'test_value_6',
- 'os-ver': 'test_value_7',
- 'reg-id': 'test_value_8',
- 'seed': 'test_value_9',
- 'serial-number': 'test_value_10',
- 'status': 'active'
- }
-
- set_method_mock.assert_called_with('user', 'fortitoken', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_fortitoken_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_fortitoken': {
- 'activation_code': 'test_value_3',
- 'activation_expire': '4',
- 'comments': 'test_value_5',
- 'license': 'test_value_6',
- 'os_ver': 'test_value_7',
- 'reg_id': 'test_value_8',
- 'seed': 'test_value_9',
- 'serial_number': 'test_value_10',
- 'status': 'active'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fortitoken.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'fortitoken', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_fortitoken_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_fortitoken': {
- 'activation_code': 'test_value_3',
- 'activation_expire': '4',
- 'comments': 'test_value_5',
- 'license': 'test_value_6',
- 'os_ver': 'test_value_7',
- 'reg_id': 'test_value_8',
- 'seed': 'test_value_9',
- 'serial_number': 'test_value_10',
- 'status': 'active'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fortitoken.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'fortitoken', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_fortitoken_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fortitoken': {
- 'activation_code': 'test_value_3',
- 'activation_expire': '4',
- 'comments': 'test_value_5',
- 'license': 'test_value_6',
- 'os_ver': 'test_value_7',
- 'reg_id': 'test_value_8',
- 'seed': 'test_value_9',
- 'serial_number': 'test_value_10',
- 'status': 'active'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fortitoken.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'activation-code': 'test_value_3',
- 'activation-expire': '4',
- 'comments': 'test_value_5',
- 'license': 'test_value_6',
- 'os-ver': 'test_value_7',
- 'reg-id': 'test_value_8',
- 'seed': 'test_value_9',
- 'serial-number': 'test_value_10',
- 'status': 'active'
- }
-
- set_method_mock.assert_called_with('user', 'fortitoken', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_fortitoken_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fortitoken': {
- 'random_attribute_not_valid': 'tag',
- 'activation_code': 'test_value_3',
- 'activation_expire': '4',
- 'comments': 'test_value_5',
- 'license': 'test_value_6',
- 'os_ver': 'test_value_7',
- 'reg_id': 'test_value_8',
- 'seed': 'test_value_9',
- 'serial_number': 'test_value_10',
- 'status': 'active'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fortitoken.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'activation-code': 'test_value_3',
- 'activation-expire': '4',
- 'comments': 'test_value_5',
- 'license': 'test_value_6',
- 'os-ver': 'test_value_7',
- 'reg-id': 'test_value_8',
- 'seed': 'test_value_9',
- 'serial-number': 'test_value_10',
- 'status': 'active'
- }
-
- set_method_mock.assert_called_with('user', 'fortitoken', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_fsso.py b/test/units/modules/network/fortios/test_fortios_user_fsso.py
deleted file mode 100644
index ac2f6be41e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_fsso.py
+++ /dev/null
@@ -1,379 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_fsso
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_fsso.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_fsso_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fsso': {
- 'ldap_server': 'test_value_3',
- 'name': 'default_name_4',
- 'password': 'test_value_5',
- 'password2': 'test_value_6',
- 'password3': 'test_value_7',
- 'password4': 'test_value_8',
- 'password5': 'test_value_9',
- 'port': '10',
- 'port2': '11',
- 'port3': '12',
- 'port4': '13',
- 'port5': '14',
- 'server': '192.168.100.15',
- 'server2': 'test_value_16',
- 'server3': 'test_value_17',
- 'server4': 'test_value_18',
- 'server5': 'test_value_19',
- 'source_ip': '84.230.14.20',
- 'source_ip6': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'ldap-server': 'test_value_3',
- 'name': 'default_name_4',
- 'password': 'test_value_5',
- 'password2': 'test_value_6',
- 'password3': 'test_value_7',
- 'password4': 'test_value_8',
- 'password5': 'test_value_9',
- 'port': '10',
- 'port2': '11',
- 'port3': '12',
- 'port4': '13',
- 'port5': '14',
- 'server': '192.168.100.15',
- 'server2': 'test_value_16',
- 'server3': 'test_value_17',
- 'server4': 'test_value_18',
- 'server5': 'test_value_19',
- 'source-ip': '84.230.14.20',
- 'source-ip6': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('user', 'fsso', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_fsso_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fsso': {
- 'ldap_server': 'test_value_3',
- 'name': 'default_name_4',
- 'password': 'test_value_5',
- 'password2': 'test_value_6',
- 'password3': 'test_value_7',
- 'password4': 'test_value_8',
- 'password5': 'test_value_9',
- 'port': '10',
- 'port2': '11',
- 'port3': '12',
- 'port4': '13',
- 'port5': '14',
- 'server': '192.168.100.15',
- 'server2': 'test_value_16',
- 'server3': 'test_value_17',
- 'server4': 'test_value_18',
- 'server5': 'test_value_19',
- 'source_ip': '84.230.14.20',
- 'source_ip6': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'ldap-server': 'test_value_3',
- 'name': 'default_name_4',
- 'password': 'test_value_5',
- 'password2': 'test_value_6',
- 'password3': 'test_value_7',
- 'password4': 'test_value_8',
- 'password5': 'test_value_9',
- 'port': '10',
- 'port2': '11',
- 'port3': '12',
- 'port4': '13',
- 'port5': '14',
- 'server': '192.168.100.15',
- 'server2': 'test_value_16',
- 'server3': 'test_value_17',
- 'server4': 'test_value_18',
- 'server5': 'test_value_19',
- 'source-ip': '84.230.14.20',
- 'source-ip6': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('user', 'fsso', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_fsso_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_fsso': {
- 'ldap_server': 'test_value_3',
- 'name': 'default_name_4',
- 'password': 'test_value_5',
- 'password2': 'test_value_6',
- 'password3': 'test_value_7',
- 'password4': 'test_value_8',
- 'password5': 'test_value_9',
- 'port': '10',
- 'port2': '11',
- 'port3': '12',
- 'port4': '13',
- 'port5': '14',
- 'server': '192.168.100.15',
- 'server2': 'test_value_16',
- 'server3': 'test_value_17',
- 'server4': 'test_value_18',
- 'server5': 'test_value_19',
- 'source_ip': '84.230.14.20',
- 'source_ip6': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'fsso', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_fsso_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_fsso': {
- 'ldap_server': 'test_value_3',
- 'name': 'default_name_4',
- 'password': 'test_value_5',
- 'password2': 'test_value_6',
- 'password3': 'test_value_7',
- 'password4': 'test_value_8',
- 'password5': 'test_value_9',
- 'port': '10',
- 'port2': '11',
- 'port3': '12',
- 'port4': '13',
- 'port5': '14',
- 'server': '192.168.100.15',
- 'server2': 'test_value_16',
- 'server3': 'test_value_17',
- 'server4': 'test_value_18',
- 'server5': 'test_value_19',
- 'source_ip': '84.230.14.20',
- 'source_ip6': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'fsso', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_fsso_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fsso': {
- 'ldap_server': 'test_value_3',
- 'name': 'default_name_4',
- 'password': 'test_value_5',
- 'password2': 'test_value_6',
- 'password3': 'test_value_7',
- 'password4': 'test_value_8',
- 'password5': 'test_value_9',
- 'port': '10',
- 'port2': '11',
- 'port3': '12',
- 'port4': '13',
- 'port5': '14',
- 'server': '192.168.100.15',
- 'server2': 'test_value_16',
- 'server3': 'test_value_17',
- 'server4': 'test_value_18',
- 'server5': 'test_value_19',
- 'source_ip': '84.230.14.20',
- 'source_ip6': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'ldap-server': 'test_value_3',
- 'name': 'default_name_4',
- 'password': 'test_value_5',
- 'password2': 'test_value_6',
- 'password3': 'test_value_7',
- 'password4': 'test_value_8',
- 'password5': 'test_value_9',
- 'port': '10',
- 'port2': '11',
- 'port3': '12',
- 'port4': '13',
- 'port5': '14',
- 'server': '192.168.100.15',
- 'server2': 'test_value_16',
- 'server3': 'test_value_17',
- 'server4': 'test_value_18',
- 'server5': 'test_value_19',
- 'source-ip': '84.230.14.20',
- 'source-ip6': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('user', 'fsso', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_fsso_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fsso': {
- 'random_attribute_not_valid': 'tag',
- 'ldap_server': 'test_value_3',
- 'name': 'default_name_4',
- 'password': 'test_value_5',
- 'password2': 'test_value_6',
- 'password3': 'test_value_7',
- 'password4': 'test_value_8',
- 'password5': 'test_value_9',
- 'port': '10',
- 'port2': '11',
- 'port3': '12',
- 'port4': '13',
- 'port5': '14',
- 'server': '192.168.100.15',
- 'server2': 'test_value_16',
- 'server3': 'test_value_17',
- 'server4': 'test_value_18',
- 'server5': 'test_value_19',
- 'source_ip': '84.230.14.20',
- 'source_ip6': 'test_value_21'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'ldap-server': 'test_value_3',
- 'name': 'default_name_4',
- 'password': 'test_value_5',
- 'password2': 'test_value_6',
- 'password3': 'test_value_7',
- 'password4': 'test_value_8',
- 'password5': 'test_value_9',
- 'port': '10',
- 'port2': '11',
- 'port3': '12',
- 'port4': '13',
- 'port5': '14',
- 'server': '192.168.100.15',
- 'server2': 'test_value_16',
- 'server3': 'test_value_17',
- 'server4': 'test_value_18',
- 'server5': 'test_value_19',
- 'source-ip': '84.230.14.20',
- 'source-ip6': 'test_value_21'
- }
-
- set_method_mock.assert_called_with('user', 'fsso', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_fsso_polling.py b/test/units/modules/network/fortios/test_fortios_user_fsso_polling.py
deleted file mode 100644
index 6d495aff4d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_fsso_polling.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_fsso_polling
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_fsso_polling.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_fsso_polling_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fsso_polling': {'default_domain': 'test_value_3',
- 'id': '4',
- 'ldap_server': 'test_value_5',
- 'logon_history': '6',
- 'password': 'test_value_7',
- 'polling_frequency': '8',
- 'port': '9',
- 'server': '192.168.100.10',
- 'status': 'enable',
- 'user': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso_polling.fortios_user(input_data, fos_instance)
-
- expected_data = {'default-domain': 'test_value_3',
- 'id': '4',
- 'ldap-server': 'test_value_5',
- 'logon-history': '6',
- 'password': 'test_value_7',
- 'polling-frequency': '8',
- 'port': '9',
- 'server': '192.168.100.10',
- 'status': 'enable',
- 'user': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('user', 'fsso-polling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_fsso_polling_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fsso_polling': {'default_domain': 'test_value_3',
- 'id': '4',
- 'ldap_server': 'test_value_5',
- 'logon_history': '6',
- 'password': 'test_value_7',
- 'polling_frequency': '8',
- 'port': '9',
- 'server': '192.168.100.10',
- 'status': 'enable',
- 'user': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso_polling.fortios_user(input_data, fos_instance)
-
- expected_data = {'default-domain': 'test_value_3',
- 'id': '4',
- 'ldap-server': 'test_value_5',
- 'logon-history': '6',
- 'password': 'test_value_7',
- 'polling-frequency': '8',
- 'port': '9',
- 'server': '192.168.100.10',
- 'status': 'enable',
- 'user': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('user', 'fsso-polling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_fsso_polling_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_fsso_polling': {'default_domain': 'test_value_3',
- 'id': '4',
- 'ldap_server': 'test_value_5',
- 'logon_history': '6',
- 'password': 'test_value_7',
- 'polling_frequency': '8',
- 'port': '9',
- 'server': '192.168.100.10',
- 'status': 'enable',
- 'user': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso_polling.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'fsso-polling', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_fsso_polling_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_fsso_polling': {'default_domain': 'test_value_3',
- 'id': '4',
- 'ldap_server': 'test_value_5',
- 'logon_history': '6',
- 'password': 'test_value_7',
- 'polling_frequency': '8',
- 'port': '9',
- 'server': '192.168.100.10',
- 'status': 'enable',
- 'user': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso_polling.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'fsso-polling', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_fsso_polling_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fsso_polling': {'default_domain': 'test_value_3',
- 'id': '4',
- 'ldap_server': 'test_value_5',
- 'logon_history': '6',
- 'password': 'test_value_7',
- 'polling_frequency': '8',
- 'port': '9',
- 'server': '192.168.100.10',
- 'status': 'enable',
- 'user': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso_polling.fortios_user(input_data, fos_instance)
-
- expected_data = {'default-domain': 'test_value_3',
- 'id': '4',
- 'ldap-server': 'test_value_5',
- 'logon-history': '6',
- 'password': 'test_value_7',
- 'polling-frequency': '8',
- 'port': '9',
- 'server': '192.168.100.10',
- 'status': 'enable',
- 'user': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('user', 'fsso-polling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_fsso_polling_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_fsso_polling': {
- 'random_attribute_not_valid': 'tag', 'default_domain': 'test_value_3',
- 'id': '4',
- 'ldap_server': 'test_value_5',
- 'logon_history': '6',
- 'password': 'test_value_7',
- 'polling_frequency': '8',
- 'port': '9',
- 'server': '192.168.100.10',
- 'status': 'enable',
- 'user': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_fsso_polling.fortios_user(input_data, fos_instance)
-
- expected_data = {'default-domain': 'test_value_3',
- 'id': '4',
- 'ldap-server': 'test_value_5',
- 'logon-history': '6',
- 'password': 'test_value_7',
- 'polling-frequency': '8',
- 'port': '9',
- 'server': '192.168.100.10',
- 'status': 'enable',
- 'user': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('user', 'fsso-polling', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_group.py b/test/units/modules/network/fortios/test_fortios_user_group.py
deleted file mode 100644
index b7aa50bdb0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_group.py
+++ /dev/null
@@ -1,399 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_group': {
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'company': 'optional',
- 'email': 'disable',
- 'expire': '8',
- 'expire_type': 'immediately',
- 'group_type': 'firewall',
- 'http_digest_realm': 'test_value_11',
- 'id': '12',
- 'max_accounts': '13',
- 'mobile_phone': 'disable',
- 'multiple_guest_add': 'disable',
- 'name': 'default_name_16',
- 'password': 'auto-generate',
- 'sms_custom_server': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'sponsor': 'optional',
- 'sso_attribute_value': 'test_value_21',
- 'user_id': 'email',
- 'user_name': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_group.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-concurrent-override': 'enable',
- 'auth-concurrent-value': '4',
- 'authtimeout': '5',
- 'company': 'optional',
- 'email': 'disable',
- 'expire': '8',
- 'expire-type': 'immediately',
- 'group-type': 'firewall',
- 'http-digest-realm': 'test_value_11',
- 'id': '12',
- 'max-accounts': '13',
- 'mobile-phone': 'disable',
- 'multiple-guest-add': 'disable',
- 'name': 'default_name_16',
- 'password': 'auto-generate',
- 'sms-custom-server': 'test_value_18',
- 'sms-server': 'fortiguard',
- 'sponsor': 'optional',
- 'sso-attribute-value': 'test_value_21',
- 'user-id': 'email',
- 'user-name': 'disable'
- }
-
- set_method_mock.assert_called_with('user', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_group': {
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'company': 'optional',
- 'email': 'disable',
- 'expire': '8',
- 'expire_type': 'immediately',
- 'group_type': 'firewall',
- 'http_digest_realm': 'test_value_11',
- 'id': '12',
- 'max_accounts': '13',
- 'mobile_phone': 'disable',
- 'multiple_guest_add': 'disable',
- 'name': 'default_name_16',
- 'password': 'auto-generate',
- 'sms_custom_server': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'sponsor': 'optional',
- 'sso_attribute_value': 'test_value_21',
- 'user_id': 'email',
- 'user_name': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_group.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-concurrent-override': 'enable',
- 'auth-concurrent-value': '4',
- 'authtimeout': '5',
- 'company': 'optional',
- 'email': 'disable',
- 'expire': '8',
- 'expire-type': 'immediately',
- 'group-type': 'firewall',
- 'http-digest-realm': 'test_value_11',
- 'id': '12',
- 'max-accounts': '13',
- 'mobile-phone': 'disable',
- 'multiple-guest-add': 'disable',
- 'name': 'default_name_16',
- 'password': 'auto-generate',
- 'sms-custom-server': 'test_value_18',
- 'sms-server': 'fortiguard',
- 'sponsor': 'optional',
- 'sso-attribute-value': 'test_value_21',
- 'user-id': 'email',
- 'user-name': 'disable'
- }
-
- set_method_mock.assert_called_with('user', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_group': {
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'company': 'optional',
- 'email': 'disable',
- 'expire': '8',
- 'expire_type': 'immediately',
- 'group_type': 'firewall',
- 'http_digest_realm': 'test_value_11',
- 'id': '12',
- 'max_accounts': '13',
- 'mobile_phone': 'disable',
- 'multiple_guest_add': 'disable',
- 'name': 'default_name_16',
- 'password': 'auto-generate',
- 'sms_custom_server': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'sponsor': 'optional',
- 'sso_attribute_value': 'test_value_21',
- 'user_id': 'email',
- 'user_name': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_group.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_group': {
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'company': 'optional',
- 'email': 'disable',
- 'expire': '8',
- 'expire_type': 'immediately',
- 'group_type': 'firewall',
- 'http_digest_realm': 'test_value_11',
- 'id': '12',
- 'max_accounts': '13',
- 'mobile_phone': 'disable',
- 'multiple_guest_add': 'disable',
- 'name': 'default_name_16',
- 'password': 'auto-generate',
- 'sms_custom_server': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'sponsor': 'optional',
- 'sso_attribute_value': 'test_value_21',
- 'user_id': 'email',
- 'user_name': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_group.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_group': {
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'company': 'optional',
- 'email': 'disable',
- 'expire': '8',
- 'expire_type': 'immediately',
- 'group_type': 'firewall',
- 'http_digest_realm': 'test_value_11',
- 'id': '12',
- 'max_accounts': '13',
- 'mobile_phone': 'disable',
- 'multiple_guest_add': 'disable',
- 'name': 'default_name_16',
- 'password': 'auto-generate',
- 'sms_custom_server': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'sponsor': 'optional',
- 'sso_attribute_value': 'test_value_21',
- 'user_id': 'email',
- 'user_name': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_group.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-concurrent-override': 'enable',
- 'auth-concurrent-value': '4',
- 'authtimeout': '5',
- 'company': 'optional',
- 'email': 'disable',
- 'expire': '8',
- 'expire-type': 'immediately',
- 'group-type': 'firewall',
- 'http-digest-realm': 'test_value_11',
- 'id': '12',
- 'max-accounts': '13',
- 'mobile-phone': 'disable',
- 'multiple-guest-add': 'disable',
- 'name': 'default_name_16',
- 'password': 'auto-generate',
- 'sms-custom-server': 'test_value_18',
- 'sms-server': 'fortiguard',
- 'sponsor': 'optional',
- 'sso-attribute-value': 'test_value_21',
- 'user-id': 'email',
- 'user-name': 'disable'
- }
-
- set_method_mock.assert_called_with('user', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_group': {
- 'random_attribute_not_valid': 'tag',
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'company': 'optional',
- 'email': 'disable',
- 'expire': '8',
- 'expire_type': 'immediately',
- 'group_type': 'firewall',
- 'http_digest_realm': 'test_value_11',
- 'id': '12',
- 'max_accounts': '13',
- 'mobile_phone': 'disable',
- 'multiple_guest_add': 'disable',
- 'name': 'default_name_16',
- 'password': 'auto-generate',
- 'sms_custom_server': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'sponsor': 'optional',
- 'sso_attribute_value': 'test_value_21',
- 'user_id': 'email',
- 'user_name': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_group.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-concurrent-override': 'enable',
- 'auth-concurrent-value': '4',
- 'authtimeout': '5',
- 'company': 'optional',
- 'email': 'disable',
- 'expire': '8',
- 'expire-type': 'immediately',
- 'group-type': 'firewall',
- 'http-digest-realm': 'test_value_11',
- 'id': '12',
- 'max-accounts': '13',
- 'mobile-phone': 'disable',
- 'multiple-guest-add': 'disable',
- 'name': 'default_name_16',
- 'password': 'auto-generate',
- 'sms-custom-server': 'test_value_18',
- 'sms-server': 'fortiguard',
- 'sponsor': 'optional',
- 'sso-attribute-value': 'test_value_21',
- 'user-id': 'email',
- 'user-name': 'disable'
- }
-
- set_method_mock.assert_called_with('user', 'group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_krb_keytab.py b/test/units/modules/network/fortios/test_fortios_user_krb_keytab.py
deleted file mode 100644
index a30af02563..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_krb_keytab.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_krb_keytab
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_krb_keytab.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_krb_keytab_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_krb_keytab': {
- 'keytab': 'test_value_3',
- 'ldap_server': 'test_value_4',
- 'name': 'default_name_5',
- 'principal': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_krb_keytab.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'keytab': 'test_value_3',
- 'ldap-server': 'test_value_4',
- 'name': 'default_name_5',
- 'principal': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('user', 'krb-keytab', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_krb_keytab_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_krb_keytab': {
- 'keytab': 'test_value_3',
- 'ldap_server': 'test_value_4',
- 'name': 'default_name_5',
- 'principal': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_krb_keytab.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'keytab': 'test_value_3',
- 'ldap-server': 'test_value_4',
- 'name': 'default_name_5',
- 'principal': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('user', 'krb-keytab', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_krb_keytab_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_krb_keytab': {
- 'keytab': 'test_value_3',
- 'ldap_server': 'test_value_4',
- 'name': 'default_name_5',
- 'principal': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_krb_keytab.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'krb-keytab', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_krb_keytab_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_krb_keytab': {
- 'keytab': 'test_value_3',
- 'ldap_server': 'test_value_4',
- 'name': 'default_name_5',
- 'principal': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_krb_keytab.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'krb-keytab', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_krb_keytab_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_krb_keytab': {
- 'keytab': 'test_value_3',
- 'ldap_server': 'test_value_4',
- 'name': 'default_name_5',
- 'principal': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_krb_keytab.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'keytab': 'test_value_3',
- 'ldap-server': 'test_value_4',
- 'name': 'default_name_5',
- 'principal': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('user', 'krb-keytab', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_krb_keytab_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_krb_keytab': {
- 'random_attribute_not_valid': 'tag',
- 'keytab': 'test_value_3',
- 'ldap_server': 'test_value_4',
- 'name': 'default_name_5',
- 'principal': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_krb_keytab.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'keytab': 'test_value_3',
- 'ldap-server': 'test_value_4',
- 'name': 'default_name_5',
- 'principal': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('user', 'krb-keytab', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_ldap.py b/test/units/modules/network/fortios/test_fortios_user_ldap.py
deleted file mode 100644
index 47b06f8622..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_ldap.py
+++ /dev/null
@@ -1,429 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_ldap
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_ldap.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_ldap_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_ldap': {
- 'account_key_filter': 'test_value_3',
- 'account_key_processing': 'same',
- 'ca_cert': 'test_value_5',
- 'cnid': 'test_value_6',
- 'dn': 'test_value_7',
- 'group_filter': 'test_value_8',
- 'group_member_check': 'user-attr',
- 'group_object_filter': 'test_value_10',
- 'group_search_base': 'test_value_11',
- 'member_attr': 'test_value_12',
- 'name': 'default_name_13',
- 'password': 'test_value_14',
- 'password_expiry_warning': 'enable',
- 'password_renewal': 'enable',
- 'port': '17',
- 'secondary_server': 'test_value_18',
- 'secure': 'disable',
- 'server': '192.168.100.20',
- 'server_identity_check': 'enable',
- 'source_ip': '84.230.14.22',
- 'ssl_min_proto_version': 'default',
- 'tertiary_server': 'test_value_24',
- 'type': 'simple',
- 'username': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_ldap.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'account-key-filter': 'test_value_3',
- 'account-key-processing': 'same',
- 'ca-cert': 'test_value_5',
- 'cnid': 'test_value_6',
- 'dn': 'test_value_7',
- 'group-filter': 'test_value_8',
- 'group-member-check': 'user-attr',
- 'group-object-filter': 'test_value_10',
- 'group-search-base': 'test_value_11',
- 'member-attr': 'test_value_12',
- 'name': 'default_name_13',
- 'password': 'test_value_14',
- 'password-expiry-warning': 'enable',
- 'password-renewal': 'enable',
- 'port': '17',
- 'secondary-server': 'test_value_18',
- 'secure': 'disable',
- 'server': '192.168.100.20',
- 'server-identity-check': 'enable',
- 'source-ip': '84.230.14.22',
- 'ssl-min-proto-version': 'default',
- 'tertiary-server': 'test_value_24',
- 'type': 'simple',
- 'username': 'test_value_26'
- }
-
- set_method_mock.assert_called_with('user', 'ldap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_ldap_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_ldap': {
- 'account_key_filter': 'test_value_3',
- 'account_key_processing': 'same',
- 'ca_cert': 'test_value_5',
- 'cnid': 'test_value_6',
- 'dn': 'test_value_7',
- 'group_filter': 'test_value_8',
- 'group_member_check': 'user-attr',
- 'group_object_filter': 'test_value_10',
- 'group_search_base': 'test_value_11',
- 'member_attr': 'test_value_12',
- 'name': 'default_name_13',
- 'password': 'test_value_14',
- 'password_expiry_warning': 'enable',
- 'password_renewal': 'enable',
- 'port': '17',
- 'secondary_server': 'test_value_18',
- 'secure': 'disable',
- 'server': '192.168.100.20',
- 'server_identity_check': 'enable',
- 'source_ip': '84.230.14.22',
- 'ssl_min_proto_version': 'default',
- 'tertiary_server': 'test_value_24',
- 'type': 'simple',
- 'username': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_ldap.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'account-key-filter': 'test_value_3',
- 'account-key-processing': 'same',
- 'ca-cert': 'test_value_5',
- 'cnid': 'test_value_6',
- 'dn': 'test_value_7',
- 'group-filter': 'test_value_8',
- 'group-member-check': 'user-attr',
- 'group-object-filter': 'test_value_10',
- 'group-search-base': 'test_value_11',
- 'member-attr': 'test_value_12',
- 'name': 'default_name_13',
- 'password': 'test_value_14',
- 'password-expiry-warning': 'enable',
- 'password-renewal': 'enable',
- 'port': '17',
- 'secondary-server': 'test_value_18',
- 'secure': 'disable',
- 'server': '192.168.100.20',
- 'server-identity-check': 'enable',
- 'source-ip': '84.230.14.22',
- 'ssl-min-proto-version': 'default',
- 'tertiary-server': 'test_value_24',
- 'type': 'simple',
- 'username': 'test_value_26'
- }
-
- set_method_mock.assert_called_with('user', 'ldap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_ldap_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_ldap': {
- 'account_key_filter': 'test_value_3',
- 'account_key_processing': 'same',
- 'ca_cert': 'test_value_5',
- 'cnid': 'test_value_6',
- 'dn': 'test_value_7',
- 'group_filter': 'test_value_8',
- 'group_member_check': 'user-attr',
- 'group_object_filter': 'test_value_10',
- 'group_search_base': 'test_value_11',
- 'member_attr': 'test_value_12',
- 'name': 'default_name_13',
- 'password': 'test_value_14',
- 'password_expiry_warning': 'enable',
- 'password_renewal': 'enable',
- 'port': '17',
- 'secondary_server': 'test_value_18',
- 'secure': 'disable',
- 'server': '192.168.100.20',
- 'server_identity_check': 'enable',
- 'source_ip': '84.230.14.22',
- 'ssl_min_proto_version': 'default',
- 'tertiary_server': 'test_value_24',
- 'type': 'simple',
- 'username': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_ldap.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'ldap', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_ldap_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_ldap': {
- 'account_key_filter': 'test_value_3',
- 'account_key_processing': 'same',
- 'ca_cert': 'test_value_5',
- 'cnid': 'test_value_6',
- 'dn': 'test_value_7',
- 'group_filter': 'test_value_8',
- 'group_member_check': 'user-attr',
- 'group_object_filter': 'test_value_10',
- 'group_search_base': 'test_value_11',
- 'member_attr': 'test_value_12',
- 'name': 'default_name_13',
- 'password': 'test_value_14',
- 'password_expiry_warning': 'enable',
- 'password_renewal': 'enable',
- 'port': '17',
- 'secondary_server': 'test_value_18',
- 'secure': 'disable',
- 'server': '192.168.100.20',
- 'server_identity_check': 'enable',
- 'source_ip': '84.230.14.22',
- 'ssl_min_proto_version': 'default',
- 'tertiary_server': 'test_value_24',
- 'type': 'simple',
- 'username': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_ldap.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'ldap', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_ldap_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_ldap': {
- 'account_key_filter': 'test_value_3',
- 'account_key_processing': 'same',
- 'ca_cert': 'test_value_5',
- 'cnid': 'test_value_6',
- 'dn': 'test_value_7',
- 'group_filter': 'test_value_8',
- 'group_member_check': 'user-attr',
- 'group_object_filter': 'test_value_10',
- 'group_search_base': 'test_value_11',
- 'member_attr': 'test_value_12',
- 'name': 'default_name_13',
- 'password': 'test_value_14',
- 'password_expiry_warning': 'enable',
- 'password_renewal': 'enable',
- 'port': '17',
- 'secondary_server': 'test_value_18',
- 'secure': 'disable',
- 'server': '192.168.100.20',
- 'server_identity_check': 'enable',
- 'source_ip': '84.230.14.22',
- 'ssl_min_proto_version': 'default',
- 'tertiary_server': 'test_value_24',
- 'type': 'simple',
- 'username': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_ldap.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'account-key-filter': 'test_value_3',
- 'account-key-processing': 'same',
- 'ca-cert': 'test_value_5',
- 'cnid': 'test_value_6',
- 'dn': 'test_value_7',
- 'group-filter': 'test_value_8',
- 'group-member-check': 'user-attr',
- 'group-object-filter': 'test_value_10',
- 'group-search-base': 'test_value_11',
- 'member-attr': 'test_value_12',
- 'name': 'default_name_13',
- 'password': 'test_value_14',
- 'password-expiry-warning': 'enable',
- 'password-renewal': 'enable',
- 'port': '17',
- 'secondary-server': 'test_value_18',
- 'secure': 'disable',
- 'server': '192.168.100.20',
- 'server-identity-check': 'enable',
- 'source-ip': '84.230.14.22',
- 'ssl-min-proto-version': 'default',
- 'tertiary-server': 'test_value_24',
- 'type': 'simple',
- 'username': 'test_value_26'
- }
-
- set_method_mock.assert_called_with('user', 'ldap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_ldap_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_ldap': {
- 'random_attribute_not_valid': 'tag',
- 'account_key_filter': 'test_value_3',
- 'account_key_processing': 'same',
- 'ca_cert': 'test_value_5',
- 'cnid': 'test_value_6',
- 'dn': 'test_value_7',
- 'group_filter': 'test_value_8',
- 'group_member_check': 'user-attr',
- 'group_object_filter': 'test_value_10',
- 'group_search_base': 'test_value_11',
- 'member_attr': 'test_value_12',
- 'name': 'default_name_13',
- 'password': 'test_value_14',
- 'password_expiry_warning': 'enable',
- 'password_renewal': 'enable',
- 'port': '17',
- 'secondary_server': 'test_value_18',
- 'secure': 'disable',
- 'server': '192.168.100.20',
- 'server_identity_check': 'enable',
- 'source_ip': '84.230.14.22',
- 'ssl_min_proto_version': 'default',
- 'tertiary_server': 'test_value_24',
- 'type': 'simple',
- 'username': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_ldap.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'account-key-filter': 'test_value_3',
- 'account-key-processing': 'same',
- 'ca-cert': 'test_value_5',
- 'cnid': 'test_value_6',
- 'dn': 'test_value_7',
- 'group-filter': 'test_value_8',
- 'group-member-check': 'user-attr',
- 'group-object-filter': 'test_value_10',
- 'group-search-base': 'test_value_11',
- 'member-attr': 'test_value_12',
- 'name': 'default_name_13',
- 'password': 'test_value_14',
- 'password-expiry-warning': 'enable',
- 'password-renewal': 'enable',
- 'port': '17',
- 'secondary-server': 'test_value_18',
- 'secure': 'disable',
- 'server': '192.168.100.20',
- 'server-identity-check': 'enable',
- 'source-ip': '84.230.14.22',
- 'ssl-min-proto-version': 'default',
- 'tertiary-server': 'test_value_24',
- 'type': 'simple',
- 'username': 'test_value_26'
- }
-
- set_method_mock.assert_called_with('user', 'ldap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_local.py b/test/units/modules/network/fortios/test_fortios_user_local.py
deleted file mode 100644
index 27ab005a2d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_local.py
+++ /dev/null
@@ -1,399 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_local
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_local.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_local_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_local': {
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'email_to': 'test_value_6',
- 'fortitoken': 'test_value_7',
- 'id': '8',
- 'ldap_server': 'test_value_9',
- 'name': 'default_name_10',
- 'passwd': 'test_value_11',
- 'passwd_policy': 'test_value_12',
- 'passwd_time': 'test_value_13',
- 'ppk_identity': 'test_value_14',
- 'ppk_secret': 'test_value_15',
- 'radius_server': 'test_value_16',
- 'sms_custom_server': 'test_value_17',
- 'sms_phone': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'status': 'enable',
- 'two_factor': 'disable',
- 'type': 'password',
- 'workstation': 'test_value_24'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_local.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-concurrent-override': 'enable',
- 'auth-concurrent-value': '4',
- 'authtimeout': '5',
- 'email-to': 'test_value_6',
- 'fortitoken': 'test_value_7',
- 'id': '8',
- 'ldap-server': 'test_value_9',
- 'name': 'default_name_10',
- 'passwd': 'test_value_11',
- 'passwd-policy': 'test_value_12',
- 'passwd-time': 'test_value_13',
- 'ppk-identity': 'test_value_14',
- 'ppk-secret': 'test_value_15',
- 'radius-server': 'test_value_16',
- 'sms-custom-server': 'test_value_17',
- 'sms-phone': 'test_value_18',
- 'sms-server': 'fortiguard',
- 'status': 'enable',
- 'two-factor': 'disable',
- 'type': 'password',
- 'workstation': 'test_value_24'
- }
-
- set_method_mock.assert_called_with('user', 'local', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_local_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_local': {
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'email_to': 'test_value_6',
- 'fortitoken': 'test_value_7',
- 'id': '8',
- 'ldap_server': 'test_value_9',
- 'name': 'default_name_10',
- 'passwd': 'test_value_11',
- 'passwd_policy': 'test_value_12',
- 'passwd_time': 'test_value_13',
- 'ppk_identity': 'test_value_14',
- 'ppk_secret': 'test_value_15',
- 'radius_server': 'test_value_16',
- 'sms_custom_server': 'test_value_17',
- 'sms_phone': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'status': 'enable',
- 'two_factor': 'disable',
- 'type': 'password',
- 'workstation': 'test_value_24'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_local.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-concurrent-override': 'enable',
- 'auth-concurrent-value': '4',
- 'authtimeout': '5',
- 'email-to': 'test_value_6',
- 'fortitoken': 'test_value_7',
- 'id': '8',
- 'ldap-server': 'test_value_9',
- 'name': 'default_name_10',
- 'passwd': 'test_value_11',
- 'passwd-policy': 'test_value_12',
- 'passwd-time': 'test_value_13',
- 'ppk-identity': 'test_value_14',
- 'ppk-secret': 'test_value_15',
- 'radius-server': 'test_value_16',
- 'sms-custom-server': 'test_value_17',
- 'sms-phone': 'test_value_18',
- 'sms-server': 'fortiguard',
- 'status': 'enable',
- 'two-factor': 'disable',
- 'type': 'password',
- 'workstation': 'test_value_24'
- }
-
- set_method_mock.assert_called_with('user', 'local', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_local_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_local': {
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'email_to': 'test_value_6',
- 'fortitoken': 'test_value_7',
- 'id': '8',
- 'ldap_server': 'test_value_9',
- 'name': 'default_name_10',
- 'passwd': 'test_value_11',
- 'passwd_policy': 'test_value_12',
- 'passwd_time': 'test_value_13',
- 'ppk_identity': 'test_value_14',
- 'ppk_secret': 'test_value_15',
- 'radius_server': 'test_value_16',
- 'sms_custom_server': 'test_value_17',
- 'sms_phone': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'status': 'enable',
- 'two_factor': 'disable',
- 'type': 'password',
- 'workstation': 'test_value_24'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_local.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'local', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_local_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_local': {
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'email_to': 'test_value_6',
- 'fortitoken': 'test_value_7',
- 'id': '8',
- 'ldap_server': 'test_value_9',
- 'name': 'default_name_10',
- 'passwd': 'test_value_11',
- 'passwd_policy': 'test_value_12',
- 'passwd_time': 'test_value_13',
- 'ppk_identity': 'test_value_14',
- 'ppk_secret': 'test_value_15',
- 'radius_server': 'test_value_16',
- 'sms_custom_server': 'test_value_17',
- 'sms_phone': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'status': 'enable',
- 'two_factor': 'disable',
- 'type': 'password',
- 'workstation': 'test_value_24'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_local.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'local', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_local_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_local': {
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'email_to': 'test_value_6',
- 'fortitoken': 'test_value_7',
- 'id': '8',
- 'ldap_server': 'test_value_9',
- 'name': 'default_name_10',
- 'passwd': 'test_value_11',
- 'passwd_policy': 'test_value_12',
- 'passwd_time': 'test_value_13',
- 'ppk_identity': 'test_value_14',
- 'ppk_secret': 'test_value_15',
- 'radius_server': 'test_value_16',
- 'sms_custom_server': 'test_value_17',
- 'sms_phone': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'status': 'enable',
- 'two_factor': 'disable',
- 'type': 'password',
- 'workstation': 'test_value_24'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_local.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-concurrent-override': 'enable',
- 'auth-concurrent-value': '4',
- 'authtimeout': '5',
- 'email-to': 'test_value_6',
- 'fortitoken': 'test_value_7',
- 'id': '8',
- 'ldap-server': 'test_value_9',
- 'name': 'default_name_10',
- 'passwd': 'test_value_11',
- 'passwd-policy': 'test_value_12',
- 'passwd-time': 'test_value_13',
- 'ppk-identity': 'test_value_14',
- 'ppk-secret': 'test_value_15',
- 'radius-server': 'test_value_16',
- 'sms-custom-server': 'test_value_17',
- 'sms-phone': 'test_value_18',
- 'sms-server': 'fortiguard',
- 'status': 'enable',
- 'two-factor': 'disable',
- 'type': 'password',
- 'workstation': 'test_value_24'
- }
-
- set_method_mock.assert_called_with('user', 'local', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_local_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_local': {
- 'random_attribute_not_valid': 'tag',
- 'auth_concurrent_override': 'enable',
- 'auth_concurrent_value': '4',
- 'authtimeout': '5',
- 'email_to': 'test_value_6',
- 'fortitoken': 'test_value_7',
- 'id': '8',
- 'ldap_server': 'test_value_9',
- 'name': 'default_name_10',
- 'passwd': 'test_value_11',
- 'passwd_policy': 'test_value_12',
- 'passwd_time': 'test_value_13',
- 'ppk_identity': 'test_value_14',
- 'ppk_secret': 'test_value_15',
- 'radius_server': 'test_value_16',
- 'sms_custom_server': 'test_value_17',
- 'sms_phone': 'test_value_18',
- 'sms_server': 'fortiguard',
- 'status': 'enable',
- 'two_factor': 'disable',
- 'type': 'password',
- 'workstation': 'test_value_24'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_local.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-concurrent-override': 'enable',
- 'auth-concurrent-value': '4',
- 'authtimeout': '5',
- 'email-to': 'test_value_6',
- 'fortitoken': 'test_value_7',
- 'id': '8',
- 'ldap-server': 'test_value_9',
- 'name': 'default_name_10',
- 'passwd': 'test_value_11',
- 'passwd-policy': 'test_value_12',
- 'passwd-time': 'test_value_13',
- 'ppk-identity': 'test_value_14',
- 'ppk-secret': 'test_value_15',
- 'radius-server': 'test_value_16',
- 'sms-custom-server': 'test_value_17',
- 'sms-phone': 'test_value_18',
- 'sms-server': 'fortiguard',
- 'status': 'enable',
- 'two-factor': 'disable',
- 'type': 'password',
- 'workstation': 'test_value_24'
- }
-
- set_method_mock.assert_called_with('user', 'local', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_password_policy.py b/test/units/modules/network/fortios/test_fortios_user_password_policy.py
deleted file mode 100644
index 0c939f4933..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_password_policy.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_password_policy
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_password_policy.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_password_policy_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_password_policy': {
- 'expire_days': '3',
- 'name': 'default_name_4',
- 'warn_days': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_password_policy.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'expire-days': '3',
- 'name': 'default_name_4',
- 'warn-days': '5'
- }
-
- set_method_mock.assert_called_with('user', 'password-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_password_policy_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_password_policy': {
- 'expire_days': '3',
- 'name': 'default_name_4',
- 'warn_days': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_password_policy.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'expire-days': '3',
- 'name': 'default_name_4',
- 'warn-days': '5'
- }
-
- set_method_mock.assert_called_with('user', 'password-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_password_policy_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_password_policy': {
- 'expire_days': '3',
- 'name': 'default_name_4',
- 'warn_days': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_password_policy.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'password-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_password_policy_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_password_policy': {
- 'expire_days': '3',
- 'name': 'default_name_4',
- 'warn_days': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_password_policy.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'password-policy', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_password_policy_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_password_policy': {
- 'expire_days': '3',
- 'name': 'default_name_4',
- 'warn_days': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_password_policy.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'expire-days': '3',
- 'name': 'default_name_4',
- 'warn-days': '5'
- }
-
- set_method_mock.assert_called_with('user', 'password-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_password_policy_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_password_policy': {
- 'random_attribute_not_valid': 'tag',
- 'expire_days': '3',
- 'name': 'default_name_4',
- 'warn_days': '5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_password_policy.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'expire-days': '3',
- 'name': 'default_name_4',
- 'warn-days': '5'
- }
-
- set_method_mock.assert_called_with('user', 'password-policy', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_peer.py b/test/units/modules/network/fortios/test_fortios_user_peer.py
deleted file mode 100644
index 044fd40481..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_peer.py
+++ /dev/null
@@ -1,319 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_peer
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_peer.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_peer_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_peer': {
- 'ca': 'test_value_3',
- 'cn': 'test_value_4',
- 'cn_type': 'string',
- 'ldap_mode': 'password',
- 'ldap_password': 'test_value_7',
- 'ldap_server': 'test_value_8',
- 'ldap_username': 'test_value_9',
- 'mandatory_ca_verify': 'enable',
- 'name': 'default_name_11',
- 'ocsp_override_server': 'test_value_12',
- 'passwd': 'test_value_13',
- 'subject': 'test_value_14',
- 'two_factor': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peer.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'ca': 'test_value_3',
- 'cn': 'test_value_4',
- 'cn-type': 'string',
- 'ldap-mode': 'password',
- 'ldap-password': 'test_value_7',
- 'ldap-server': 'test_value_8',
- 'ldap-username': 'test_value_9',
- 'mandatory-ca-verify': 'enable',
- 'name': 'default_name_11',
- 'ocsp-override-server': 'test_value_12',
- 'passwd': 'test_value_13',
- 'subject': 'test_value_14',
- 'two-factor': 'enable'
- }
-
- set_method_mock.assert_called_with('user', 'peer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_peer_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_peer': {
- 'ca': 'test_value_3',
- 'cn': 'test_value_4',
- 'cn_type': 'string',
- 'ldap_mode': 'password',
- 'ldap_password': 'test_value_7',
- 'ldap_server': 'test_value_8',
- 'ldap_username': 'test_value_9',
- 'mandatory_ca_verify': 'enable',
- 'name': 'default_name_11',
- 'ocsp_override_server': 'test_value_12',
- 'passwd': 'test_value_13',
- 'subject': 'test_value_14',
- 'two_factor': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peer.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'ca': 'test_value_3',
- 'cn': 'test_value_4',
- 'cn-type': 'string',
- 'ldap-mode': 'password',
- 'ldap-password': 'test_value_7',
- 'ldap-server': 'test_value_8',
- 'ldap-username': 'test_value_9',
- 'mandatory-ca-verify': 'enable',
- 'name': 'default_name_11',
- 'ocsp-override-server': 'test_value_12',
- 'passwd': 'test_value_13',
- 'subject': 'test_value_14',
- 'two-factor': 'enable'
- }
-
- set_method_mock.assert_called_with('user', 'peer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_peer_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_peer': {
- 'ca': 'test_value_3',
- 'cn': 'test_value_4',
- 'cn_type': 'string',
- 'ldap_mode': 'password',
- 'ldap_password': 'test_value_7',
- 'ldap_server': 'test_value_8',
- 'ldap_username': 'test_value_9',
- 'mandatory_ca_verify': 'enable',
- 'name': 'default_name_11',
- 'ocsp_override_server': 'test_value_12',
- 'passwd': 'test_value_13',
- 'subject': 'test_value_14',
- 'two_factor': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peer.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'peer', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_peer_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_peer': {
- 'ca': 'test_value_3',
- 'cn': 'test_value_4',
- 'cn_type': 'string',
- 'ldap_mode': 'password',
- 'ldap_password': 'test_value_7',
- 'ldap_server': 'test_value_8',
- 'ldap_username': 'test_value_9',
- 'mandatory_ca_verify': 'enable',
- 'name': 'default_name_11',
- 'ocsp_override_server': 'test_value_12',
- 'passwd': 'test_value_13',
- 'subject': 'test_value_14',
- 'two_factor': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peer.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'peer', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_peer_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_peer': {
- 'ca': 'test_value_3',
- 'cn': 'test_value_4',
- 'cn_type': 'string',
- 'ldap_mode': 'password',
- 'ldap_password': 'test_value_7',
- 'ldap_server': 'test_value_8',
- 'ldap_username': 'test_value_9',
- 'mandatory_ca_verify': 'enable',
- 'name': 'default_name_11',
- 'ocsp_override_server': 'test_value_12',
- 'passwd': 'test_value_13',
- 'subject': 'test_value_14',
- 'two_factor': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peer.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'ca': 'test_value_3',
- 'cn': 'test_value_4',
- 'cn-type': 'string',
- 'ldap-mode': 'password',
- 'ldap-password': 'test_value_7',
- 'ldap-server': 'test_value_8',
- 'ldap-username': 'test_value_9',
- 'mandatory-ca-verify': 'enable',
- 'name': 'default_name_11',
- 'ocsp-override-server': 'test_value_12',
- 'passwd': 'test_value_13',
- 'subject': 'test_value_14',
- 'two-factor': 'enable'
- }
-
- set_method_mock.assert_called_with('user', 'peer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_peer_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_peer': {
- 'random_attribute_not_valid': 'tag',
- 'ca': 'test_value_3',
- 'cn': 'test_value_4',
- 'cn_type': 'string',
- 'ldap_mode': 'password',
- 'ldap_password': 'test_value_7',
- 'ldap_server': 'test_value_8',
- 'ldap_username': 'test_value_9',
- 'mandatory_ca_verify': 'enable',
- 'name': 'default_name_11',
- 'ocsp_override_server': 'test_value_12',
- 'passwd': 'test_value_13',
- 'subject': 'test_value_14',
- 'two_factor': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peer.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'ca': 'test_value_3',
- 'cn': 'test_value_4',
- 'cn-type': 'string',
- 'ldap-mode': 'password',
- 'ldap-password': 'test_value_7',
- 'ldap-server': 'test_value_8',
- 'ldap-username': 'test_value_9',
- 'mandatory-ca-verify': 'enable',
- 'name': 'default_name_11',
- 'ocsp-override-server': 'test_value_12',
- 'passwd': 'test_value_13',
- 'subject': 'test_value_14',
- 'two-factor': 'enable'
- }
-
- set_method_mock.assert_called_with('user', 'peer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_peergrp.py b/test/units/modules/network/fortios/test_fortios_user_peergrp.py
deleted file mode 100644
index 68c91829ed..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_peergrp.py
+++ /dev/null
@@ -1,189 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_peergrp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_peergrp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_peergrp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_peergrp': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peergrp.fortios_user(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('user', 'peergrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_peergrp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_peergrp': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peergrp.fortios_user(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('user', 'peergrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_peergrp_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_peergrp': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peergrp.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'peergrp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_peergrp_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_peergrp': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peergrp.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'peergrp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_peergrp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_peergrp': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peergrp.fortios_user(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('user', 'peergrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_peergrp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_peergrp': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_peergrp.fortios_user(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('user', 'peergrp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_pop3.py b/test/units/modules/network/fortios/test_fortios_user_pop3.py
deleted file mode 100644
index cfba45ad65..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_pop3.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_pop3
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_pop3.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_pop3_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_pop3': {
- 'name': 'default_name_3',
- 'port': '4',
- 'secure': 'none',
- 'server': '192.168.100.6',
- 'ssl_min_proto_version': 'default'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_pop3.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'port': '4',
- 'secure': 'none',
- 'server': '192.168.100.6',
- 'ssl-min-proto-version': 'default'
- }
-
- set_method_mock.assert_called_with('user', 'pop3', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_pop3_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_pop3': {
- 'name': 'default_name_3',
- 'port': '4',
- 'secure': 'none',
- 'server': '192.168.100.6',
- 'ssl_min_proto_version': 'default'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_pop3.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'port': '4',
- 'secure': 'none',
- 'server': '192.168.100.6',
- 'ssl-min-proto-version': 'default'
- }
-
- set_method_mock.assert_called_with('user', 'pop3', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_pop3_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_pop3': {
- 'name': 'default_name_3',
- 'port': '4',
- 'secure': 'none',
- 'server': '192.168.100.6',
- 'ssl_min_proto_version': 'default'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_pop3.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'pop3', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_pop3_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_pop3': {
- 'name': 'default_name_3',
- 'port': '4',
- 'secure': 'none',
- 'server': '192.168.100.6',
- 'ssl_min_proto_version': 'default'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_pop3.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'pop3', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_pop3_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_pop3': {
- 'name': 'default_name_3',
- 'port': '4',
- 'secure': 'none',
- 'server': '192.168.100.6',
- 'ssl_min_proto_version': 'default'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_pop3.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'port': '4',
- 'secure': 'none',
- 'server': '192.168.100.6',
- 'ssl-min-proto-version': 'default'
- }
-
- set_method_mock.assert_called_with('user', 'pop3', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_pop3_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_pop3': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
- 'port': '4',
- 'secure': 'none',
- 'server': '192.168.100.6',
- 'ssl_min_proto_version': 'default'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_pop3.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'port': '4',
- 'secure': 'none',
- 'server': '192.168.100.6',
- 'ssl-min-proto-version': 'default'
- }
-
- set_method_mock.assert_called_with('user', 'pop3', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_quarantine.py b/test/units/modules/network/fortios/test_fortios_user_quarantine.py
deleted file mode 100644
index 441283c3fa..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_quarantine.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_quarantine
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_quarantine.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_quarantine_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_quarantine': {
- 'quarantine': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_quarantine.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'quarantine': 'enable',
-
- }
-
- set_method_mock.assert_called_with('user', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_quarantine_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_quarantine': {
- 'quarantine': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_quarantine.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'quarantine': 'enable',
-
- }
-
- set_method_mock.assert_called_with('user', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_quarantine_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_quarantine': {
- 'quarantine': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_quarantine.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'quarantine': 'enable',
-
- }
-
- set_method_mock.assert_called_with('user', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_quarantine_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_quarantine': {
- 'random_attribute_not_valid': 'tag',
- 'quarantine': 'enable',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_quarantine.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'quarantine': 'enable',
-
- }
-
- set_method_mock.assert_called_with('user', 'quarantine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_radius.py b/test/units/modules/network/fortios/test_fortios_user_radius.py
deleted file mode 100644
index 6e4e07118f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_radius.py
+++ /dev/null
@@ -1,539 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_radius
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_radius.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_radius_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_radius': {'acct_all_servers': 'enable',
- 'acct_interim_interval': '4',
- 'all_usergroup': 'disable',
- 'auth_type': 'auto',
- 'h3c_compatibility': 'enable',
- 'name': 'default_name_8',
- 'nas_ip': 'test_value_9',
- 'password_encoding': 'auto',
- 'password_renewal': 'enable',
- 'radius_coa': 'enable',
- 'radius_port': '13',
- 'rsso': 'enable',
- 'rsso_context_timeout': '15',
- 'rsso_endpoint_attribute': 'User-Name',
- 'rsso_endpoint_block_attribute': 'User-Name',
- 'rsso_ep_one_ip_only': 'enable',
- 'rsso_flush_ip_session': 'enable',
- 'rsso_log_flags': 'protocol-error',
- 'rsso_log_period': '21',
- 'rsso_radius_response': 'enable',
- 'rsso_radius_server_port': '23',
- 'rsso_secret': 'test_value_24',
- 'rsso_validate_request_secret': 'enable',
- 'secondary_secret': 'test_value_26',
- 'secondary_server': 'test_value_27',
- 'secret': 'test_value_28',
- 'server': '192.168.100.29',
- 'source_ip': '84.230.14.30',
- 'sso_attribute': 'User-Name',
- 'sso_attribute_key': 'test_value_32',
- 'sso_attribute_value_override': 'enable',
- 'tertiary_secret': 'test_value_34',
- 'tertiary_server': 'test_value_35',
- 'timeout': '36',
- 'use_management_vdom': 'enable',
- 'username_case_sensitive': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_radius.fortios_user(input_data, fos_instance)
-
- expected_data = {'acct-all-servers': 'enable',
- 'acct-interim-interval': '4',
- 'all-usergroup': 'disable',
- 'auth-type': 'auto',
- 'h3c-compatibility': 'enable',
- 'name': 'default_name_8',
- 'nas-ip': 'test_value_9',
- 'password-encoding': 'auto',
- 'password-renewal': 'enable',
- 'radius-coa': 'enable',
- 'radius-port': '13',
- 'rsso': 'enable',
- 'rsso-context-timeout': '15',
- 'rsso-endpoint-attribute': 'User-Name',
- 'rsso-endpoint-block-attribute': 'User-Name',
- 'rsso-ep-one-ip-only': 'enable',
- 'rsso-flush-ip-session': 'enable',
- 'rsso-log-flags': 'protocol-error',
- 'rsso-log-period': '21',
- 'rsso-radius-response': 'enable',
- 'rsso-radius-server-port': '23',
- 'rsso-secret': 'test_value_24',
- 'rsso-validate-request-secret': 'enable',
- 'secondary-secret': 'test_value_26',
- 'secondary-server': 'test_value_27',
- 'secret': 'test_value_28',
- 'server': '192.168.100.29',
- 'source-ip': '84.230.14.30',
- 'sso-attribute': 'User-Name',
- 'sso-attribute-key': 'test_value_32',
- 'sso-attribute-value-override': 'enable',
- 'tertiary-secret': 'test_value_34',
- 'tertiary-server': 'test_value_35',
- 'timeout': '36',
- 'use-management-vdom': 'enable',
- 'username-case-sensitive': 'enable'
- }
-
- set_method_mock.assert_called_with('user', 'radius', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_radius_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_radius': {'acct_all_servers': 'enable',
- 'acct_interim_interval': '4',
- 'all_usergroup': 'disable',
- 'auth_type': 'auto',
- 'h3c_compatibility': 'enable',
- 'name': 'default_name_8',
- 'nas_ip': 'test_value_9',
- 'password_encoding': 'auto',
- 'password_renewal': 'enable',
- 'radius_coa': 'enable',
- 'radius_port': '13',
- 'rsso': 'enable',
- 'rsso_context_timeout': '15',
- 'rsso_endpoint_attribute': 'User-Name',
- 'rsso_endpoint_block_attribute': 'User-Name',
- 'rsso_ep_one_ip_only': 'enable',
- 'rsso_flush_ip_session': 'enable',
- 'rsso_log_flags': 'protocol-error',
- 'rsso_log_period': '21',
- 'rsso_radius_response': 'enable',
- 'rsso_radius_server_port': '23',
- 'rsso_secret': 'test_value_24',
- 'rsso_validate_request_secret': 'enable',
- 'secondary_secret': 'test_value_26',
- 'secondary_server': 'test_value_27',
- 'secret': 'test_value_28',
- 'server': '192.168.100.29',
- 'source_ip': '84.230.14.30',
- 'sso_attribute': 'User-Name',
- 'sso_attribute_key': 'test_value_32',
- 'sso_attribute_value_override': 'enable',
- 'tertiary_secret': 'test_value_34',
- 'tertiary_server': 'test_value_35',
- 'timeout': '36',
- 'use_management_vdom': 'enable',
- 'username_case_sensitive': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_radius.fortios_user(input_data, fos_instance)
-
- expected_data = {'acct-all-servers': 'enable',
- 'acct-interim-interval': '4',
- 'all-usergroup': 'disable',
- 'auth-type': 'auto',
- 'h3c-compatibility': 'enable',
- 'name': 'default_name_8',
- 'nas-ip': 'test_value_9',
- 'password-encoding': 'auto',
- 'password-renewal': 'enable',
- 'radius-coa': 'enable',
- 'radius-port': '13',
- 'rsso': 'enable',
- 'rsso-context-timeout': '15',
- 'rsso-endpoint-attribute': 'User-Name',
- 'rsso-endpoint-block-attribute': 'User-Name',
- 'rsso-ep-one-ip-only': 'enable',
- 'rsso-flush-ip-session': 'enable',
- 'rsso-log-flags': 'protocol-error',
- 'rsso-log-period': '21',
- 'rsso-radius-response': 'enable',
- 'rsso-radius-server-port': '23',
- 'rsso-secret': 'test_value_24',
- 'rsso-validate-request-secret': 'enable',
- 'secondary-secret': 'test_value_26',
- 'secondary-server': 'test_value_27',
- 'secret': 'test_value_28',
- 'server': '192.168.100.29',
- 'source-ip': '84.230.14.30',
- 'sso-attribute': 'User-Name',
- 'sso-attribute-key': 'test_value_32',
- 'sso-attribute-value-override': 'enable',
- 'tertiary-secret': 'test_value_34',
- 'tertiary-server': 'test_value_35',
- 'timeout': '36',
- 'use-management-vdom': 'enable',
- 'username-case-sensitive': 'enable'
- }
-
- set_method_mock.assert_called_with('user', 'radius', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_radius_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_radius': {'acct_all_servers': 'enable',
- 'acct_interim_interval': '4',
- 'all_usergroup': 'disable',
- 'auth_type': 'auto',
- 'h3c_compatibility': 'enable',
- 'name': 'default_name_8',
- 'nas_ip': 'test_value_9',
- 'password_encoding': 'auto',
- 'password_renewal': 'enable',
- 'radius_coa': 'enable',
- 'radius_port': '13',
- 'rsso': 'enable',
- 'rsso_context_timeout': '15',
- 'rsso_endpoint_attribute': 'User-Name',
- 'rsso_endpoint_block_attribute': 'User-Name',
- 'rsso_ep_one_ip_only': 'enable',
- 'rsso_flush_ip_session': 'enable',
- 'rsso_log_flags': 'protocol-error',
- 'rsso_log_period': '21',
- 'rsso_radius_response': 'enable',
- 'rsso_radius_server_port': '23',
- 'rsso_secret': 'test_value_24',
- 'rsso_validate_request_secret': 'enable',
- 'secondary_secret': 'test_value_26',
- 'secondary_server': 'test_value_27',
- 'secret': 'test_value_28',
- 'server': '192.168.100.29',
- 'source_ip': '84.230.14.30',
- 'sso_attribute': 'User-Name',
- 'sso_attribute_key': 'test_value_32',
- 'sso_attribute_value_override': 'enable',
- 'tertiary_secret': 'test_value_34',
- 'tertiary_server': 'test_value_35',
- 'timeout': '36',
- 'use_management_vdom': 'enable',
- 'username_case_sensitive': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_radius.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'radius', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_radius_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_radius': {'acct_all_servers': 'enable',
- 'acct_interim_interval': '4',
- 'all_usergroup': 'disable',
- 'auth_type': 'auto',
- 'h3c_compatibility': 'enable',
- 'name': 'default_name_8',
- 'nas_ip': 'test_value_9',
- 'password_encoding': 'auto',
- 'password_renewal': 'enable',
- 'radius_coa': 'enable',
- 'radius_port': '13',
- 'rsso': 'enable',
- 'rsso_context_timeout': '15',
- 'rsso_endpoint_attribute': 'User-Name',
- 'rsso_endpoint_block_attribute': 'User-Name',
- 'rsso_ep_one_ip_only': 'enable',
- 'rsso_flush_ip_session': 'enable',
- 'rsso_log_flags': 'protocol-error',
- 'rsso_log_period': '21',
- 'rsso_radius_response': 'enable',
- 'rsso_radius_server_port': '23',
- 'rsso_secret': 'test_value_24',
- 'rsso_validate_request_secret': 'enable',
- 'secondary_secret': 'test_value_26',
- 'secondary_server': 'test_value_27',
- 'secret': 'test_value_28',
- 'server': '192.168.100.29',
- 'source_ip': '84.230.14.30',
- 'sso_attribute': 'User-Name',
- 'sso_attribute_key': 'test_value_32',
- 'sso_attribute_value_override': 'enable',
- 'tertiary_secret': 'test_value_34',
- 'tertiary_server': 'test_value_35',
- 'timeout': '36',
- 'use_management_vdom': 'enable',
- 'username_case_sensitive': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_radius.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'radius', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_radius_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_radius': {'acct_all_servers': 'enable',
- 'acct_interim_interval': '4',
- 'all_usergroup': 'disable',
- 'auth_type': 'auto',
- 'h3c_compatibility': 'enable',
- 'name': 'default_name_8',
- 'nas_ip': 'test_value_9',
- 'password_encoding': 'auto',
- 'password_renewal': 'enable',
- 'radius_coa': 'enable',
- 'radius_port': '13',
- 'rsso': 'enable',
- 'rsso_context_timeout': '15',
- 'rsso_endpoint_attribute': 'User-Name',
- 'rsso_endpoint_block_attribute': 'User-Name',
- 'rsso_ep_one_ip_only': 'enable',
- 'rsso_flush_ip_session': 'enable',
- 'rsso_log_flags': 'protocol-error',
- 'rsso_log_period': '21',
- 'rsso_radius_response': 'enable',
- 'rsso_radius_server_port': '23',
- 'rsso_secret': 'test_value_24',
- 'rsso_validate_request_secret': 'enable',
- 'secondary_secret': 'test_value_26',
- 'secondary_server': 'test_value_27',
- 'secret': 'test_value_28',
- 'server': '192.168.100.29',
- 'source_ip': '84.230.14.30',
- 'sso_attribute': 'User-Name',
- 'sso_attribute_key': 'test_value_32',
- 'sso_attribute_value_override': 'enable',
- 'tertiary_secret': 'test_value_34',
- 'tertiary_server': 'test_value_35',
- 'timeout': '36',
- 'use_management_vdom': 'enable',
- 'username_case_sensitive': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_radius.fortios_user(input_data, fos_instance)
-
- expected_data = {'acct-all-servers': 'enable',
- 'acct-interim-interval': '4',
- 'all-usergroup': 'disable',
- 'auth-type': 'auto',
- 'h3c-compatibility': 'enable',
- 'name': 'default_name_8',
- 'nas-ip': 'test_value_9',
- 'password-encoding': 'auto',
- 'password-renewal': 'enable',
- 'radius-coa': 'enable',
- 'radius-port': '13',
- 'rsso': 'enable',
- 'rsso-context-timeout': '15',
- 'rsso-endpoint-attribute': 'User-Name',
- 'rsso-endpoint-block-attribute': 'User-Name',
- 'rsso-ep-one-ip-only': 'enable',
- 'rsso-flush-ip-session': 'enable',
- 'rsso-log-flags': 'protocol-error',
- 'rsso-log-period': '21',
- 'rsso-radius-response': 'enable',
- 'rsso-radius-server-port': '23',
- 'rsso-secret': 'test_value_24',
- 'rsso-validate-request-secret': 'enable',
- 'secondary-secret': 'test_value_26',
- 'secondary-server': 'test_value_27',
- 'secret': 'test_value_28',
- 'server': '192.168.100.29',
- 'source-ip': '84.230.14.30',
- 'sso-attribute': 'User-Name',
- 'sso-attribute-key': 'test_value_32',
- 'sso-attribute-value-override': 'enable',
- 'tertiary-secret': 'test_value_34',
- 'tertiary-server': 'test_value_35',
- 'timeout': '36',
- 'use-management-vdom': 'enable',
- 'username-case-sensitive': 'enable'
- }
-
- set_method_mock.assert_called_with('user', 'radius', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_radius_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_radius': {
- 'random_attribute_not_valid': 'tag', 'acct_all_servers': 'enable',
- 'acct_interim_interval': '4',
- 'all_usergroup': 'disable',
- 'auth_type': 'auto',
- 'h3c_compatibility': 'enable',
- 'name': 'default_name_8',
- 'nas_ip': 'test_value_9',
- 'password_encoding': 'auto',
- 'password_renewal': 'enable',
- 'radius_coa': 'enable',
- 'radius_port': '13',
- 'rsso': 'enable',
- 'rsso_context_timeout': '15',
- 'rsso_endpoint_attribute': 'User-Name',
- 'rsso_endpoint_block_attribute': 'User-Name',
- 'rsso_ep_one_ip_only': 'enable',
- 'rsso_flush_ip_session': 'enable',
- 'rsso_log_flags': 'protocol-error',
- 'rsso_log_period': '21',
- 'rsso_radius_response': 'enable',
- 'rsso_radius_server_port': '23',
- 'rsso_secret': 'test_value_24',
- 'rsso_validate_request_secret': 'enable',
- 'secondary_secret': 'test_value_26',
- 'secondary_server': 'test_value_27',
- 'secret': 'test_value_28',
- 'server': '192.168.100.29',
- 'source_ip': '84.230.14.30',
- 'sso_attribute': 'User-Name',
- 'sso_attribute_key': 'test_value_32',
- 'sso_attribute_value_override': 'enable',
- 'tertiary_secret': 'test_value_34',
- 'tertiary_server': 'test_value_35',
- 'timeout': '36',
- 'use_management_vdom': 'enable',
- 'username_case_sensitive': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_radius.fortios_user(input_data, fos_instance)
-
- expected_data = {'acct-all-servers': 'enable',
- 'acct-interim-interval': '4',
- 'all-usergroup': 'disable',
- 'auth-type': 'auto',
- 'h3c-compatibility': 'enable',
- 'name': 'default_name_8',
- 'nas-ip': 'test_value_9',
- 'password-encoding': 'auto',
- 'password-renewal': 'enable',
- 'radius-coa': 'enable',
- 'radius-port': '13',
- 'rsso': 'enable',
- 'rsso-context-timeout': '15',
- 'rsso-endpoint-attribute': 'User-Name',
- 'rsso-endpoint-block-attribute': 'User-Name',
- 'rsso-ep-one-ip-only': 'enable',
- 'rsso-flush-ip-session': 'enable',
- 'rsso-log-flags': 'protocol-error',
- 'rsso-log-period': '21',
- 'rsso-radius-response': 'enable',
- 'rsso-radius-server-port': '23',
- 'rsso-secret': 'test_value_24',
- 'rsso-validate-request-secret': 'enable',
- 'secondary-secret': 'test_value_26',
- 'secondary-server': 'test_value_27',
- 'secret': 'test_value_28',
- 'server': '192.168.100.29',
- 'source-ip': '84.230.14.30',
- 'sso-attribute': 'User-Name',
- 'sso-attribute-key': 'test_value_32',
- 'sso-attribute-value-override': 'enable',
- 'tertiary-secret': 'test_value_34',
- 'tertiary-server': 'test_value_35',
- 'timeout': '36',
- 'use-management-vdom': 'enable',
- 'username-case-sensitive': 'enable'
- }
-
- set_method_mock.assert_called_with('user', 'radius', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_security_exempt_list.py b/test/units/modules/network/fortios/test_fortios_user_security_exempt_list.py
deleted file mode 100644
index b8e4780dbc..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_security_exempt_list.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_security_exempt_list
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_security_exempt_list.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_security_exempt_list_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_security_exempt_list': {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_security_exempt_list.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('user', 'security-exempt-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_security_exempt_list_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_security_exempt_list': {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_security_exempt_list.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('user', 'security-exempt-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_security_exempt_list_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_security_exempt_list': {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_security_exempt_list.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'security-exempt-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_security_exempt_list_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_security_exempt_list': {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_security_exempt_list.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'security-exempt-list', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_security_exempt_list_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_security_exempt_list': {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_security_exempt_list.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('user', 'security-exempt-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_security_exempt_list_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_security_exempt_list': {
- 'random_attribute_not_valid': 'tag',
- 'description': 'test_value_3',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_security_exempt_list.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'description': 'test_value_3',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('user', 'security-exempt-list', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_setting.py b/test/units/modules/network/fortios/test_fortios_user_setting.py
deleted file mode 100644
index 056de49aa4..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_setting.py
+++ /dev/null
@@ -1,263 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_setting': {
- 'auth_blackout_time': '3',
- 'auth_ca_cert': 'test_value_4',
- 'auth_cert': 'test_value_5',
- 'auth_http_basic': 'enable',
- 'auth_invalid_max': '7',
- 'auth_lockout_duration': '8',
- 'auth_lockout_threshold': '9',
- 'auth_portal_timeout': '10',
- 'auth_secure_http': 'enable',
- 'auth_src_mac': 'enable',
- 'auth_ssl_allow_renegotiation': 'enable',
- 'auth_timeout': '14',
- 'auth_timeout_type': 'idle-timeout',
- 'auth_type': 'http',
- 'radius_ses_timeout_act': 'hard-timeout'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_setting.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-blackout-time': '3',
- 'auth-ca-cert': 'test_value_4',
- 'auth-cert': 'test_value_5',
- 'auth-http-basic': 'enable',
- 'auth-invalid-max': '7',
- 'auth-lockout-duration': '8',
- 'auth-lockout-threshold': '9',
- 'auth-portal-timeout': '10',
- 'auth-secure-http': 'enable',
- 'auth-src-mac': 'enable',
- 'auth-ssl-allow-renegotiation': 'enable',
- 'auth-timeout': '14',
- 'auth-timeout-type': 'idle-timeout',
- 'auth-type': 'http',
- 'radius-ses-timeout-act': 'hard-timeout'
- }
-
- set_method_mock.assert_called_with('user', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_setting': {
- 'auth_blackout_time': '3',
- 'auth_ca_cert': 'test_value_4',
- 'auth_cert': 'test_value_5',
- 'auth_http_basic': 'enable',
- 'auth_invalid_max': '7',
- 'auth_lockout_duration': '8',
- 'auth_lockout_threshold': '9',
- 'auth_portal_timeout': '10',
- 'auth_secure_http': 'enable',
- 'auth_src_mac': 'enable',
- 'auth_ssl_allow_renegotiation': 'enable',
- 'auth_timeout': '14',
- 'auth_timeout_type': 'idle-timeout',
- 'auth_type': 'http',
- 'radius_ses_timeout_act': 'hard-timeout'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_setting.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-blackout-time': '3',
- 'auth-ca-cert': 'test_value_4',
- 'auth-cert': 'test_value_5',
- 'auth-http-basic': 'enable',
- 'auth-invalid-max': '7',
- 'auth-lockout-duration': '8',
- 'auth-lockout-threshold': '9',
- 'auth-portal-timeout': '10',
- 'auth-secure-http': 'enable',
- 'auth-src-mac': 'enable',
- 'auth-ssl-allow-renegotiation': 'enable',
- 'auth-timeout': '14',
- 'auth-timeout-type': 'idle-timeout',
- 'auth-type': 'http',
- 'radius-ses-timeout-act': 'hard-timeout'
- }
-
- set_method_mock.assert_called_with('user', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_setting': {
- 'auth_blackout_time': '3',
- 'auth_ca_cert': 'test_value_4',
- 'auth_cert': 'test_value_5',
- 'auth_http_basic': 'enable',
- 'auth_invalid_max': '7',
- 'auth_lockout_duration': '8',
- 'auth_lockout_threshold': '9',
- 'auth_portal_timeout': '10',
- 'auth_secure_http': 'enable',
- 'auth_src_mac': 'enable',
- 'auth_ssl_allow_renegotiation': 'enable',
- 'auth_timeout': '14',
- 'auth_timeout_type': 'idle-timeout',
- 'auth_type': 'http',
- 'radius_ses_timeout_act': 'hard-timeout'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_setting.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-blackout-time': '3',
- 'auth-ca-cert': 'test_value_4',
- 'auth-cert': 'test_value_5',
- 'auth-http-basic': 'enable',
- 'auth-invalid-max': '7',
- 'auth-lockout-duration': '8',
- 'auth-lockout-threshold': '9',
- 'auth-portal-timeout': '10',
- 'auth-secure-http': 'enable',
- 'auth-src-mac': 'enable',
- 'auth-ssl-allow-renegotiation': 'enable',
- 'auth-timeout': '14',
- 'auth-timeout-type': 'idle-timeout',
- 'auth-type': 'http',
- 'radius-ses-timeout-act': 'hard-timeout'
- }
-
- set_method_mock.assert_called_with('user', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_setting': {
- 'random_attribute_not_valid': 'tag',
- 'auth_blackout_time': '3',
- 'auth_ca_cert': 'test_value_4',
- 'auth_cert': 'test_value_5',
- 'auth_http_basic': 'enable',
- 'auth_invalid_max': '7',
- 'auth_lockout_duration': '8',
- 'auth_lockout_threshold': '9',
- 'auth_portal_timeout': '10',
- 'auth_secure_http': 'enable',
- 'auth_src_mac': 'enable',
- 'auth_ssl_allow_renegotiation': 'enable',
- 'auth_timeout': '14',
- 'auth_timeout_type': 'idle-timeout',
- 'auth_type': 'http',
- 'radius_ses_timeout_act': 'hard-timeout'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_setting.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'auth-blackout-time': '3',
- 'auth-ca-cert': 'test_value_4',
- 'auth-cert': 'test_value_5',
- 'auth-http-basic': 'enable',
- 'auth-invalid-max': '7',
- 'auth-lockout-duration': '8',
- 'auth-lockout-threshold': '9',
- 'auth-portal-timeout': '10',
- 'auth-secure-http': 'enable',
- 'auth-src-mac': 'enable',
- 'auth-ssl-allow-renegotiation': 'enable',
- 'auth-timeout': '14',
- 'auth-timeout-type': 'idle-timeout',
- 'auth-type': 'http',
- 'radius-ses-timeout-act': 'hard-timeout'
- }
-
- set_method_mock.assert_called_with('user', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_user_tacacsplus.py b/test/units/modules/network/fortios/test_fortios_user_tacacsplus.py
deleted file mode 100644
index 4df18b443d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_user_tacacsplus.py
+++ /dev/null
@@ -1,299 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_user_tacacsplus
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_user_tacacsplus.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_user_tacacsplus_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_tacacsplus': {
- 'authen_type': 'mschap',
- 'authorization': 'enable',
- 'key': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7',
- 'secondary_key': 'test_value_8',
- 'secondary_server': 'test_value_9',
- 'server': '192.168.100.10',
- 'source_ip': '84.230.14.11',
- 'tertiary_key': 'test_value_12',
- 'tertiary_server': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_tacacsplus.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'authen-type': 'mschap',
- 'authorization': 'enable',
- 'key': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7',
- 'secondary-key': 'test_value_8',
- 'secondary-server': 'test_value_9',
- 'server': '192.168.100.10',
- 'source-ip': '84.230.14.11',
- 'tertiary-key': 'test_value_12',
- 'tertiary-server': 'test_value_13'
- }
-
- set_method_mock.assert_called_with('user', 'tacacs+', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_tacacsplus_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_tacacsplus': {
- 'authen_type': 'mschap',
- 'authorization': 'enable',
- 'key': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7',
- 'secondary_key': 'test_value_8',
- 'secondary_server': 'test_value_9',
- 'server': '192.168.100.10',
- 'source_ip': '84.230.14.11',
- 'tertiary_key': 'test_value_12',
- 'tertiary_server': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_tacacsplus.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'authen-type': 'mschap',
- 'authorization': 'enable',
- 'key': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7',
- 'secondary-key': 'test_value_8',
- 'secondary-server': 'test_value_9',
- 'server': '192.168.100.10',
- 'source-ip': '84.230.14.11',
- 'tertiary-key': 'test_value_12',
- 'tertiary-server': 'test_value_13'
- }
-
- set_method_mock.assert_called_with('user', 'tacacs+', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_tacacsplus_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_tacacsplus': {
- 'authen_type': 'mschap',
- 'authorization': 'enable',
- 'key': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7',
- 'secondary_key': 'test_value_8',
- 'secondary_server': 'test_value_9',
- 'server': '192.168.100.10',
- 'source_ip': '84.230.14.11',
- 'tertiary_key': 'test_value_12',
- 'tertiary_server': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_tacacsplus.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'tacacs+', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_user_tacacsplus_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'user_tacacsplus': {
- 'authen_type': 'mschap',
- 'authorization': 'enable',
- 'key': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7',
- 'secondary_key': 'test_value_8',
- 'secondary_server': 'test_value_9',
- 'server': '192.168.100.10',
- 'source_ip': '84.230.14.11',
- 'tertiary_key': 'test_value_12',
- 'tertiary_server': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_tacacsplus.fortios_user(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('user', 'tacacs+', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_user_tacacsplus_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_tacacsplus': {
- 'authen_type': 'mschap',
- 'authorization': 'enable',
- 'key': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7',
- 'secondary_key': 'test_value_8',
- 'secondary_server': 'test_value_9',
- 'server': '192.168.100.10',
- 'source_ip': '84.230.14.11',
- 'tertiary_key': 'test_value_12',
- 'tertiary_server': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_tacacsplus.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'authen-type': 'mschap',
- 'authorization': 'enable',
- 'key': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7',
- 'secondary-key': 'test_value_8',
- 'secondary-server': 'test_value_9',
- 'server': '192.168.100.10',
- 'source-ip': '84.230.14.11',
- 'tertiary-key': 'test_value_12',
- 'tertiary-server': 'test_value_13'
- }
-
- set_method_mock.assert_called_with('user', 'tacacs+', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_user_tacacsplus_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'user_tacacsplus': {
- 'random_attribute_not_valid': 'tag',
- 'authen_type': 'mschap',
- 'authorization': 'enable',
- 'key': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7',
- 'secondary_key': 'test_value_8',
- 'secondary_server': 'test_value_9',
- 'server': '192.168.100.10',
- 'source_ip': '84.230.14.11',
- 'tertiary_key': 'test_value_12',
- 'tertiary_server': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_user_tacacsplus.fortios_user(input_data, fos_instance)
-
- expected_data = {
- 'authen-type': 'mschap',
- 'authorization': 'enable',
- 'key': 'test_value_5',
- 'name': 'default_name_6',
- 'port': '7',
- 'secondary-key': 'test_value_8',
- 'secondary-server': 'test_value_9',
- 'server': '192.168.100.10',
- 'source-ip': '84.230.14.11',
- 'tertiary-key': 'test_value_12',
- 'tertiary-server': 'test_value_13'
- }
-
- set_method_mock.assert_called_with('user', 'tacacs+', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_voip_profile.py b/test/units/modules/network/fortios/test_fortios_voip_profile.py
deleted file mode 100644
index 3ce7064a82..0000000000
--- a/test/units/modules/network/fortios/test_fortios_voip_profile.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_voip_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_voip_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_voip_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'voip_profile': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_voip_profile.fortios_voip(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('voip', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_voip_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'voip_profile': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_voip_profile.fortios_voip(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('voip', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_voip_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'voip_profile': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_voip_profile.fortios_voip(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('voip', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_voip_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'voip_profile': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_voip_profile.fortios_voip(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('voip', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_voip_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'voip_profile': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_voip_profile.fortios_voip(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('voip', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_voip_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'voip_profile': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_voip_profile.fortios_voip(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('voip', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_certificate_ca.py b/test/units/modules/network/fortios/test_fortios_vpn_certificate_ca.py
deleted file mode 100644
index 96cceb4190..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_certificate_ca.py
+++ /dev/null
@@ -1,289 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_certificate_ca
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_certificate_ca.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_certificate_ca_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_ca': {
- 'auto_update_days': '3',
- 'auto_update_days_warning': '4',
- 'ca': 'test_value_5',
- 'last_updated': '6',
- 'name': 'default_name_7',
- 'range': 'global',
- 'scep_url': 'test_value_9',
- 'source': 'factory',
- 'source_ip': '84.230.14.11',
- 'trusted': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ca.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'auto-update-days': '3',
- 'auto-update-days-warning': '4',
- 'ca': 'test_value_5',
- 'last-updated': '6',
- 'name': 'default_name_7',
- 'range': 'global',
- 'scep-url': 'test_value_9',
- 'source': 'factory',
- 'source-ip': '84.230.14.11',
- 'trusted': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'ca', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_certificate_ca_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_ca': {
- 'auto_update_days': '3',
- 'auto_update_days_warning': '4',
- 'ca': 'test_value_5',
- 'last_updated': '6',
- 'name': 'default_name_7',
- 'range': 'global',
- 'scep_url': 'test_value_9',
- 'source': 'factory',
- 'source_ip': '84.230.14.11',
- 'trusted': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ca.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'auto-update-days': '3',
- 'auto-update-days-warning': '4',
- 'ca': 'test_value_5',
- 'last-updated': '6',
- 'name': 'default_name_7',
- 'range': 'global',
- 'scep-url': 'test_value_9',
- 'source': 'factory',
- 'source-ip': '84.230.14.11',
- 'trusted': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'ca', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_certificate_ca_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_certificate_ca': {
- 'auto_update_days': '3',
- 'auto_update_days_warning': '4',
- 'ca': 'test_value_5',
- 'last_updated': '6',
- 'name': 'default_name_7',
- 'range': 'global',
- 'scep_url': 'test_value_9',
- 'source': 'factory',
- 'source_ip': '84.230.14.11',
- 'trusted': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ca.fortios_vpn_certificate(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.certificate', 'ca', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_certificate_ca_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_certificate_ca': {
- 'auto_update_days': '3',
- 'auto_update_days_warning': '4',
- 'ca': 'test_value_5',
- 'last_updated': '6',
- 'name': 'default_name_7',
- 'range': 'global',
- 'scep_url': 'test_value_9',
- 'source': 'factory',
- 'source_ip': '84.230.14.11',
- 'trusted': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ca.fortios_vpn_certificate(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.certificate', 'ca', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_certificate_ca_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_ca': {
- 'auto_update_days': '3',
- 'auto_update_days_warning': '4',
- 'ca': 'test_value_5',
- 'last_updated': '6',
- 'name': 'default_name_7',
- 'range': 'global',
- 'scep_url': 'test_value_9',
- 'source': 'factory',
- 'source_ip': '84.230.14.11',
- 'trusted': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ca.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'auto-update-days': '3',
- 'auto-update-days-warning': '4',
- 'ca': 'test_value_5',
- 'last-updated': '6',
- 'name': 'default_name_7',
- 'range': 'global',
- 'scep-url': 'test_value_9',
- 'source': 'factory',
- 'source-ip': '84.230.14.11',
- 'trusted': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'ca', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_certificate_ca_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_ca': {
- 'random_attribute_not_valid': 'tag',
- 'auto_update_days': '3',
- 'auto_update_days_warning': '4',
- 'ca': 'test_value_5',
- 'last_updated': '6',
- 'name': 'default_name_7',
- 'range': 'global',
- 'scep_url': 'test_value_9',
- 'source': 'factory',
- 'source_ip': '84.230.14.11',
- 'trusted': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ca.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'auto-update-days': '3',
- 'auto-update-days-warning': '4',
- 'ca': 'test_value_5',
- 'last-updated': '6',
- 'name': 'default_name_7',
- 'range': 'global',
- 'scep-url': 'test_value_9',
- 'source': 'factory',
- 'source-ip': '84.230.14.11',
- 'trusted': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'ca', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_certificate_crl.py b/test/units/modules/network/fortios/test_fortios_vpn_certificate_crl.py
deleted file mode 100644
index ca660d1ba0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_certificate_crl.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_certificate_crl
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_certificate_crl.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_certificate_crl_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_crl': {
- 'crl': 'test_value_3',
- 'http_url': 'test_value_4',
- 'last_updated': '5',
- 'ldap_password': 'test_value_6',
- 'ldap_server': 'test_value_7',
- 'ldap_username': 'test_value_8',
- 'name': 'default_name_9',
- 'range': 'global',
- 'scep_cert': 'test_value_11',
- 'scep_url': 'test_value_12',
- 'source': 'factory',
- 'source_ip': '84.230.14.14',
- 'update_interval': '15',
- 'update_vdom': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_crl.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'crl': 'test_value_3',
- 'http-url': 'test_value_4',
- 'last-updated': '5',
- 'ldap-password': 'test_value_6',
- 'ldap-server': 'test_value_7',
- 'ldap-username': 'test_value_8',
- 'name': 'default_name_9',
- 'range': 'global',
- 'scep-cert': 'test_value_11',
- 'scep-url': 'test_value_12',
- 'source': 'factory',
- 'source-ip': '84.230.14.14',
- 'update-interval': '15',
- 'update-vdom': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'crl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_certificate_crl_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_crl': {
- 'crl': 'test_value_3',
- 'http_url': 'test_value_4',
- 'last_updated': '5',
- 'ldap_password': 'test_value_6',
- 'ldap_server': 'test_value_7',
- 'ldap_username': 'test_value_8',
- 'name': 'default_name_9',
- 'range': 'global',
- 'scep_cert': 'test_value_11',
- 'scep_url': 'test_value_12',
- 'source': 'factory',
- 'source_ip': '84.230.14.14',
- 'update_interval': '15',
- 'update_vdom': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_crl.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'crl': 'test_value_3',
- 'http-url': 'test_value_4',
- 'last-updated': '5',
- 'ldap-password': 'test_value_6',
- 'ldap-server': 'test_value_7',
- 'ldap-username': 'test_value_8',
- 'name': 'default_name_9',
- 'range': 'global',
- 'scep-cert': 'test_value_11',
- 'scep-url': 'test_value_12',
- 'source': 'factory',
- 'source-ip': '84.230.14.14',
- 'update-interval': '15',
- 'update-vdom': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'crl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_certificate_crl_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_certificate_crl': {
- 'crl': 'test_value_3',
- 'http_url': 'test_value_4',
- 'last_updated': '5',
- 'ldap_password': 'test_value_6',
- 'ldap_server': 'test_value_7',
- 'ldap_username': 'test_value_8',
- 'name': 'default_name_9',
- 'range': 'global',
- 'scep_cert': 'test_value_11',
- 'scep_url': 'test_value_12',
- 'source': 'factory',
- 'source_ip': '84.230.14.14',
- 'update_interval': '15',
- 'update_vdom': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_crl.fortios_vpn_certificate(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.certificate', 'crl', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_certificate_crl_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_certificate_crl': {
- 'crl': 'test_value_3',
- 'http_url': 'test_value_4',
- 'last_updated': '5',
- 'ldap_password': 'test_value_6',
- 'ldap_server': 'test_value_7',
- 'ldap_username': 'test_value_8',
- 'name': 'default_name_9',
- 'range': 'global',
- 'scep_cert': 'test_value_11',
- 'scep_url': 'test_value_12',
- 'source': 'factory',
- 'source_ip': '84.230.14.14',
- 'update_interval': '15',
- 'update_vdom': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_crl.fortios_vpn_certificate(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.certificate', 'crl', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_certificate_crl_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_crl': {
- 'crl': 'test_value_3',
- 'http_url': 'test_value_4',
- 'last_updated': '5',
- 'ldap_password': 'test_value_6',
- 'ldap_server': 'test_value_7',
- 'ldap_username': 'test_value_8',
- 'name': 'default_name_9',
- 'range': 'global',
- 'scep_cert': 'test_value_11',
- 'scep_url': 'test_value_12',
- 'source': 'factory',
- 'source_ip': '84.230.14.14',
- 'update_interval': '15',
- 'update_vdom': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_crl.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'crl': 'test_value_3',
- 'http-url': 'test_value_4',
- 'last-updated': '5',
- 'ldap-password': 'test_value_6',
- 'ldap-server': 'test_value_7',
- 'ldap-username': 'test_value_8',
- 'name': 'default_name_9',
- 'range': 'global',
- 'scep-cert': 'test_value_11',
- 'scep-url': 'test_value_12',
- 'source': 'factory',
- 'source-ip': '84.230.14.14',
- 'update-interval': '15',
- 'update-vdom': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'crl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_certificate_crl_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_crl': {
- 'random_attribute_not_valid': 'tag',
- 'crl': 'test_value_3',
- 'http_url': 'test_value_4',
- 'last_updated': '5',
- 'ldap_password': 'test_value_6',
- 'ldap_server': 'test_value_7',
- 'ldap_username': 'test_value_8',
- 'name': 'default_name_9',
- 'range': 'global',
- 'scep_cert': 'test_value_11',
- 'scep_url': 'test_value_12',
- 'source': 'factory',
- 'source_ip': '84.230.14.14',
- 'update_interval': '15',
- 'update_vdom': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_crl.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'crl': 'test_value_3',
- 'http-url': 'test_value_4',
- 'last-updated': '5',
- 'ldap-password': 'test_value_6',
- 'ldap-server': 'test_value_7',
- 'ldap-username': 'test_value_8',
- 'name': 'default_name_9',
- 'range': 'global',
- 'scep-cert': 'test_value_11',
- 'scep-url': 'test_value_12',
- 'source': 'factory',
- 'source-ip': '84.230.14.14',
- 'update-interval': '15',
- 'update-vdom': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'crl', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_certificate_local.py b/test/units/modules/network/fortios/test_fortios_vpn_certificate_local.py
deleted file mode 100644
index c83c6c3e59..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_certificate_local.py
+++ /dev/null
@@ -1,429 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_certificate_local
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_certificate_local.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_certificate_local_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_local': {
- 'auto_regenerate_days': '3',
- 'auto_regenerate_days_warning': '4',
- 'ca_identifier': 'myId_5',
- 'certificate': 'test_value_6',
- 'cmp_path': 'test_value_7',
- 'cmp_regeneration_method': 'keyupate',
- 'cmp_server': 'test_value_9',
- 'cmp_server_cert': 'test_value_10',
- 'comments': 'test_value_11',
- 'csr': 'test_value_12',
- 'enroll_protocol': 'none',
- 'ike_localid': 'test_value_14',
- 'ike_localid_type': 'asn1dn',
- 'last_updated': '16',
- 'name': 'default_name_17',
- 'name_encoding': 'printable',
- 'password': 'test_value_19',
- 'private_key': 'test_value_20',
- 'range': 'global',
- 'scep_password': 'test_value_22',
- 'scep_url': 'test_value_23',
- 'source': 'factory',
- 'source_ip': '84.230.14.25',
- 'state': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_local.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'auto-regenerate-days': '3',
- 'auto-regenerate-days-warning': '4',
- 'ca-identifier': 'myId_5',
- 'certificate': 'test_value_6',
- 'cmp-path': 'test_value_7',
- 'cmp-regeneration-method': 'keyupate',
- 'cmp-server': 'test_value_9',
- 'cmp-server-cert': 'test_value_10',
- 'comments': 'test_value_11',
- 'csr': 'test_value_12',
- 'enroll-protocol': 'none',
- 'ike-localid': 'test_value_14',
- 'ike-localid-type': 'asn1dn',
- 'last-updated': '16',
- 'name': 'default_name_17',
- 'name-encoding': 'printable',
- 'password': 'test_value_19',
- 'private-key': 'test_value_20',
- 'range': 'global',
- 'scep-password': 'test_value_22',
- 'scep-url': 'test_value_23',
- 'source': 'factory',
- 'source-ip': '84.230.14.25',
- 'state': 'test_value_26'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'local', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_certificate_local_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_local': {
- 'auto_regenerate_days': '3',
- 'auto_regenerate_days_warning': '4',
- 'ca_identifier': 'myId_5',
- 'certificate': 'test_value_6',
- 'cmp_path': 'test_value_7',
- 'cmp_regeneration_method': 'keyupate',
- 'cmp_server': 'test_value_9',
- 'cmp_server_cert': 'test_value_10',
- 'comments': 'test_value_11',
- 'csr': 'test_value_12',
- 'enroll_protocol': 'none',
- 'ike_localid': 'test_value_14',
- 'ike_localid_type': 'asn1dn',
- 'last_updated': '16',
- 'name': 'default_name_17',
- 'name_encoding': 'printable',
- 'password': 'test_value_19',
- 'private_key': 'test_value_20',
- 'range': 'global',
- 'scep_password': 'test_value_22',
- 'scep_url': 'test_value_23',
- 'source': 'factory',
- 'source_ip': '84.230.14.25',
- 'state': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_local.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'auto-regenerate-days': '3',
- 'auto-regenerate-days-warning': '4',
- 'ca-identifier': 'myId_5',
- 'certificate': 'test_value_6',
- 'cmp-path': 'test_value_7',
- 'cmp-regeneration-method': 'keyupate',
- 'cmp-server': 'test_value_9',
- 'cmp-server-cert': 'test_value_10',
- 'comments': 'test_value_11',
- 'csr': 'test_value_12',
- 'enroll-protocol': 'none',
- 'ike-localid': 'test_value_14',
- 'ike-localid-type': 'asn1dn',
- 'last-updated': '16',
- 'name': 'default_name_17',
- 'name-encoding': 'printable',
- 'password': 'test_value_19',
- 'private-key': 'test_value_20',
- 'range': 'global',
- 'scep-password': 'test_value_22',
- 'scep-url': 'test_value_23',
- 'source': 'factory',
- 'source-ip': '84.230.14.25',
- 'state': 'test_value_26'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'local', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_certificate_local_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_certificate_local': {
- 'auto_regenerate_days': '3',
- 'auto_regenerate_days_warning': '4',
- 'ca_identifier': 'myId_5',
- 'certificate': 'test_value_6',
- 'cmp_path': 'test_value_7',
- 'cmp_regeneration_method': 'keyupate',
- 'cmp_server': 'test_value_9',
- 'cmp_server_cert': 'test_value_10',
- 'comments': 'test_value_11',
- 'csr': 'test_value_12',
- 'enroll_protocol': 'none',
- 'ike_localid': 'test_value_14',
- 'ike_localid_type': 'asn1dn',
- 'last_updated': '16',
- 'name': 'default_name_17',
- 'name_encoding': 'printable',
- 'password': 'test_value_19',
- 'private_key': 'test_value_20',
- 'range': 'global',
- 'scep_password': 'test_value_22',
- 'scep_url': 'test_value_23',
- 'source': 'factory',
- 'source_ip': '84.230.14.25',
- 'state': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_local.fortios_vpn_certificate(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.certificate', 'local', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_certificate_local_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_certificate_local': {
- 'auto_regenerate_days': '3',
- 'auto_regenerate_days_warning': '4',
- 'ca_identifier': 'myId_5',
- 'certificate': 'test_value_6',
- 'cmp_path': 'test_value_7',
- 'cmp_regeneration_method': 'keyupate',
- 'cmp_server': 'test_value_9',
- 'cmp_server_cert': 'test_value_10',
- 'comments': 'test_value_11',
- 'csr': 'test_value_12',
- 'enroll_protocol': 'none',
- 'ike_localid': 'test_value_14',
- 'ike_localid_type': 'asn1dn',
- 'last_updated': '16',
- 'name': 'default_name_17',
- 'name_encoding': 'printable',
- 'password': 'test_value_19',
- 'private_key': 'test_value_20',
- 'range': 'global',
- 'scep_password': 'test_value_22',
- 'scep_url': 'test_value_23',
- 'source': 'factory',
- 'source_ip': '84.230.14.25',
- 'state': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_local.fortios_vpn_certificate(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.certificate', 'local', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_certificate_local_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_local': {
- 'auto_regenerate_days': '3',
- 'auto_regenerate_days_warning': '4',
- 'ca_identifier': 'myId_5',
- 'certificate': 'test_value_6',
- 'cmp_path': 'test_value_7',
- 'cmp_regeneration_method': 'keyupate',
- 'cmp_server': 'test_value_9',
- 'cmp_server_cert': 'test_value_10',
- 'comments': 'test_value_11',
- 'csr': 'test_value_12',
- 'enroll_protocol': 'none',
- 'ike_localid': 'test_value_14',
- 'ike_localid_type': 'asn1dn',
- 'last_updated': '16',
- 'name': 'default_name_17',
- 'name_encoding': 'printable',
- 'password': 'test_value_19',
- 'private_key': 'test_value_20',
- 'range': 'global',
- 'scep_password': 'test_value_22',
- 'scep_url': 'test_value_23',
- 'source': 'factory',
- 'source_ip': '84.230.14.25',
- 'state': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_local.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'auto-regenerate-days': '3',
- 'auto-regenerate-days-warning': '4',
- 'ca-identifier': 'myId_5',
- 'certificate': 'test_value_6',
- 'cmp-path': 'test_value_7',
- 'cmp-regeneration-method': 'keyupate',
- 'cmp-server': 'test_value_9',
- 'cmp-server-cert': 'test_value_10',
- 'comments': 'test_value_11',
- 'csr': 'test_value_12',
- 'enroll-protocol': 'none',
- 'ike-localid': 'test_value_14',
- 'ike-localid-type': 'asn1dn',
- 'last-updated': '16',
- 'name': 'default_name_17',
- 'name-encoding': 'printable',
- 'password': 'test_value_19',
- 'private-key': 'test_value_20',
- 'range': 'global',
- 'scep-password': 'test_value_22',
- 'scep-url': 'test_value_23',
- 'source': 'factory',
- 'source-ip': '84.230.14.25',
- 'state': 'test_value_26'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'local', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_certificate_local_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_local': {
- 'random_attribute_not_valid': 'tag',
- 'auto_regenerate_days': '3',
- 'auto_regenerate_days_warning': '4',
- 'ca_identifier': 'myId_5',
- 'certificate': 'test_value_6',
- 'cmp_path': 'test_value_7',
- 'cmp_regeneration_method': 'keyupate',
- 'cmp_server': 'test_value_9',
- 'cmp_server_cert': 'test_value_10',
- 'comments': 'test_value_11',
- 'csr': 'test_value_12',
- 'enroll_protocol': 'none',
- 'ike_localid': 'test_value_14',
- 'ike_localid_type': 'asn1dn',
- 'last_updated': '16',
- 'name': 'default_name_17',
- 'name_encoding': 'printable',
- 'password': 'test_value_19',
- 'private_key': 'test_value_20',
- 'range': 'global',
- 'scep_password': 'test_value_22',
- 'scep_url': 'test_value_23',
- 'source': 'factory',
- 'source_ip': '84.230.14.25',
- 'state': 'test_value_26'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_local.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'auto-regenerate-days': '3',
- 'auto-regenerate-days-warning': '4',
- 'ca-identifier': 'myId_5',
- 'certificate': 'test_value_6',
- 'cmp-path': 'test_value_7',
- 'cmp-regeneration-method': 'keyupate',
- 'cmp-server': 'test_value_9',
- 'cmp-server-cert': 'test_value_10',
- 'comments': 'test_value_11',
- 'csr': 'test_value_12',
- 'enroll-protocol': 'none',
- 'ike-localid': 'test_value_14',
- 'ike-localid-type': 'asn1dn',
- 'last-updated': '16',
- 'name': 'default_name_17',
- 'name-encoding': 'printable',
- 'password': 'test_value_19',
- 'private-key': 'test_value_20',
- 'range': 'global',
- 'scep-password': 'test_value_22',
- 'scep-url': 'test_value_23',
- 'source': 'factory',
- 'source-ip': '84.230.14.25',
- 'state': 'test_value_26'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'local', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_certificate_ocsp_server.py b/test/units/modules/network/fortios/test_fortios_vpn_certificate_ocsp_server.py
deleted file mode 100644
index 0ec48bd289..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_certificate_ocsp_server.py
+++ /dev/null
@@ -1,259 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_certificate_ocsp_server
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_certificate_ocsp_server.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_certificate_ocsp_server_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_ocsp_server': {
- 'cert': 'test_value_3',
- 'name': 'default_name_4',
- 'secondary_cert': 'test_value_5',
- 'secondary_url': 'test_value_6',
- 'source_ip': '84.230.14.7',
- 'unavail_action': 'revoke',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ocsp_server.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'cert': 'test_value_3',
- 'name': 'default_name_4',
- 'secondary-cert': 'test_value_5',
- 'secondary-url': 'test_value_6',
- 'source-ip': '84.230.14.7',
- 'unavail-action': 'revoke',
- 'url': 'myurl_9.com'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'ocsp-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_certificate_ocsp_server_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_ocsp_server': {
- 'cert': 'test_value_3',
- 'name': 'default_name_4',
- 'secondary_cert': 'test_value_5',
- 'secondary_url': 'test_value_6',
- 'source_ip': '84.230.14.7',
- 'unavail_action': 'revoke',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ocsp_server.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'cert': 'test_value_3',
- 'name': 'default_name_4',
- 'secondary-cert': 'test_value_5',
- 'secondary-url': 'test_value_6',
- 'source-ip': '84.230.14.7',
- 'unavail-action': 'revoke',
- 'url': 'myurl_9.com'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'ocsp-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_certificate_ocsp_server_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_certificate_ocsp_server': {
- 'cert': 'test_value_3',
- 'name': 'default_name_4',
- 'secondary_cert': 'test_value_5',
- 'secondary_url': 'test_value_6',
- 'source_ip': '84.230.14.7',
- 'unavail_action': 'revoke',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ocsp_server.fortios_vpn_certificate(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.certificate', 'ocsp-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_certificate_ocsp_server_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_certificate_ocsp_server': {
- 'cert': 'test_value_3',
- 'name': 'default_name_4',
- 'secondary_cert': 'test_value_5',
- 'secondary_url': 'test_value_6',
- 'source_ip': '84.230.14.7',
- 'unavail_action': 'revoke',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ocsp_server.fortios_vpn_certificate(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.certificate', 'ocsp-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_certificate_ocsp_server_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_ocsp_server': {
- 'cert': 'test_value_3',
- 'name': 'default_name_4',
- 'secondary_cert': 'test_value_5',
- 'secondary_url': 'test_value_6',
- 'source_ip': '84.230.14.7',
- 'unavail_action': 'revoke',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ocsp_server.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'cert': 'test_value_3',
- 'name': 'default_name_4',
- 'secondary-cert': 'test_value_5',
- 'secondary-url': 'test_value_6',
- 'source-ip': '84.230.14.7',
- 'unavail-action': 'revoke',
- 'url': 'myurl_9.com'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'ocsp-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_certificate_ocsp_server_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_ocsp_server': {
- 'random_attribute_not_valid': 'tag',
- 'cert': 'test_value_3',
- 'name': 'default_name_4',
- 'secondary_cert': 'test_value_5',
- 'secondary_url': 'test_value_6',
- 'source_ip': '84.230.14.7',
- 'unavail_action': 'revoke',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_ocsp_server.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'cert': 'test_value_3',
- 'name': 'default_name_4',
- 'secondary-cert': 'test_value_5',
- 'secondary-url': 'test_value_6',
- 'source-ip': '84.230.14.7',
- 'unavail-action': 'revoke',
- 'url': 'myurl_9.com'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'ocsp-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_certificate_remote.py b/test/units/modules/network/fortios/test_fortios_vpn_certificate_remote.py
deleted file mode 100644
index 926d1a12b6..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_certificate_remote.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_certificate_remote
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_certificate_remote.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_certificate_remote_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_remote': {
- 'name': 'default_name_3',
- 'range': 'global',
- 'remote': 'test_value_5',
- 'source': 'factory'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_remote.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'range': 'global',
- 'remote': 'test_value_5',
- 'source': 'factory'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'remote', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_certificate_remote_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_remote': {
- 'name': 'default_name_3',
- 'range': 'global',
- 'remote': 'test_value_5',
- 'source': 'factory'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_remote.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'range': 'global',
- 'remote': 'test_value_5',
- 'source': 'factory'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'remote', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_certificate_remote_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_certificate_remote': {
- 'name': 'default_name_3',
- 'range': 'global',
- 'remote': 'test_value_5',
- 'source': 'factory'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_remote.fortios_vpn_certificate(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.certificate', 'remote', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_certificate_remote_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_certificate_remote': {
- 'name': 'default_name_3',
- 'range': 'global',
- 'remote': 'test_value_5',
- 'source': 'factory'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_remote.fortios_vpn_certificate(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.certificate', 'remote', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_certificate_remote_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_remote': {
- 'name': 'default_name_3',
- 'range': 'global',
- 'remote': 'test_value_5',
- 'source': 'factory'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_remote.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'range': 'global',
- 'remote': 'test_value_5',
- 'source': 'factory'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'remote', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_certificate_remote_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_remote': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
- 'range': 'global',
- 'remote': 'test_value_5',
- 'source': 'factory'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_remote.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'range': 'global',
- 'remote': 'test_value_5',
- 'source': 'factory'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'remote', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_certificate_setting.py b/test/units/modules/network/fortios/test_fortios_vpn_certificate_setting.py
deleted file mode 100644
index 2fd011233e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_certificate_setting.py
+++ /dev/null
@@ -1,287 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_certificate_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_certificate_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_certificate_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_setting': {
- 'certname_dsa1024': 'test_value_3',
- 'certname_dsa2048': 'test_value_4',
- 'certname_ecdsa256': 'test_value_5',
- 'certname_ecdsa384': 'test_value_6',
- 'certname_rsa1024': 'test_value_7',
- 'certname_rsa2048': 'test_value_8',
- 'check_ca_cert': 'enable',
- 'check_ca_chain': 'enable',
- 'cmp_save_extra_certs': 'enable',
- 'cn_match': 'substring',
- 'ocsp_default_server': 'test_value_13',
- 'ocsp_status': 'enable',
- 'ssl_min_proto_version': 'default',
- 'ssl_ocsp_option': 'certificate',
- 'ssl_ocsp_status': 'enable',
- 'strict_crl_check': 'enable',
- 'strict_ocsp_check': 'enable',
- 'subject_match': 'substring'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_setting.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'certname-dsa1024': 'test_value_3',
- 'certname-dsa2048': 'test_value_4',
- 'certname-ecdsa256': 'test_value_5',
- 'certname-ecdsa384': 'test_value_6',
- 'certname-rsa1024': 'test_value_7',
- 'certname-rsa2048': 'test_value_8',
- 'check-ca-cert': 'enable',
- 'check-ca-chain': 'enable',
- 'cmp-save-extra-certs': 'enable',
- 'cn-match': 'substring',
- 'ocsp-default-server': 'test_value_13',
- 'ocsp-status': 'enable',
- 'ssl-min-proto-version': 'default',
- 'ssl-ocsp-option': 'certificate',
- 'ssl-ocsp-status': 'enable',
- 'strict-crl-check': 'enable',
- 'strict-ocsp-check': 'enable',
- 'subject-match': 'substring'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_certificate_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_setting': {
- 'certname_dsa1024': 'test_value_3',
- 'certname_dsa2048': 'test_value_4',
- 'certname_ecdsa256': 'test_value_5',
- 'certname_ecdsa384': 'test_value_6',
- 'certname_rsa1024': 'test_value_7',
- 'certname_rsa2048': 'test_value_8',
- 'check_ca_cert': 'enable',
- 'check_ca_chain': 'enable',
- 'cmp_save_extra_certs': 'enable',
- 'cn_match': 'substring',
- 'ocsp_default_server': 'test_value_13',
- 'ocsp_status': 'enable',
- 'ssl_min_proto_version': 'default',
- 'ssl_ocsp_option': 'certificate',
- 'ssl_ocsp_status': 'enable',
- 'strict_crl_check': 'enable',
- 'strict_ocsp_check': 'enable',
- 'subject_match': 'substring'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_setting.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'certname-dsa1024': 'test_value_3',
- 'certname-dsa2048': 'test_value_4',
- 'certname-ecdsa256': 'test_value_5',
- 'certname-ecdsa384': 'test_value_6',
- 'certname-rsa1024': 'test_value_7',
- 'certname-rsa2048': 'test_value_8',
- 'check-ca-cert': 'enable',
- 'check-ca-chain': 'enable',
- 'cmp-save-extra-certs': 'enable',
- 'cn-match': 'substring',
- 'ocsp-default-server': 'test_value_13',
- 'ocsp-status': 'enable',
- 'ssl-min-proto-version': 'default',
- 'ssl-ocsp-option': 'certificate',
- 'ssl-ocsp-status': 'enable',
- 'strict-crl-check': 'enable',
- 'strict-ocsp-check': 'enable',
- 'subject-match': 'substring'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_certificate_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_setting': {
- 'certname_dsa1024': 'test_value_3',
- 'certname_dsa2048': 'test_value_4',
- 'certname_ecdsa256': 'test_value_5',
- 'certname_ecdsa384': 'test_value_6',
- 'certname_rsa1024': 'test_value_7',
- 'certname_rsa2048': 'test_value_8',
- 'check_ca_cert': 'enable',
- 'check_ca_chain': 'enable',
- 'cmp_save_extra_certs': 'enable',
- 'cn_match': 'substring',
- 'ocsp_default_server': 'test_value_13',
- 'ocsp_status': 'enable',
- 'ssl_min_proto_version': 'default',
- 'ssl_ocsp_option': 'certificate',
- 'ssl_ocsp_status': 'enable',
- 'strict_crl_check': 'enable',
- 'strict_ocsp_check': 'enable',
- 'subject_match': 'substring'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_setting.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'certname-dsa1024': 'test_value_3',
- 'certname-dsa2048': 'test_value_4',
- 'certname-ecdsa256': 'test_value_5',
- 'certname-ecdsa384': 'test_value_6',
- 'certname-rsa1024': 'test_value_7',
- 'certname-rsa2048': 'test_value_8',
- 'check-ca-cert': 'enable',
- 'check-ca-chain': 'enable',
- 'cmp-save-extra-certs': 'enable',
- 'cn-match': 'substring',
- 'ocsp-default-server': 'test_value_13',
- 'ocsp-status': 'enable',
- 'ssl-min-proto-version': 'default',
- 'ssl-ocsp-option': 'certificate',
- 'ssl-ocsp-status': 'enable',
- 'strict-crl-check': 'enable',
- 'strict-ocsp-check': 'enable',
- 'subject-match': 'substring'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_certificate_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_certificate_setting': {
- 'random_attribute_not_valid': 'tag',
- 'certname_dsa1024': 'test_value_3',
- 'certname_dsa2048': 'test_value_4',
- 'certname_ecdsa256': 'test_value_5',
- 'certname_ecdsa384': 'test_value_6',
- 'certname_rsa1024': 'test_value_7',
- 'certname_rsa2048': 'test_value_8',
- 'check_ca_cert': 'enable',
- 'check_ca_chain': 'enable',
- 'cmp_save_extra_certs': 'enable',
- 'cn_match': 'substring',
- 'ocsp_default_server': 'test_value_13',
- 'ocsp_status': 'enable',
- 'ssl_min_proto_version': 'default',
- 'ssl_ocsp_option': 'certificate',
- 'ssl_ocsp_status': 'enable',
- 'strict_crl_check': 'enable',
- 'strict_ocsp_check': 'enable',
- 'subject_match': 'substring'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_certificate_setting.fortios_vpn_certificate(input_data, fos_instance)
-
- expected_data = {
- 'certname-dsa1024': 'test_value_3',
- 'certname-dsa2048': 'test_value_4',
- 'certname-ecdsa256': 'test_value_5',
- 'certname-ecdsa384': 'test_value_6',
- 'certname-rsa1024': 'test_value_7',
- 'certname-rsa2048': 'test_value_8',
- 'check-ca-cert': 'enable',
- 'check-ca-chain': 'enable',
- 'cmp-save-extra-certs': 'enable',
- 'cn-match': 'substring',
- 'ocsp-default-server': 'test_value_13',
- 'ocsp-status': 'enable',
- 'ssl-min-proto-version': 'default',
- 'ssl-ocsp-option': 'certificate',
- 'ssl-ocsp-status': 'enable',
- 'strict-crl-check': 'enable',
- 'strict-ocsp-check': 'enable',
- 'subject-match': 'substring'
- }
-
- set_method_mock.assert_called_with('vpn.certificate', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_concentrator.py b/test/units/modules/network/fortios/test_fortios_vpn_ipsec_concentrator.py
deleted file mode 100644
index fb103d3c7b..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_concentrator.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ipsec_concentrator
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ipsec_concentrator.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ipsec_concentrator_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_concentrator': {'name': 'default_name_3',
- 'src_check': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_concentrator.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'src-check': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'concentrator', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_concentrator_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_concentrator': {'name': 'default_name_3',
- 'src_check': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_concentrator.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'src-check': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'concentrator', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_concentrator_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_concentrator': {'name': 'default_name_3',
- 'src_check': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_concentrator.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'concentrator', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_concentrator_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_concentrator': {'name': 'default_name_3',
- 'src_check': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_concentrator.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'concentrator', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_concentrator_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_concentrator': {'name': 'default_name_3',
- 'src_check': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_concentrator.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'src-check': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'concentrator', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ipsec_concentrator_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_concentrator': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3',
- 'src_check': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_concentrator.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3',
- 'src-check': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'concentrator', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_forticlient.py b/test/units/modules/network/fortios/test_fortios_vpn_ipsec_forticlient.py
deleted file mode 100644
index f448f3370b..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_forticlient.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ipsec_forticlient
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ipsec_forticlient.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ipsec_forticlient_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_forticlient': {
- 'phase2name': 'test_value_3',
- 'realm': 'test_value_4',
- 'status': 'enable',
- 'usergroupname': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_forticlient.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'phase2name': 'test_value_3',
- 'realm': 'test_value_4',
- 'status': 'enable',
- 'usergroupname': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'forticlient', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_forticlient_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_forticlient': {
- 'phase2name': 'test_value_3',
- 'realm': 'test_value_4',
- 'status': 'enable',
- 'usergroupname': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_forticlient.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'phase2name': 'test_value_3',
- 'realm': 'test_value_4',
- 'status': 'enable',
- 'usergroupname': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'forticlient', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_forticlient_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_forticlient': {
- 'phase2name': 'test_value_3',
- 'realm': 'test_value_4',
- 'status': 'enable',
- 'usergroupname': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_forticlient.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'forticlient', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_forticlient_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_forticlient': {
- 'phase2name': 'test_value_3',
- 'realm': 'test_value_4',
- 'status': 'enable',
- 'usergroupname': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_forticlient.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'forticlient', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_forticlient_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_forticlient': {
- 'phase2name': 'test_value_3',
- 'realm': 'test_value_4',
- 'status': 'enable',
- 'usergroupname': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_forticlient.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'phase2name': 'test_value_3',
- 'realm': 'test_value_4',
- 'status': 'enable',
- 'usergroupname': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'forticlient', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ipsec_forticlient_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_forticlient': {
- 'random_attribute_not_valid': 'tag',
- 'phase2name': 'test_value_3',
- 'realm': 'test_value_4',
- 'status': 'enable',
- 'usergroupname': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_forticlient.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'phase2name': 'test_value_3',
- 'realm': 'test_value_4',
- 'status': 'enable',
- 'usergroupname': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'forticlient', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_manualkey.py b/test/units/modules/network/fortios/test_fortios_vpn_ipsec_manualkey.py
deleted file mode 100644
index 0bc4787ca2..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_manualkey.py
+++ /dev/null
@@ -1,289 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ipsec_manualkey
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ipsec_manualkey.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ipsec_manualkey_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_manualkey': {
- 'authentication': 'null',
- 'authkey': 'test_value_4',
- 'enckey': 'test_value_5',
- 'encryption': 'null',
- 'interface': 'test_value_7',
- 'local_gw': 'test_value_8',
- 'localspi': 'test_value_9',
- 'name': 'default_name_10',
- 'remote_gw': 'test_value_11',
- 'remotespi': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'authentication': 'null',
- 'authkey': 'test_value_4',
- 'enckey': 'test_value_5',
- 'encryption': 'null',
- 'interface': 'test_value_7',
- 'local-gw': 'test_value_8',
- 'localspi': 'test_value_9',
- 'name': 'default_name_10',
- 'remote-gw': 'test_value_11',
- 'remotespi': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'manualkey', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_manualkey_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_manualkey': {
- 'authentication': 'null',
- 'authkey': 'test_value_4',
- 'enckey': 'test_value_5',
- 'encryption': 'null',
- 'interface': 'test_value_7',
- 'local_gw': 'test_value_8',
- 'localspi': 'test_value_9',
- 'name': 'default_name_10',
- 'remote_gw': 'test_value_11',
- 'remotespi': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'authentication': 'null',
- 'authkey': 'test_value_4',
- 'enckey': 'test_value_5',
- 'encryption': 'null',
- 'interface': 'test_value_7',
- 'local-gw': 'test_value_8',
- 'localspi': 'test_value_9',
- 'name': 'default_name_10',
- 'remote-gw': 'test_value_11',
- 'remotespi': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'manualkey', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_manualkey_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_manualkey': {
- 'authentication': 'null',
- 'authkey': 'test_value_4',
- 'enckey': 'test_value_5',
- 'encryption': 'null',
- 'interface': 'test_value_7',
- 'local_gw': 'test_value_8',
- 'localspi': 'test_value_9',
- 'name': 'default_name_10',
- 'remote_gw': 'test_value_11',
- 'remotespi': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'manualkey', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_manualkey_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_manualkey': {
- 'authentication': 'null',
- 'authkey': 'test_value_4',
- 'enckey': 'test_value_5',
- 'encryption': 'null',
- 'interface': 'test_value_7',
- 'local_gw': 'test_value_8',
- 'localspi': 'test_value_9',
- 'name': 'default_name_10',
- 'remote_gw': 'test_value_11',
- 'remotespi': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'manualkey', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_manualkey_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_manualkey': {
- 'authentication': 'null',
- 'authkey': 'test_value_4',
- 'enckey': 'test_value_5',
- 'encryption': 'null',
- 'interface': 'test_value_7',
- 'local_gw': 'test_value_8',
- 'localspi': 'test_value_9',
- 'name': 'default_name_10',
- 'remote_gw': 'test_value_11',
- 'remotespi': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'authentication': 'null',
- 'authkey': 'test_value_4',
- 'enckey': 'test_value_5',
- 'encryption': 'null',
- 'interface': 'test_value_7',
- 'local-gw': 'test_value_8',
- 'localspi': 'test_value_9',
- 'name': 'default_name_10',
- 'remote-gw': 'test_value_11',
- 'remotespi': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'manualkey', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ipsec_manualkey_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_manualkey': {
- 'random_attribute_not_valid': 'tag',
- 'authentication': 'null',
- 'authkey': 'test_value_4',
- 'enckey': 'test_value_5',
- 'encryption': 'null',
- 'interface': 'test_value_7',
- 'local_gw': 'test_value_8',
- 'localspi': 'test_value_9',
- 'name': 'default_name_10',
- 'remote_gw': 'test_value_11',
- 'remotespi': 'test_value_12'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'authentication': 'null',
- 'authkey': 'test_value_4',
- 'enckey': 'test_value_5',
- 'encryption': 'null',
- 'interface': 'test_value_7',
- 'local-gw': 'test_value_8',
- 'localspi': 'test_value_9',
- 'name': 'default_name_10',
- 'remote-gw': 'test_value_11',
- 'remotespi': 'test_value_12'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'manualkey', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_manualkey_interface.py b/test/units/modules/network/fortios/test_fortios_vpn_ipsec_manualkey_interface.py
deleted file mode 100644
index d08c4f2142..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_manualkey_interface.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ipsec_manualkey_interface
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ipsec_manualkey_interface.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ipsec_manualkey_interface_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_manualkey_interface': {
- 'addr_type': '4',
- 'auth_alg': 'null',
- 'auth_key': 'test_value_5',
- 'enc_alg': 'null',
- 'enc_key': 'test_value_7',
- 'interface': 'test_value_8',
- 'ip_version': '4',
- 'local_gw': 'test_value_10',
- 'local_gw6': 'test_value_11',
- 'local_spi': 'test_value_12',
- 'name': 'default_name_13',
- 'remote_gw': 'test_value_14',
- 'remote_gw6': 'test_value_15',
- 'remote_spi': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'addr-type': '4',
- 'auth-alg': 'null',
- 'auth-key': 'test_value_5',
- 'enc-alg': 'null',
- 'enc-key': 'test_value_7',
- 'interface': 'test_value_8',
- 'ip-version': '4',
- 'local-gw': 'test_value_10',
- 'local-gw6': 'test_value_11',
- 'local-spi': 'test_value_12',
- 'name': 'default_name_13',
- 'remote-gw': 'test_value_14',
- 'remote-gw6': 'test_value_15',
- 'remote-spi': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'manualkey-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_manualkey_interface_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_manualkey_interface': {
- 'addr_type': '4',
- 'auth_alg': 'null',
- 'auth_key': 'test_value_5',
- 'enc_alg': 'null',
- 'enc_key': 'test_value_7',
- 'interface': 'test_value_8',
- 'ip_version': '4',
- 'local_gw': 'test_value_10',
- 'local_gw6': 'test_value_11',
- 'local_spi': 'test_value_12',
- 'name': 'default_name_13',
- 'remote_gw': 'test_value_14',
- 'remote_gw6': 'test_value_15',
- 'remote_spi': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'addr-type': '4',
- 'auth-alg': 'null',
- 'auth-key': 'test_value_5',
- 'enc-alg': 'null',
- 'enc-key': 'test_value_7',
- 'interface': 'test_value_8',
- 'ip-version': '4',
- 'local-gw': 'test_value_10',
- 'local-gw6': 'test_value_11',
- 'local-spi': 'test_value_12',
- 'name': 'default_name_13',
- 'remote-gw': 'test_value_14',
- 'remote-gw6': 'test_value_15',
- 'remote-spi': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'manualkey-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_manualkey_interface_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_manualkey_interface': {
- 'addr_type': '4',
- 'auth_alg': 'null',
- 'auth_key': 'test_value_5',
- 'enc_alg': 'null',
- 'enc_key': 'test_value_7',
- 'interface': 'test_value_8',
- 'ip_version': '4',
- 'local_gw': 'test_value_10',
- 'local_gw6': 'test_value_11',
- 'local_spi': 'test_value_12',
- 'name': 'default_name_13',
- 'remote_gw': 'test_value_14',
- 'remote_gw6': 'test_value_15',
- 'remote_spi': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'manualkey-interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_manualkey_interface_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_manualkey_interface': {
- 'addr_type': '4',
- 'auth_alg': 'null',
- 'auth_key': 'test_value_5',
- 'enc_alg': 'null',
- 'enc_key': 'test_value_7',
- 'interface': 'test_value_8',
- 'ip_version': '4',
- 'local_gw': 'test_value_10',
- 'local_gw6': 'test_value_11',
- 'local_spi': 'test_value_12',
- 'name': 'default_name_13',
- 'remote_gw': 'test_value_14',
- 'remote_gw6': 'test_value_15',
- 'remote_spi': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'manualkey-interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_manualkey_interface_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_manualkey_interface': {
- 'addr_type': '4',
- 'auth_alg': 'null',
- 'auth_key': 'test_value_5',
- 'enc_alg': 'null',
- 'enc_key': 'test_value_7',
- 'interface': 'test_value_8',
- 'ip_version': '4',
- 'local_gw': 'test_value_10',
- 'local_gw6': 'test_value_11',
- 'local_spi': 'test_value_12',
- 'name': 'default_name_13',
- 'remote_gw': 'test_value_14',
- 'remote_gw6': 'test_value_15',
- 'remote_spi': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'addr-type': '4',
- 'auth-alg': 'null',
- 'auth-key': 'test_value_5',
- 'enc-alg': 'null',
- 'enc-key': 'test_value_7',
- 'interface': 'test_value_8',
- 'ip-version': '4',
- 'local-gw': 'test_value_10',
- 'local-gw6': 'test_value_11',
- 'local-spi': 'test_value_12',
- 'name': 'default_name_13',
- 'remote-gw': 'test_value_14',
- 'remote-gw6': 'test_value_15',
- 'remote-spi': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'manualkey-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ipsec_manualkey_interface_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_manualkey_interface': {
- 'random_attribute_not_valid': 'tag',
- 'addr_type': '4',
- 'auth_alg': 'null',
- 'auth_key': 'test_value_5',
- 'enc_alg': 'null',
- 'enc_key': 'test_value_7',
- 'interface': 'test_value_8',
- 'ip_version': '4',
- 'local_gw': 'test_value_10',
- 'local_gw6': 'test_value_11',
- 'local_spi': 'test_value_12',
- 'name': 'default_name_13',
- 'remote_gw': 'test_value_14',
- 'remote_gw6': 'test_value_15',
- 'remote_spi': 'test_value_16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_manualkey_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'addr-type': '4',
- 'auth-alg': 'null',
- 'auth-key': 'test_value_5',
- 'enc-alg': 'null',
- 'enc-key': 'test_value_7',
- 'interface': 'test_value_8',
- 'ip-version': '4',
- 'local-gw': 'test_value_10',
- 'local-gw6': 'test_value_11',
- 'local-spi': 'test_value_12',
- 'name': 'default_name_13',
- 'remote-gw': 'test_value_14',
- 'remote-gw6': 'test_value_15',
- 'remote-spi': 'test_value_16'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'manualkey-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase1.py b/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase1.py
deleted file mode 100644
index b46caff350..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase1.py
+++ /dev/null
@@ -1,1149 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ipsec_phase1
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ipsec_phase1.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ipsec_phase1_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase1': {
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_14',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_19',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '22',
- 'dns_mode': 'manual',
- 'domain': 'test_value_24',
- 'dpd': 'disable',
- 'dpd_retrycount': '26',
- 'dpd_retryinterval': 'test_value_27',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'enforce_unique_id': 'disable',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '33',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_35',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '38',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_41',
- 'ipv4_dns_server1': 'test_value_42',
- 'ipv4_dns_server2': 'test_value_43',
- 'ipv4_dns_server3': 'test_value_44',
- 'ipv4_end_ip': 'test_value_45',
- 'ipv4_name': 'test_value_46',
- 'ipv4_netmask': 'test_value_47',
- 'ipv4_split_exclude': 'test_value_48',
- 'ipv4_split_include': 'test_value_49',
- 'ipv4_start_ip': 'test_value_50',
- 'ipv4_wins_server1': 'test_value_51',
- 'ipv4_wins_server2': 'test_value_52',
- 'ipv6_dns_server1': 'test_value_53',
- 'ipv6_dns_server2': 'test_value_54',
- 'ipv6_dns_server3': 'test_value_55',
- 'ipv6_end_ip': 'test_value_56',
- 'ipv6_name': 'test_value_57',
- 'ipv6_prefix': '58',
- 'ipv6_split_exclude': 'test_value_59',
- 'ipv6_split_include': 'test_value_60',
- 'ipv6_start_ip': 'test_value_61',
- 'keepalive': '62',
- 'keylife': '63',
- 'local_gw': 'test_value_64',
- 'localid': 'test_value_65',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'name': 'default_name_70',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '72',
- 'peer': 'test_value_73',
- 'peergrp': 'test_value_74',
- 'peerid': 'test_value_75',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_78',
- 'ppk_secret': 'test_value_79',
- 'priority': '80',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_82',
- 'psksecret_remote': 'test_value_83',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_86',
- 'remotegw_ddns': 'test_value_87',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_92',
- 'suite_b': 'disable',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_96',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'acct-verify': 'enable',
- 'add-gw-route': 'enable',
- 'add-route': 'disable',
- 'assign-ip': 'disable',
- 'assign-ip-from': 'range',
- 'authmethod': 'psk',
- 'authmethod-remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto-negotiate': 'enable',
- 'banner': 'test_value_14',
- 'cert-id-validation': 'enable',
- 'childless-ike': 'enable',
- 'client-auto-negotiate': 'disable',
- 'client-keep-alive': 'disable',
- 'comments': 'test_value_19',
- 'dhgrp': '1',
- 'digital-signature-auth': 'enable',
- 'distance': '22',
- 'dns-mode': 'manual',
- 'domain': 'test_value_24',
- 'dpd': 'disable',
- 'dpd-retrycount': '26',
- 'dpd-retryinterval': 'test_value_27',
- 'eap': 'enable',
- 'eap-identity': 'use-id-payload',
- 'enforce-unique-id': 'disable',
- 'forticlient-enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation-mtu': '33',
- 'group-authentication': 'enable',
- 'group-authentication-secret': 'test_value_35',
- 'ha-sync-esp-seqno': 'enable',
- 'idle-timeout': 'enable',
- 'idle-timeoutinterval': '38',
- 'ike-version': '1',
- 'include-local-lan': 'disable',
- 'interface': 'test_value_41',
- 'ipv4-dns-server1': 'test_value_42',
- 'ipv4-dns-server2': 'test_value_43',
- 'ipv4-dns-server3': 'test_value_44',
- 'ipv4-end-ip': 'test_value_45',
- 'ipv4-name': 'test_value_46',
- 'ipv4-netmask': 'test_value_47',
- 'ipv4-split-exclude': 'test_value_48',
- 'ipv4-split-include': 'test_value_49',
- 'ipv4-start-ip': 'test_value_50',
- 'ipv4-wins-server1': 'test_value_51',
- 'ipv4-wins-server2': 'test_value_52',
- 'ipv6-dns-server1': 'test_value_53',
- 'ipv6-dns-server2': 'test_value_54',
- 'ipv6-dns-server3': 'test_value_55',
- 'ipv6-end-ip': 'test_value_56',
- 'ipv6-name': 'test_value_57',
- 'ipv6-prefix': '58',
- 'ipv6-split-exclude': 'test_value_59',
- 'ipv6-split-include': 'test_value_60',
- 'ipv6-start-ip': 'test_value_61',
- 'keepalive': '62',
- 'keylife': '63',
- 'local-gw': 'test_value_64',
- 'localid': 'test_value_65',
- 'localid-type': 'auto',
- 'mesh-selector-type': 'disable',
- 'mode': 'aggressive',
- 'mode-cfg': 'disable',
- 'name': 'default_name_70',
- 'nattraversal': 'enable',
- 'negotiate-timeout': '72',
- 'peer': 'test_value_73',
- 'peergrp': 'test_value_74',
- 'peerid': 'test_value_75',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk-identity': 'test_value_78',
- 'ppk-secret': 'test_value_79',
- 'priority': '80',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_82',
- 'psksecret-remote': 'test_value_83',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote-gw': 'test_value_86',
- 'remotegw-ddns': 'test_value_87',
- 'rsa-signature-format': 'pkcs1',
- 'save-password': 'disable',
- 'send-cert-chain': 'enable',
- 'signature-hash-alg': 'sha1',
- 'split-include-service': 'test_value_92',
- 'suite-b': 'disable',
- 'type': 'static',
- 'unity-support': 'disable',
- 'usrgrp': 'test_value_96',
- 'wizard-type': 'custom',
- 'xauthtype': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase1', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_phase1_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase1': {
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_14',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_19',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '22',
- 'dns_mode': 'manual',
- 'domain': 'test_value_24',
- 'dpd': 'disable',
- 'dpd_retrycount': '26',
- 'dpd_retryinterval': 'test_value_27',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'enforce_unique_id': 'disable',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '33',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_35',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '38',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_41',
- 'ipv4_dns_server1': 'test_value_42',
- 'ipv4_dns_server2': 'test_value_43',
- 'ipv4_dns_server3': 'test_value_44',
- 'ipv4_end_ip': 'test_value_45',
- 'ipv4_name': 'test_value_46',
- 'ipv4_netmask': 'test_value_47',
- 'ipv4_split_exclude': 'test_value_48',
- 'ipv4_split_include': 'test_value_49',
- 'ipv4_start_ip': 'test_value_50',
- 'ipv4_wins_server1': 'test_value_51',
- 'ipv4_wins_server2': 'test_value_52',
- 'ipv6_dns_server1': 'test_value_53',
- 'ipv6_dns_server2': 'test_value_54',
- 'ipv6_dns_server3': 'test_value_55',
- 'ipv6_end_ip': 'test_value_56',
- 'ipv6_name': 'test_value_57',
- 'ipv6_prefix': '58',
- 'ipv6_split_exclude': 'test_value_59',
- 'ipv6_split_include': 'test_value_60',
- 'ipv6_start_ip': 'test_value_61',
- 'keepalive': '62',
- 'keylife': '63',
- 'local_gw': 'test_value_64',
- 'localid': 'test_value_65',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'name': 'default_name_70',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '72',
- 'peer': 'test_value_73',
- 'peergrp': 'test_value_74',
- 'peerid': 'test_value_75',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_78',
- 'ppk_secret': 'test_value_79',
- 'priority': '80',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_82',
- 'psksecret_remote': 'test_value_83',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_86',
- 'remotegw_ddns': 'test_value_87',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_92',
- 'suite_b': 'disable',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_96',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'acct-verify': 'enable',
- 'add-gw-route': 'enable',
- 'add-route': 'disable',
- 'assign-ip': 'disable',
- 'assign-ip-from': 'range',
- 'authmethod': 'psk',
- 'authmethod-remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto-negotiate': 'enable',
- 'banner': 'test_value_14',
- 'cert-id-validation': 'enable',
- 'childless-ike': 'enable',
- 'client-auto-negotiate': 'disable',
- 'client-keep-alive': 'disable',
- 'comments': 'test_value_19',
- 'dhgrp': '1',
- 'digital-signature-auth': 'enable',
- 'distance': '22',
- 'dns-mode': 'manual',
- 'domain': 'test_value_24',
- 'dpd': 'disable',
- 'dpd-retrycount': '26',
- 'dpd-retryinterval': 'test_value_27',
- 'eap': 'enable',
- 'eap-identity': 'use-id-payload',
- 'enforce-unique-id': 'disable',
- 'forticlient-enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation-mtu': '33',
- 'group-authentication': 'enable',
- 'group-authentication-secret': 'test_value_35',
- 'ha-sync-esp-seqno': 'enable',
- 'idle-timeout': 'enable',
- 'idle-timeoutinterval': '38',
- 'ike-version': '1',
- 'include-local-lan': 'disable',
- 'interface': 'test_value_41',
- 'ipv4-dns-server1': 'test_value_42',
- 'ipv4-dns-server2': 'test_value_43',
- 'ipv4-dns-server3': 'test_value_44',
- 'ipv4-end-ip': 'test_value_45',
- 'ipv4-name': 'test_value_46',
- 'ipv4-netmask': 'test_value_47',
- 'ipv4-split-exclude': 'test_value_48',
- 'ipv4-split-include': 'test_value_49',
- 'ipv4-start-ip': 'test_value_50',
- 'ipv4-wins-server1': 'test_value_51',
- 'ipv4-wins-server2': 'test_value_52',
- 'ipv6-dns-server1': 'test_value_53',
- 'ipv6-dns-server2': 'test_value_54',
- 'ipv6-dns-server3': 'test_value_55',
- 'ipv6-end-ip': 'test_value_56',
- 'ipv6-name': 'test_value_57',
- 'ipv6-prefix': '58',
- 'ipv6-split-exclude': 'test_value_59',
- 'ipv6-split-include': 'test_value_60',
- 'ipv6-start-ip': 'test_value_61',
- 'keepalive': '62',
- 'keylife': '63',
- 'local-gw': 'test_value_64',
- 'localid': 'test_value_65',
- 'localid-type': 'auto',
- 'mesh-selector-type': 'disable',
- 'mode': 'aggressive',
- 'mode-cfg': 'disable',
- 'name': 'default_name_70',
- 'nattraversal': 'enable',
- 'negotiate-timeout': '72',
- 'peer': 'test_value_73',
- 'peergrp': 'test_value_74',
- 'peerid': 'test_value_75',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk-identity': 'test_value_78',
- 'ppk-secret': 'test_value_79',
- 'priority': '80',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_82',
- 'psksecret-remote': 'test_value_83',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote-gw': 'test_value_86',
- 'remotegw-ddns': 'test_value_87',
- 'rsa-signature-format': 'pkcs1',
- 'save-password': 'disable',
- 'send-cert-chain': 'enable',
- 'signature-hash-alg': 'sha1',
- 'split-include-service': 'test_value_92',
- 'suite-b': 'disable',
- 'type': 'static',
- 'unity-support': 'disable',
- 'usrgrp': 'test_value_96',
- 'wizard-type': 'custom',
- 'xauthtype': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase1', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_phase1_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_phase1': {
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_14',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_19',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '22',
- 'dns_mode': 'manual',
- 'domain': 'test_value_24',
- 'dpd': 'disable',
- 'dpd_retrycount': '26',
- 'dpd_retryinterval': 'test_value_27',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'enforce_unique_id': 'disable',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '33',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_35',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '38',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_41',
- 'ipv4_dns_server1': 'test_value_42',
- 'ipv4_dns_server2': 'test_value_43',
- 'ipv4_dns_server3': 'test_value_44',
- 'ipv4_end_ip': 'test_value_45',
- 'ipv4_name': 'test_value_46',
- 'ipv4_netmask': 'test_value_47',
- 'ipv4_split_exclude': 'test_value_48',
- 'ipv4_split_include': 'test_value_49',
- 'ipv4_start_ip': 'test_value_50',
- 'ipv4_wins_server1': 'test_value_51',
- 'ipv4_wins_server2': 'test_value_52',
- 'ipv6_dns_server1': 'test_value_53',
- 'ipv6_dns_server2': 'test_value_54',
- 'ipv6_dns_server3': 'test_value_55',
- 'ipv6_end_ip': 'test_value_56',
- 'ipv6_name': 'test_value_57',
- 'ipv6_prefix': '58',
- 'ipv6_split_exclude': 'test_value_59',
- 'ipv6_split_include': 'test_value_60',
- 'ipv6_start_ip': 'test_value_61',
- 'keepalive': '62',
- 'keylife': '63',
- 'local_gw': 'test_value_64',
- 'localid': 'test_value_65',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'name': 'default_name_70',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '72',
- 'peer': 'test_value_73',
- 'peergrp': 'test_value_74',
- 'peerid': 'test_value_75',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_78',
- 'ppk_secret': 'test_value_79',
- 'priority': '80',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_82',
- 'psksecret_remote': 'test_value_83',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_86',
- 'remotegw_ddns': 'test_value_87',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_92',
- 'suite_b': 'disable',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_96',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'phase1', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_phase1_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_phase1': {
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_14',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_19',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '22',
- 'dns_mode': 'manual',
- 'domain': 'test_value_24',
- 'dpd': 'disable',
- 'dpd_retrycount': '26',
- 'dpd_retryinterval': 'test_value_27',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'enforce_unique_id': 'disable',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '33',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_35',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '38',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_41',
- 'ipv4_dns_server1': 'test_value_42',
- 'ipv4_dns_server2': 'test_value_43',
- 'ipv4_dns_server3': 'test_value_44',
- 'ipv4_end_ip': 'test_value_45',
- 'ipv4_name': 'test_value_46',
- 'ipv4_netmask': 'test_value_47',
- 'ipv4_split_exclude': 'test_value_48',
- 'ipv4_split_include': 'test_value_49',
- 'ipv4_start_ip': 'test_value_50',
- 'ipv4_wins_server1': 'test_value_51',
- 'ipv4_wins_server2': 'test_value_52',
- 'ipv6_dns_server1': 'test_value_53',
- 'ipv6_dns_server2': 'test_value_54',
- 'ipv6_dns_server3': 'test_value_55',
- 'ipv6_end_ip': 'test_value_56',
- 'ipv6_name': 'test_value_57',
- 'ipv6_prefix': '58',
- 'ipv6_split_exclude': 'test_value_59',
- 'ipv6_split_include': 'test_value_60',
- 'ipv6_start_ip': 'test_value_61',
- 'keepalive': '62',
- 'keylife': '63',
- 'local_gw': 'test_value_64',
- 'localid': 'test_value_65',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'name': 'default_name_70',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '72',
- 'peer': 'test_value_73',
- 'peergrp': 'test_value_74',
- 'peerid': 'test_value_75',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_78',
- 'ppk_secret': 'test_value_79',
- 'priority': '80',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_82',
- 'psksecret_remote': 'test_value_83',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_86',
- 'remotegw_ddns': 'test_value_87',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_92',
- 'suite_b': 'disable',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_96',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'phase1', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_phase1_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase1': {
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_14',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_19',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '22',
- 'dns_mode': 'manual',
- 'domain': 'test_value_24',
- 'dpd': 'disable',
- 'dpd_retrycount': '26',
- 'dpd_retryinterval': 'test_value_27',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'enforce_unique_id': 'disable',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '33',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_35',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '38',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_41',
- 'ipv4_dns_server1': 'test_value_42',
- 'ipv4_dns_server2': 'test_value_43',
- 'ipv4_dns_server3': 'test_value_44',
- 'ipv4_end_ip': 'test_value_45',
- 'ipv4_name': 'test_value_46',
- 'ipv4_netmask': 'test_value_47',
- 'ipv4_split_exclude': 'test_value_48',
- 'ipv4_split_include': 'test_value_49',
- 'ipv4_start_ip': 'test_value_50',
- 'ipv4_wins_server1': 'test_value_51',
- 'ipv4_wins_server2': 'test_value_52',
- 'ipv6_dns_server1': 'test_value_53',
- 'ipv6_dns_server2': 'test_value_54',
- 'ipv6_dns_server3': 'test_value_55',
- 'ipv6_end_ip': 'test_value_56',
- 'ipv6_name': 'test_value_57',
- 'ipv6_prefix': '58',
- 'ipv6_split_exclude': 'test_value_59',
- 'ipv6_split_include': 'test_value_60',
- 'ipv6_start_ip': 'test_value_61',
- 'keepalive': '62',
- 'keylife': '63',
- 'local_gw': 'test_value_64',
- 'localid': 'test_value_65',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'name': 'default_name_70',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '72',
- 'peer': 'test_value_73',
- 'peergrp': 'test_value_74',
- 'peerid': 'test_value_75',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_78',
- 'ppk_secret': 'test_value_79',
- 'priority': '80',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_82',
- 'psksecret_remote': 'test_value_83',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_86',
- 'remotegw_ddns': 'test_value_87',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_92',
- 'suite_b': 'disable',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_96',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'acct-verify': 'enable',
- 'add-gw-route': 'enable',
- 'add-route': 'disable',
- 'assign-ip': 'disable',
- 'assign-ip-from': 'range',
- 'authmethod': 'psk',
- 'authmethod-remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto-negotiate': 'enable',
- 'banner': 'test_value_14',
- 'cert-id-validation': 'enable',
- 'childless-ike': 'enable',
- 'client-auto-negotiate': 'disable',
- 'client-keep-alive': 'disable',
- 'comments': 'test_value_19',
- 'dhgrp': '1',
- 'digital-signature-auth': 'enable',
- 'distance': '22',
- 'dns-mode': 'manual',
- 'domain': 'test_value_24',
- 'dpd': 'disable',
- 'dpd-retrycount': '26',
- 'dpd-retryinterval': 'test_value_27',
- 'eap': 'enable',
- 'eap-identity': 'use-id-payload',
- 'enforce-unique-id': 'disable',
- 'forticlient-enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation-mtu': '33',
- 'group-authentication': 'enable',
- 'group-authentication-secret': 'test_value_35',
- 'ha-sync-esp-seqno': 'enable',
- 'idle-timeout': 'enable',
- 'idle-timeoutinterval': '38',
- 'ike-version': '1',
- 'include-local-lan': 'disable',
- 'interface': 'test_value_41',
- 'ipv4-dns-server1': 'test_value_42',
- 'ipv4-dns-server2': 'test_value_43',
- 'ipv4-dns-server3': 'test_value_44',
- 'ipv4-end-ip': 'test_value_45',
- 'ipv4-name': 'test_value_46',
- 'ipv4-netmask': 'test_value_47',
- 'ipv4-split-exclude': 'test_value_48',
- 'ipv4-split-include': 'test_value_49',
- 'ipv4-start-ip': 'test_value_50',
- 'ipv4-wins-server1': 'test_value_51',
- 'ipv4-wins-server2': 'test_value_52',
- 'ipv6-dns-server1': 'test_value_53',
- 'ipv6-dns-server2': 'test_value_54',
- 'ipv6-dns-server3': 'test_value_55',
- 'ipv6-end-ip': 'test_value_56',
- 'ipv6-name': 'test_value_57',
- 'ipv6-prefix': '58',
- 'ipv6-split-exclude': 'test_value_59',
- 'ipv6-split-include': 'test_value_60',
- 'ipv6-start-ip': 'test_value_61',
- 'keepalive': '62',
- 'keylife': '63',
- 'local-gw': 'test_value_64',
- 'localid': 'test_value_65',
- 'localid-type': 'auto',
- 'mesh-selector-type': 'disable',
- 'mode': 'aggressive',
- 'mode-cfg': 'disable',
- 'name': 'default_name_70',
- 'nattraversal': 'enable',
- 'negotiate-timeout': '72',
- 'peer': 'test_value_73',
- 'peergrp': 'test_value_74',
- 'peerid': 'test_value_75',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk-identity': 'test_value_78',
- 'ppk-secret': 'test_value_79',
- 'priority': '80',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_82',
- 'psksecret-remote': 'test_value_83',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote-gw': 'test_value_86',
- 'remotegw-ddns': 'test_value_87',
- 'rsa-signature-format': 'pkcs1',
- 'save-password': 'disable',
- 'send-cert-chain': 'enable',
- 'signature-hash-alg': 'sha1',
- 'split-include-service': 'test_value_92',
- 'suite-b': 'disable',
- 'type': 'static',
- 'unity-support': 'disable',
- 'usrgrp': 'test_value_96',
- 'wizard-type': 'custom',
- 'xauthtype': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase1', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ipsec_phase1_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase1': {
- 'random_attribute_not_valid': 'tag',
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_14',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_19',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '22',
- 'dns_mode': 'manual',
- 'domain': 'test_value_24',
- 'dpd': 'disable',
- 'dpd_retrycount': '26',
- 'dpd_retryinterval': 'test_value_27',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'enforce_unique_id': 'disable',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '33',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_35',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '38',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_41',
- 'ipv4_dns_server1': 'test_value_42',
- 'ipv4_dns_server2': 'test_value_43',
- 'ipv4_dns_server3': 'test_value_44',
- 'ipv4_end_ip': 'test_value_45',
- 'ipv4_name': 'test_value_46',
- 'ipv4_netmask': 'test_value_47',
- 'ipv4_split_exclude': 'test_value_48',
- 'ipv4_split_include': 'test_value_49',
- 'ipv4_start_ip': 'test_value_50',
- 'ipv4_wins_server1': 'test_value_51',
- 'ipv4_wins_server2': 'test_value_52',
- 'ipv6_dns_server1': 'test_value_53',
- 'ipv6_dns_server2': 'test_value_54',
- 'ipv6_dns_server3': 'test_value_55',
- 'ipv6_end_ip': 'test_value_56',
- 'ipv6_name': 'test_value_57',
- 'ipv6_prefix': '58',
- 'ipv6_split_exclude': 'test_value_59',
- 'ipv6_split_include': 'test_value_60',
- 'ipv6_start_ip': 'test_value_61',
- 'keepalive': '62',
- 'keylife': '63',
- 'local_gw': 'test_value_64',
- 'localid': 'test_value_65',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'name': 'default_name_70',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '72',
- 'peer': 'test_value_73',
- 'peergrp': 'test_value_74',
- 'peerid': 'test_value_75',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_78',
- 'ppk_secret': 'test_value_79',
- 'priority': '80',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_82',
- 'psksecret_remote': 'test_value_83',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_86',
- 'remotegw_ddns': 'test_value_87',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_92',
- 'suite_b': 'disable',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_96',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'acct-verify': 'enable',
- 'add-gw-route': 'enable',
- 'add-route': 'disable',
- 'assign-ip': 'disable',
- 'assign-ip-from': 'range',
- 'authmethod': 'psk',
- 'authmethod-remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto-negotiate': 'enable',
- 'banner': 'test_value_14',
- 'cert-id-validation': 'enable',
- 'childless-ike': 'enable',
- 'client-auto-negotiate': 'disable',
- 'client-keep-alive': 'disable',
- 'comments': 'test_value_19',
- 'dhgrp': '1',
- 'digital-signature-auth': 'enable',
- 'distance': '22',
- 'dns-mode': 'manual',
- 'domain': 'test_value_24',
- 'dpd': 'disable',
- 'dpd-retrycount': '26',
- 'dpd-retryinterval': 'test_value_27',
- 'eap': 'enable',
- 'eap-identity': 'use-id-payload',
- 'enforce-unique-id': 'disable',
- 'forticlient-enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation-mtu': '33',
- 'group-authentication': 'enable',
- 'group-authentication-secret': 'test_value_35',
- 'ha-sync-esp-seqno': 'enable',
- 'idle-timeout': 'enable',
- 'idle-timeoutinterval': '38',
- 'ike-version': '1',
- 'include-local-lan': 'disable',
- 'interface': 'test_value_41',
- 'ipv4-dns-server1': 'test_value_42',
- 'ipv4-dns-server2': 'test_value_43',
- 'ipv4-dns-server3': 'test_value_44',
- 'ipv4-end-ip': 'test_value_45',
- 'ipv4-name': 'test_value_46',
- 'ipv4-netmask': 'test_value_47',
- 'ipv4-split-exclude': 'test_value_48',
- 'ipv4-split-include': 'test_value_49',
- 'ipv4-start-ip': 'test_value_50',
- 'ipv4-wins-server1': 'test_value_51',
- 'ipv4-wins-server2': 'test_value_52',
- 'ipv6-dns-server1': 'test_value_53',
- 'ipv6-dns-server2': 'test_value_54',
- 'ipv6-dns-server3': 'test_value_55',
- 'ipv6-end-ip': 'test_value_56',
- 'ipv6-name': 'test_value_57',
- 'ipv6-prefix': '58',
- 'ipv6-split-exclude': 'test_value_59',
- 'ipv6-split-include': 'test_value_60',
- 'ipv6-start-ip': 'test_value_61',
- 'keepalive': '62',
- 'keylife': '63',
- 'local-gw': 'test_value_64',
- 'localid': 'test_value_65',
- 'localid-type': 'auto',
- 'mesh-selector-type': 'disable',
- 'mode': 'aggressive',
- 'mode-cfg': 'disable',
- 'name': 'default_name_70',
- 'nattraversal': 'enable',
- 'negotiate-timeout': '72',
- 'peer': 'test_value_73',
- 'peergrp': 'test_value_74',
- 'peerid': 'test_value_75',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk-identity': 'test_value_78',
- 'ppk-secret': 'test_value_79',
- 'priority': '80',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_82',
- 'psksecret-remote': 'test_value_83',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote-gw': 'test_value_86',
- 'remotegw-ddns': 'test_value_87',
- 'rsa-signature-format': 'pkcs1',
- 'save-password': 'disable',
- 'send-cert-chain': 'enable',
- 'signature-hash-alg': 'sha1',
- 'split-include-service': 'test_value_92',
- 'suite-b': 'disable',
- 'type': 'static',
- 'unity-support': 'disable',
- 'usrgrp': 'test_value_96',
- 'wizard-type': 'custom',
- 'xauthtype': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase1', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase1_interface.py b/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase1_interface.py
deleted file mode 100644
index 6a422b834c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase1_interface.py
+++ /dev/null
@@ -1,1419 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ipsec_phase1_interface
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ipsec_phase1_interface.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ipsec_phase1_interface_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase1_interface': {
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_discovery_forwarder': 'enable',
- 'auto_discovery_psk': 'enable',
- 'auto_discovery_receiver': 'enable',
- 'auto_discovery_sender': 'enable',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_18',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_23',
- 'default_gw': 'test_value_24',
- 'default_gw_priority': '25',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '28',
- 'dns_mode': 'manual',
- 'domain': 'test_value_30',
- 'dpd': 'disable',
- 'dpd_retrycount': '32',
- 'dpd_retryinterval': 'test_value_33',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'encap_local_gw4': 'test_value_36',
- 'encap_local_gw6': 'test_value_37',
- 'encap_remote_gw4': 'test_value_38',
- 'encap_remote_gw6': 'test_value_39',
- 'encapsulation': 'none',
- 'encapsulation_address': 'ike',
- 'enforce_unique_id': 'disable',
- 'exchange_interface_ip': 'enable',
- 'exchange_ip_addr4': 'test_value_44',
- 'exchange_ip_addr6': 'test_value_45',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '48',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_50',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '53',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_56',
- 'ip_version': '4',
- 'ipv4_dns_server1': 'test_value_58',
- 'ipv4_dns_server2': 'test_value_59',
- 'ipv4_dns_server3': 'test_value_60',
- 'ipv4_end_ip': 'test_value_61',
- 'ipv4_name': 'test_value_62',
- 'ipv4_netmask': 'test_value_63',
- 'ipv4_split_exclude': 'test_value_64',
- 'ipv4_split_include': 'test_value_65',
- 'ipv4_start_ip': 'test_value_66',
- 'ipv4_wins_server1': 'test_value_67',
- 'ipv4_wins_server2': 'test_value_68',
- 'ipv6_dns_server1': 'test_value_69',
- 'ipv6_dns_server2': 'test_value_70',
- 'ipv6_dns_server3': 'test_value_71',
- 'ipv6_end_ip': 'test_value_72',
- 'ipv6_name': 'test_value_73',
- 'ipv6_prefix': '74',
- 'ipv6_split_exclude': 'test_value_75',
- 'ipv6_split_include': 'test_value_76',
- 'ipv6_start_ip': 'test_value_77',
- 'keepalive': '78',
- 'keylife': '79',
- 'local_gw': 'test_value_80',
- 'local_gw6': 'test_value_81',
- 'localid': 'test_value_82',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'monitor': 'test_value_87',
- 'monitor_hold_down_delay': '88',
- 'monitor_hold_down_time': 'test_value_89',
- 'monitor_hold_down_type': 'immediate',
- 'monitor_hold_down_weekday': 'everyday',
- 'name': 'default_name_92',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '94',
- 'net_device': 'enable',
- 'passive_mode': 'enable',
- 'peer': 'test_value_97',
- 'peergrp': 'test_value_98',
- 'peerid': 'test_value_99',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_102',
- 'ppk_secret': 'test_value_103',
- 'priority': '104',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_106',
- 'psksecret_remote': 'test_value_107',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_110',
- 'remote_gw6': 'test_value_111',
- 'remotegw_ddns': 'test_value_112',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_117',
- 'suite_b': 'disable',
- 'tunnel_search': 'selectors',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_122',
- 'vni': '123',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'acct-verify': 'enable',
- 'add-gw-route': 'enable',
- 'add-route': 'disable',
- 'assign-ip': 'disable',
- 'assign-ip-from': 'range',
- 'authmethod': 'psk',
- 'authmethod-remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto-discovery-forwarder': 'enable',
- 'auto-discovery-psk': 'enable',
- 'auto-discovery-receiver': 'enable',
- 'auto-discovery-sender': 'enable',
- 'auto-negotiate': 'enable',
- 'banner': 'test_value_18',
- 'cert-id-validation': 'enable',
- 'childless-ike': 'enable',
- 'client-auto-negotiate': 'disable',
- 'client-keep-alive': 'disable',
- 'comments': 'test_value_23',
- 'default-gw': 'test_value_24',
- 'default-gw-priority': '25',
- 'dhgrp': '1',
- 'digital-signature-auth': 'enable',
- 'distance': '28',
- 'dns-mode': 'manual',
- 'domain': 'test_value_30',
- 'dpd': 'disable',
- 'dpd-retrycount': '32',
- 'dpd-retryinterval': 'test_value_33',
- 'eap': 'enable',
- 'eap-identity': 'use-id-payload',
- 'encap-local-gw4': 'test_value_36',
- 'encap-local-gw6': 'test_value_37',
- 'encap-remote-gw4': 'test_value_38',
- 'encap-remote-gw6': 'test_value_39',
- 'encapsulation': 'none',
- 'encapsulation-address': 'ike',
- 'enforce-unique-id': 'disable',
- 'exchange-interface-ip': 'enable',
- 'exchange-ip-addr4': 'test_value_44',
- 'exchange-ip-addr6': 'test_value_45',
- 'forticlient-enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation-mtu': '48',
- 'group-authentication': 'enable',
- 'group-authentication-secret': 'test_value_50',
- 'ha-sync-esp-seqno': 'enable',
- 'idle-timeout': 'enable',
- 'idle-timeoutinterval': '53',
- 'ike-version': '1',
- 'include-local-lan': 'disable',
- 'interface': 'test_value_56',
- 'ip-version': '4',
- 'ipv4-dns-server1': 'test_value_58',
- 'ipv4-dns-server2': 'test_value_59',
- 'ipv4-dns-server3': 'test_value_60',
- 'ipv4-end-ip': 'test_value_61',
- 'ipv4-name': 'test_value_62',
- 'ipv4-netmask': 'test_value_63',
- 'ipv4-split-exclude': 'test_value_64',
- 'ipv4-split-include': 'test_value_65',
- 'ipv4-start-ip': 'test_value_66',
- 'ipv4-wins-server1': 'test_value_67',
- 'ipv4-wins-server2': 'test_value_68',
- 'ipv6-dns-server1': 'test_value_69',
- 'ipv6-dns-server2': 'test_value_70',
- 'ipv6-dns-server3': 'test_value_71',
- 'ipv6-end-ip': 'test_value_72',
- 'ipv6-name': 'test_value_73',
- 'ipv6-prefix': '74',
- 'ipv6-split-exclude': 'test_value_75',
- 'ipv6-split-include': 'test_value_76',
- 'ipv6-start-ip': 'test_value_77',
- 'keepalive': '78',
- 'keylife': '79',
- 'local-gw': 'test_value_80',
- 'local-gw6': 'test_value_81',
- 'localid': 'test_value_82',
- 'localid-type': 'auto',
- 'mesh-selector-type': 'disable',
- 'mode': 'aggressive',
- 'mode-cfg': 'disable',
- 'monitor': 'test_value_87',
- 'monitor-hold-down-delay': '88',
- 'monitor-hold-down-time': 'test_value_89',
- 'monitor-hold-down-type': 'immediate',
- 'monitor-hold-down-weekday': 'everyday',
- 'name': 'default_name_92',
- 'nattraversal': 'enable',
- 'negotiate-timeout': '94',
- 'net-device': 'enable',
- 'passive-mode': 'enable',
- 'peer': 'test_value_97',
- 'peergrp': 'test_value_98',
- 'peerid': 'test_value_99',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk-identity': 'test_value_102',
- 'ppk-secret': 'test_value_103',
- 'priority': '104',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_106',
- 'psksecret-remote': 'test_value_107',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote-gw': 'test_value_110',
- 'remote-gw6': 'test_value_111',
- 'remotegw-ddns': 'test_value_112',
- 'rsa-signature-format': 'pkcs1',
- 'save-password': 'disable',
- 'send-cert-chain': 'enable',
- 'signature-hash-alg': 'sha1',
- 'split-include-service': 'test_value_117',
- 'suite-b': 'disable',
- 'tunnel-search': 'selectors',
- 'type': 'static',
- 'unity-support': 'disable',
- 'usrgrp': 'test_value_122',
- 'vni': '123',
- 'wizard-type': 'custom',
- 'xauthtype': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase1-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_phase1_interface_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase1_interface': {
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_discovery_forwarder': 'enable',
- 'auto_discovery_psk': 'enable',
- 'auto_discovery_receiver': 'enable',
- 'auto_discovery_sender': 'enable',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_18',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_23',
- 'default_gw': 'test_value_24',
- 'default_gw_priority': '25',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '28',
- 'dns_mode': 'manual',
- 'domain': 'test_value_30',
- 'dpd': 'disable',
- 'dpd_retrycount': '32',
- 'dpd_retryinterval': 'test_value_33',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'encap_local_gw4': 'test_value_36',
- 'encap_local_gw6': 'test_value_37',
- 'encap_remote_gw4': 'test_value_38',
- 'encap_remote_gw6': 'test_value_39',
- 'encapsulation': 'none',
- 'encapsulation_address': 'ike',
- 'enforce_unique_id': 'disable',
- 'exchange_interface_ip': 'enable',
- 'exchange_ip_addr4': 'test_value_44',
- 'exchange_ip_addr6': 'test_value_45',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '48',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_50',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '53',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_56',
- 'ip_version': '4',
- 'ipv4_dns_server1': 'test_value_58',
- 'ipv4_dns_server2': 'test_value_59',
- 'ipv4_dns_server3': 'test_value_60',
- 'ipv4_end_ip': 'test_value_61',
- 'ipv4_name': 'test_value_62',
- 'ipv4_netmask': 'test_value_63',
- 'ipv4_split_exclude': 'test_value_64',
- 'ipv4_split_include': 'test_value_65',
- 'ipv4_start_ip': 'test_value_66',
- 'ipv4_wins_server1': 'test_value_67',
- 'ipv4_wins_server2': 'test_value_68',
- 'ipv6_dns_server1': 'test_value_69',
- 'ipv6_dns_server2': 'test_value_70',
- 'ipv6_dns_server3': 'test_value_71',
- 'ipv6_end_ip': 'test_value_72',
- 'ipv6_name': 'test_value_73',
- 'ipv6_prefix': '74',
- 'ipv6_split_exclude': 'test_value_75',
- 'ipv6_split_include': 'test_value_76',
- 'ipv6_start_ip': 'test_value_77',
- 'keepalive': '78',
- 'keylife': '79',
- 'local_gw': 'test_value_80',
- 'local_gw6': 'test_value_81',
- 'localid': 'test_value_82',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'monitor': 'test_value_87',
- 'monitor_hold_down_delay': '88',
- 'monitor_hold_down_time': 'test_value_89',
- 'monitor_hold_down_type': 'immediate',
- 'monitor_hold_down_weekday': 'everyday',
- 'name': 'default_name_92',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '94',
- 'net_device': 'enable',
- 'passive_mode': 'enable',
- 'peer': 'test_value_97',
- 'peergrp': 'test_value_98',
- 'peerid': 'test_value_99',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_102',
- 'ppk_secret': 'test_value_103',
- 'priority': '104',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_106',
- 'psksecret_remote': 'test_value_107',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_110',
- 'remote_gw6': 'test_value_111',
- 'remotegw_ddns': 'test_value_112',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_117',
- 'suite_b': 'disable',
- 'tunnel_search': 'selectors',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_122',
- 'vni': '123',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'acct-verify': 'enable',
- 'add-gw-route': 'enable',
- 'add-route': 'disable',
- 'assign-ip': 'disable',
- 'assign-ip-from': 'range',
- 'authmethod': 'psk',
- 'authmethod-remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto-discovery-forwarder': 'enable',
- 'auto-discovery-psk': 'enable',
- 'auto-discovery-receiver': 'enable',
- 'auto-discovery-sender': 'enable',
- 'auto-negotiate': 'enable',
- 'banner': 'test_value_18',
- 'cert-id-validation': 'enable',
- 'childless-ike': 'enable',
- 'client-auto-negotiate': 'disable',
- 'client-keep-alive': 'disable',
- 'comments': 'test_value_23',
- 'default-gw': 'test_value_24',
- 'default-gw-priority': '25',
- 'dhgrp': '1',
- 'digital-signature-auth': 'enable',
- 'distance': '28',
- 'dns-mode': 'manual',
- 'domain': 'test_value_30',
- 'dpd': 'disable',
- 'dpd-retrycount': '32',
- 'dpd-retryinterval': 'test_value_33',
- 'eap': 'enable',
- 'eap-identity': 'use-id-payload',
- 'encap-local-gw4': 'test_value_36',
- 'encap-local-gw6': 'test_value_37',
- 'encap-remote-gw4': 'test_value_38',
- 'encap-remote-gw6': 'test_value_39',
- 'encapsulation': 'none',
- 'encapsulation-address': 'ike',
- 'enforce-unique-id': 'disable',
- 'exchange-interface-ip': 'enable',
- 'exchange-ip-addr4': 'test_value_44',
- 'exchange-ip-addr6': 'test_value_45',
- 'forticlient-enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation-mtu': '48',
- 'group-authentication': 'enable',
- 'group-authentication-secret': 'test_value_50',
- 'ha-sync-esp-seqno': 'enable',
- 'idle-timeout': 'enable',
- 'idle-timeoutinterval': '53',
- 'ike-version': '1',
- 'include-local-lan': 'disable',
- 'interface': 'test_value_56',
- 'ip-version': '4',
- 'ipv4-dns-server1': 'test_value_58',
- 'ipv4-dns-server2': 'test_value_59',
- 'ipv4-dns-server3': 'test_value_60',
- 'ipv4-end-ip': 'test_value_61',
- 'ipv4-name': 'test_value_62',
- 'ipv4-netmask': 'test_value_63',
- 'ipv4-split-exclude': 'test_value_64',
- 'ipv4-split-include': 'test_value_65',
- 'ipv4-start-ip': 'test_value_66',
- 'ipv4-wins-server1': 'test_value_67',
- 'ipv4-wins-server2': 'test_value_68',
- 'ipv6-dns-server1': 'test_value_69',
- 'ipv6-dns-server2': 'test_value_70',
- 'ipv6-dns-server3': 'test_value_71',
- 'ipv6-end-ip': 'test_value_72',
- 'ipv6-name': 'test_value_73',
- 'ipv6-prefix': '74',
- 'ipv6-split-exclude': 'test_value_75',
- 'ipv6-split-include': 'test_value_76',
- 'ipv6-start-ip': 'test_value_77',
- 'keepalive': '78',
- 'keylife': '79',
- 'local-gw': 'test_value_80',
- 'local-gw6': 'test_value_81',
- 'localid': 'test_value_82',
- 'localid-type': 'auto',
- 'mesh-selector-type': 'disable',
- 'mode': 'aggressive',
- 'mode-cfg': 'disable',
- 'monitor': 'test_value_87',
- 'monitor-hold-down-delay': '88',
- 'monitor-hold-down-time': 'test_value_89',
- 'monitor-hold-down-type': 'immediate',
- 'monitor-hold-down-weekday': 'everyday',
- 'name': 'default_name_92',
- 'nattraversal': 'enable',
- 'negotiate-timeout': '94',
- 'net-device': 'enable',
- 'passive-mode': 'enable',
- 'peer': 'test_value_97',
- 'peergrp': 'test_value_98',
- 'peerid': 'test_value_99',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk-identity': 'test_value_102',
- 'ppk-secret': 'test_value_103',
- 'priority': '104',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_106',
- 'psksecret-remote': 'test_value_107',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote-gw': 'test_value_110',
- 'remote-gw6': 'test_value_111',
- 'remotegw-ddns': 'test_value_112',
- 'rsa-signature-format': 'pkcs1',
- 'save-password': 'disable',
- 'send-cert-chain': 'enable',
- 'signature-hash-alg': 'sha1',
- 'split-include-service': 'test_value_117',
- 'suite-b': 'disable',
- 'tunnel-search': 'selectors',
- 'type': 'static',
- 'unity-support': 'disable',
- 'usrgrp': 'test_value_122',
- 'vni': '123',
- 'wizard-type': 'custom',
- 'xauthtype': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase1-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_phase1_interface_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_phase1_interface': {
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_discovery_forwarder': 'enable',
- 'auto_discovery_psk': 'enable',
- 'auto_discovery_receiver': 'enable',
- 'auto_discovery_sender': 'enable',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_18',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_23',
- 'default_gw': 'test_value_24',
- 'default_gw_priority': '25',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '28',
- 'dns_mode': 'manual',
- 'domain': 'test_value_30',
- 'dpd': 'disable',
- 'dpd_retrycount': '32',
- 'dpd_retryinterval': 'test_value_33',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'encap_local_gw4': 'test_value_36',
- 'encap_local_gw6': 'test_value_37',
- 'encap_remote_gw4': 'test_value_38',
- 'encap_remote_gw6': 'test_value_39',
- 'encapsulation': 'none',
- 'encapsulation_address': 'ike',
- 'enforce_unique_id': 'disable',
- 'exchange_interface_ip': 'enable',
- 'exchange_ip_addr4': 'test_value_44',
- 'exchange_ip_addr6': 'test_value_45',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '48',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_50',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '53',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_56',
- 'ip_version': '4',
- 'ipv4_dns_server1': 'test_value_58',
- 'ipv4_dns_server2': 'test_value_59',
- 'ipv4_dns_server3': 'test_value_60',
- 'ipv4_end_ip': 'test_value_61',
- 'ipv4_name': 'test_value_62',
- 'ipv4_netmask': 'test_value_63',
- 'ipv4_split_exclude': 'test_value_64',
- 'ipv4_split_include': 'test_value_65',
- 'ipv4_start_ip': 'test_value_66',
- 'ipv4_wins_server1': 'test_value_67',
- 'ipv4_wins_server2': 'test_value_68',
- 'ipv6_dns_server1': 'test_value_69',
- 'ipv6_dns_server2': 'test_value_70',
- 'ipv6_dns_server3': 'test_value_71',
- 'ipv6_end_ip': 'test_value_72',
- 'ipv6_name': 'test_value_73',
- 'ipv6_prefix': '74',
- 'ipv6_split_exclude': 'test_value_75',
- 'ipv6_split_include': 'test_value_76',
- 'ipv6_start_ip': 'test_value_77',
- 'keepalive': '78',
- 'keylife': '79',
- 'local_gw': 'test_value_80',
- 'local_gw6': 'test_value_81',
- 'localid': 'test_value_82',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'monitor': 'test_value_87',
- 'monitor_hold_down_delay': '88',
- 'monitor_hold_down_time': 'test_value_89',
- 'monitor_hold_down_type': 'immediate',
- 'monitor_hold_down_weekday': 'everyday',
- 'name': 'default_name_92',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '94',
- 'net_device': 'enable',
- 'passive_mode': 'enable',
- 'peer': 'test_value_97',
- 'peergrp': 'test_value_98',
- 'peerid': 'test_value_99',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_102',
- 'ppk_secret': 'test_value_103',
- 'priority': '104',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_106',
- 'psksecret_remote': 'test_value_107',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_110',
- 'remote_gw6': 'test_value_111',
- 'remotegw_ddns': 'test_value_112',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_117',
- 'suite_b': 'disable',
- 'tunnel_search': 'selectors',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_122',
- 'vni': '123',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'phase1-interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_phase1_interface_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_phase1_interface': {
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_discovery_forwarder': 'enable',
- 'auto_discovery_psk': 'enable',
- 'auto_discovery_receiver': 'enable',
- 'auto_discovery_sender': 'enable',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_18',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_23',
- 'default_gw': 'test_value_24',
- 'default_gw_priority': '25',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '28',
- 'dns_mode': 'manual',
- 'domain': 'test_value_30',
- 'dpd': 'disable',
- 'dpd_retrycount': '32',
- 'dpd_retryinterval': 'test_value_33',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'encap_local_gw4': 'test_value_36',
- 'encap_local_gw6': 'test_value_37',
- 'encap_remote_gw4': 'test_value_38',
- 'encap_remote_gw6': 'test_value_39',
- 'encapsulation': 'none',
- 'encapsulation_address': 'ike',
- 'enforce_unique_id': 'disable',
- 'exchange_interface_ip': 'enable',
- 'exchange_ip_addr4': 'test_value_44',
- 'exchange_ip_addr6': 'test_value_45',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '48',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_50',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '53',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_56',
- 'ip_version': '4',
- 'ipv4_dns_server1': 'test_value_58',
- 'ipv4_dns_server2': 'test_value_59',
- 'ipv4_dns_server3': 'test_value_60',
- 'ipv4_end_ip': 'test_value_61',
- 'ipv4_name': 'test_value_62',
- 'ipv4_netmask': 'test_value_63',
- 'ipv4_split_exclude': 'test_value_64',
- 'ipv4_split_include': 'test_value_65',
- 'ipv4_start_ip': 'test_value_66',
- 'ipv4_wins_server1': 'test_value_67',
- 'ipv4_wins_server2': 'test_value_68',
- 'ipv6_dns_server1': 'test_value_69',
- 'ipv6_dns_server2': 'test_value_70',
- 'ipv6_dns_server3': 'test_value_71',
- 'ipv6_end_ip': 'test_value_72',
- 'ipv6_name': 'test_value_73',
- 'ipv6_prefix': '74',
- 'ipv6_split_exclude': 'test_value_75',
- 'ipv6_split_include': 'test_value_76',
- 'ipv6_start_ip': 'test_value_77',
- 'keepalive': '78',
- 'keylife': '79',
- 'local_gw': 'test_value_80',
- 'local_gw6': 'test_value_81',
- 'localid': 'test_value_82',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'monitor': 'test_value_87',
- 'monitor_hold_down_delay': '88',
- 'monitor_hold_down_time': 'test_value_89',
- 'monitor_hold_down_type': 'immediate',
- 'monitor_hold_down_weekday': 'everyday',
- 'name': 'default_name_92',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '94',
- 'net_device': 'enable',
- 'passive_mode': 'enable',
- 'peer': 'test_value_97',
- 'peergrp': 'test_value_98',
- 'peerid': 'test_value_99',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_102',
- 'ppk_secret': 'test_value_103',
- 'priority': '104',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_106',
- 'psksecret_remote': 'test_value_107',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_110',
- 'remote_gw6': 'test_value_111',
- 'remotegw_ddns': 'test_value_112',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_117',
- 'suite_b': 'disable',
- 'tunnel_search': 'selectors',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_122',
- 'vni': '123',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'phase1-interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_phase1_interface_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase1_interface': {
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_discovery_forwarder': 'enable',
- 'auto_discovery_psk': 'enable',
- 'auto_discovery_receiver': 'enable',
- 'auto_discovery_sender': 'enable',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_18',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_23',
- 'default_gw': 'test_value_24',
- 'default_gw_priority': '25',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '28',
- 'dns_mode': 'manual',
- 'domain': 'test_value_30',
- 'dpd': 'disable',
- 'dpd_retrycount': '32',
- 'dpd_retryinterval': 'test_value_33',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'encap_local_gw4': 'test_value_36',
- 'encap_local_gw6': 'test_value_37',
- 'encap_remote_gw4': 'test_value_38',
- 'encap_remote_gw6': 'test_value_39',
- 'encapsulation': 'none',
- 'encapsulation_address': 'ike',
- 'enforce_unique_id': 'disable',
- 'exchange_interface_ip': 'enable',
- 'exchange_ip_addr4': 'test_value_44',
- 'exchange_ip_addr6': 'test_value_45',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '48',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_50',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '53',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_56',
- 'ip_version': '4',
- 'ipv4_dns_server1': 'test_value_58',
- 'ipv4_dns_server2': 'test_value_59',
- 'ipv4_dns_server3': 'test_value_60',
- 'ipv4_end_ip': 'test_value_61',
- 'ipv4_name': 'test_value_62',
- 'ipv4_netmask': 'test_value_63',
- 'ipv4_split_exclude': 'test_value_64',
- 'ipv4_split_include': 'test_value_65',
- 'ipv4_start_ip': 'test_value_66',
- 'ipv4_wins_server1': 'test_value_67',
- 'ipv4_wins_server2': 'test_value_68',
- 'ipv6_dns_server1': 'test_value_69',
- 'ipv6_dns_server2': 'test_value_70',
- 'ipv6_dns_server3': 'test_value_71',
- 'ipv6_end_ip': 'test_value_72',
- 'ipv6_name': 'test_value_73',
- 'ipv6_prefix': '74',
- 'ipv6_split_exclude': 'test_value_75',
- 'ipv6_split_include': 'test_value_76',
- 'ipv6_start_ip': 'test_value_77',
- 'keepalive': '78',
- 'keylife': '79',
- 'local_gw': 'test_value_80',
- 'local_gw6': 'test_value_81',
- 'localid': 'test_value_82',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'monitor': 'test_value_87',
- 'monitor_hold_down_delay': '88',
- 'monitor_hold_down_time': 'test_value_89',
- 'monitor_hold_down_type': 'immediate',
- 'monitor_hold_down_weekday': 'everyday',
- 'name': 'default_name_92',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '94',
- 'net_device': 'enable',
- 'passive_mode': 'enable',
- 'peer': 'test_value_97',
- 'peergrp': 'test_value_98',
- 'peerid': 'test_value_99',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_102',
- 'ppk_secret': 'test_value_103',
- 'priority': '104',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_106',
- 'psksecret_remote': 'test_value_107',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_110',
- 'remote_gw6': 'test_value_111',
- 'remotegw_ddns': 'test_value_112',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_117',
- 'suite_b': 'disable',
- 'tunnel_search': 'selectors',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_122',
- 'vni': '123',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'acct-verify': 'enable',
- 'add-gw-route': 'enable',
- 'add-route': 'disable',
- 'assign-ip': 'disable',
- 'assign-ip-from': 'range',
- 'authmethod': 'psk',
- 'authmethod-remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto-discovery-forwarder': 'enable',
- 'auto-discovery-psk': 'enable',
- 'auto-discovery-receiver': 'enable',
- 'auto-discovery-sender': 'enable',
- 'auto-negotiate': 'enable',
- 'banner': 'test_value_18',
- 'cert-id-validation': 'enable',
- 'childless-ike': 'enable',
- 'client-auto-negotiate': 'disable',
- 'client-keep-alive': 'disable',
- 'comments': 'test_value_23',
- 'default-gw': 'test_value_24',
- 'default-gw-priority': '25',
- 'dhgrp': '1',
- 'digital-signature-auth': 'enable',
- 'distance': '28',
- 'dns-mode': 'manual',
- 'domain': 'test_value_30',
- 'dpd': 'disable',
- 'dpd-retrycount': '32',
- 'dpd-retryinterval': 'test_value_33',
- 'eap': 'enable',
- 'eap-identity': 'use-id-payload',
- 'encap-local-gw4': 'test_value_36',
- 'encap-local-gw6': 'test_value_37',
- 'encap-remote-gw4': 'test_value_38',
- 'encap-remote-gw6': 'test_value_39',
- 'encapsulation': 'none',
- 'encapsulation-address': 'ike',
- 'enforce-unique-id': 'disable',
- 'exchange-interface-ip': 'enable',
- 'exchange-ip-addr4': 'test_value_44',
- 'exchange-ip-addr6': 'test_value_45',
- 'forticlient-enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation-mtu': '48',
- 'group-authentication': 'enable',
- 'group-authentication-secret': 'test_value_50',
- 'ha-sync-esp-seqno': 'enable',
- 'idle-timeout': 'enable',
- 'idle-timeoutinterval': '53',
- 'ike-version': '1',
- 'include-local-lan': 'disable',
- 'interface': 'test_value_56',
- 'ip-version': '4',
- 'ipv4-dns-server1': 'test_value_58',
- 'ipv4-dns-server2': 'test_value_59',
- 'ipv4-dns-server3': 'test_value_60',
- 'ipv4-end-ip': 'test_value_61',
- 'ipv4-name': 'test_value_62',
- 'ipv4-netmask': 'test_value_63',
- 'ipv4-split-exclude': 'test_value_64',
- 'ipv4-split-include': 'test_value_65',
- 'ipv4-start-ip': 'test_value_66',
- 'ipv4-wins-server1': 'test_value_67',
- 'ipv4-wins-server2': 'test_value_68',
- 'ipv6-dns-server1': 'test_value_69',
- 'ipv6-dns-server2': 'test_value_70',
- 'ipv6-dns-server3': 'test_value_71',
- 'ipv6-end-ip': 'test_value_72',
- 'ipv6-name': 'test_value_73',
- 'ipv6-prefix': '74',
- 'ipv6-split-exclude': 'test_value_75',
- 'ipv6-split-include': 'test_value_76',
- 'ipv6-start-ip': 'test_value_77',
- 'keepalive': '78',
- 'keylife': '79',
- 'local-gw': 'test_value_80',
- 'local-gw6': 'test_value_81',
- 'localid': 'test_value_82',
- 'localid-type': 'auto',
- 'mesh-selector-type': 'disable',
- 'mode': 'aggressive',
- 'mode-cfg': 'disable',
- 'monitor': 'test_value_87',
- 'monitor-hold-down-delay': '88',
- 'monitor-hold-down-time': 'test_value_89',
- 'monitor-hold-down-type': 'immediate',
- 'monitor-hold-down-weekday': 'everyday',
- 'name': 'default_name_92',
- 'nattraversal': 'enable',
- 'negotiate-timeout': '94',
- 'net-device': 'enable',
- 'passive-mode': 'enable',
- 'peer': 'test_value_97',
- 'peergrp': 'test_value_98',
- 'peerid': 'test_value_99',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk-identity': 'test_value_102',
- 'ppk-secret': 'test_value_103',
- 'priority': '104',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_106',
- 'psksecret-remote': 'test_value_107',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote-gw': 'test_value_110',
- 'remote-gw6': 'test_value_111',
- 'remotegw-ddns': 'test_value_112',
- 'rsa-signature-format': 'pkcs1',
- 'save-password': 'disable',
- 'send-cert-chain': 'enable',
- 'signature-hash-alg': 'sha1',
- 'split-include-service': 'test_value_117',
- 'suite-b': 'disable',
- 'tunnel-search': 'selectors',
- 'type': 'static',
- 'unity-support': 'disable',
- 'usrgrp': 'test_value_122',
- 'vni': '123',
- 'wizard-type': 'custom',
- 'xauthtype': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase1-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ipsec_phase1_interface_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase1_interface': {
- 'random_attribute_not_valid': 'tag',
- 'acct_verify': 'enable',
- 'add_gw_route': 'enable',
- 'add_route': 'disable',
- 'assign_ip': 'disable',
- 'assign_ip_from': 'range',
- 'authmethod': 'psk',
- 'authmethod_remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto_discovery_forwarder': 'enable',
- 'auto_discovery_psk': 'enable',
- 'auto_discovery_receiver': 'enable',
- 'auto_discovery_sender': 'enable',
- 'auto_negotiate': 'enable',
- 'banner': 'test_value_18',
- 'cert_id_validation': 'enable',
- 'childless_ike': 'enable',
- 'client_auto_negotiate': 'disable',
- 'client_keep_alive': 'disable',
- 'comments': 'test_value_23',
- 'default_gw': 'test_value_24',
- 'default_gw_priority': '25',
- 'dhgrp': '1',
- 'digital_signature_auth': 'enable',
- 'distance': '28',
- 'dns_mode': 'manual',
- 'domain': 'test_value_30',
- 'dpd': 'disable',
- 'dpd_retrycount': '32',
- 'dpd_retryinterval': 'test_value_33',
- 'eap': 'enable',
- 'eap_identity': 'use-id-payload',
- 'encap_local_gw4': 'test_value_36',
- 'encap_local_gw6': 'test_value_37',
- 'encap_remote_gw4': 'test_value_38',
- 'encap_remote_gw6': 'test_value_39',
- 'encapsulation': 'none',
- 'encapsulation_address': 'ike',
- 'enforce_unique_id': 'disable',
- 'exchange_interface_ip': 'enable',
- 'exchange_ip_addr4': 'test_value_44',
- 'exchange_ip_addr6': 'test_value_45',
- 'forticlient_enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation_mtu': '48',
- 'group_authentication': 'enable',
- 'group_authentication_secret': 'test_value_50',
- 'ha_sync_esp_seqno': 'enable',
- 'idle_timeout': 'enable',
- 'idle_timeoutinterval': '53',
- 'ike_version': '1',
- 'include_local_lan': 'disable',
- 'interface': 'test_value_56',
- 'ip_version': '4',
- 'ipv4_dns_server1': 'test_value_58',
- 'ipv4_dns_server2': 'test_value_59',
- 'ipv4_dns_server3': 'test_value_60',
- 'ipv4_end_ip': 'test_value_61',
- 'ipv4_name': 'test_value_62',
- 'ipv4_netmask': 'test_value_63',
- 'ipv4_split_exclude': 'test_value_64',
- 'ipv4_split_include': 'test_value_65',
- 'ipv4_start_ip': 'test_value_66',
- 'ipv4_wins_server1': 'test_value_67',
- 'ipv4_wins_server2': 'test_value_68',
- 'ipv6_dns_server1': 'test_value_69',
- 'ipv6_dns_server2': 'test_value_70',
- 'ipv6_dns_server3': 'test_value_71',
- 'ipv6_end_ip': 'test_value_72',
- 'ipv6_name': 'test_value_73',
- 'ipv6_prefix': '74',
- 'ipv6_split_exclude': 'test_value_75',
- 'ipv6_split_include': 'test_value_76',
- 'ipv6_start_ip': 'test_value_77',
- 'keepalive': '78',
- 'keylife': '79',
- 'local_gw': 'test_value_80',
- 'local_gw6': 'test_value_81',
- 'localid': 'test_value_82',
- 'localid_type': 'auto',
- 'mesh_selector_type': 'disable',
- 'mode': 'aggressive',
- 'mode_cfg': 'disable',
- 'monitor': 'test_value_87',
- 'monitor_hold_down_delay': '88',
- 'monitor_hold_down_time': 'test_value_89',
- 'monitor_hold_down_type': 'immediate',
- 'monitor_hold_down_weekday': 'everyday',
- 'name': 'default_name_92',
- 'nattraversal': 'enable',
- 'negotiate_timeout': '94',
- 'net_device': 'enable',
- 'passive_mode': 'enable',
- 'peer': 'test_value_97',
- 'peergrp': 'test_value_98',
- 'peerid': 'test_value_99',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk_identity': 'test_value_102',
- 'ppk_secret': 'test_value_103',
- 'priority': '104',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_106',
- 'psksecret_remote': 'test_value_107',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote_gw': 'test_value_110',
- 'remote_gw6': 'test_value_111',
- 'remotegw_ddns': 'test_value_112',
- 'rsa_signature_format': 'pkcs1',
- 'save_password': 'disable',
- 'send_cert_chain': 'enable',
- 'signature_hash_alg': 'sha1',
- 'split_include_service': 'test_value_117',
- 'suite_b': 'disable',
- 'tunnel_search': 'selectors',
- 'type': 'static',
- 'unity_support': 'disable',
- 'usrgrp': 'test_value_122',
- 'vni': '123',
- 'wizard_type': 'custom',
- 'xauthtype': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase1_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'acct-verify': 'enable',
- 'add-gw-route': 'enable',
- 'add-route': 'disable',
- 'assign-ip': 'disable',
- 'assign-ip-from': 'range',
- 'authmethod': 'psk',
- 'authmethod-remote': 'psk',
- 'authpasswd': 'test_value_10',
- 'authusr': 'test_value_11',
- 'authusrgrp': 'test_value_12',
- 'auto-discovery-forwarder': 'enable',
- 'auto-discovery-psk': 'enable',
- 'auto-discovery-receiver': 'enable',
- 'auto-discovery-sender': 'enable',
- 'auto-negotiate': 'enable',
- 'banner': 'test_value_18',
- 'cert-id-validation': 'enable',
- 'childless-ike': 'enable',
- 'client-auto-negotiate': 'disable',
- 'client-keep-alive': 'disable',
- 'comments': 'test_value_23',
- 'default-gw': 'test_value_24',
- 'default-gw-priority': '25',
- 'dhgrp': '1',
- 'digital-signature-auth': 'enable',
- 'distance': '28',
- 'dns-mode': 'manual',
- 'domain': 'test_value_30',
- 'dpd': 'disable',
- 'dpd-retrycount': '32',
- 'dpd-retryinterval': 'test_value_33',
- 'eap': 'enable',
- 'eap-identity': 'use-id-payload',
- 'encap-local-gw4': 'test_value_36',
- 'encap-local-gw6': 'test_value_37',
- 'encap-remote-gw4': 'test_value_38',
- 'encap-remote-gw6': 'test_value_39',
- 'encapsulation': 'none',
- 'encapsulation-address': 'ike',
- 'enforce-unique-id': 'disable',
- 'exchange-interface-ip': 'enable',
- 'exchange-ip-addr4': 'test_value_44',
- 'exchange-ip-addr6': 'test_value_45',
- 'forticlient-enforcement': 'enable',
- 'fragmentation': 'enable',
- 'fragmentation-mtu': '48',
- 'group-authentication': 'enable',
- 'group-authentication-secret': 'test_value_50',
- 'ha-sync-esp-seqno': 'enable',
- 'idle-timeout': 'enable',
- 'idle-timeoutinterval': '53',
- 'ike-version': '1',
- 'include-local-lan': 'disable',
- 'interface': 'test_value_56',
- 'ip-version': '4',
- 'ipv4-dns-server1': 'test_value_58',
- 'ipv4-dns-server2': 'test_value_59',
- 'ipv4-dns-server3': 'test_value_60',
- 'ipv4-end-ip': 'test_value_61',
- 'ipv4-name': 'test_value_62',
- 'ipv4-netmask': 'test_value_63',
- 'ipv4-split-exclude': 'test_value_64',
- 'ipv4-split-include': 'test_value_65',
- 'ipv4-start-ip': 'test_value_66',
- 'ipv4-wins-server1': 'test_value_67',
- 'ipv4-wins-server2': 'test_value_68',
- 'ipv6-dns-server1': 'test_value_69',
- 'ipv6-dns-server2': 'test_value_70',
- 'ipv6-dns-server3': 'test_value_71',
- 'ipv6-end-ip': 'test_value_72',
- 'ipv6-name': 'test_value_73',
- 'ipv6-prefix': '74',
- 'ipv6-split-exclude': 'test_value_75',
- 'ipv6-split-include': 'test_value_76',
- 'ipv6-start-ip': 'test_value_77',
- 'keepalive': '78',
- 'keylife': '79',
- 'local-gw': 'test_value_80',
- 'local-gw6': 'test_value_81',
- 'localid': 'test_value_82',
- 'localid-type': 'auto',
- 'mesh-selector-type': 'disable',
- 'mode': 'aggressive',
- 'mode-cfg': 'disable',
- 'monitor': 'test_value_87',
- 'monitor-hold-down-delay': '88',
- 'monitor-hold-down-time': 'test_value_89',
- 'monitor-hold-down-type': 'immediate',
- 'monitor-hold-down-weekday': 'everyday',
- 'name': 'default_name_92',
- 'nattraversal': 'enable',
- 'negotiate-timeout': '94',
- 'net-device': 'enable',
- 'passive-mode': 'enable',
- 'peer': 'test_value_97',
- 'peergrp': 'test_value_98',
- 'peerid': 'test_value_99',
- 'peertype': 'any',
- 'ppk': 'disable',
- 'ppk-identity': 'test_value_102',
- 'ppk-secret': 'test_value_103',
- 'priority': '104',
- 'proposal': 'des-md5',
- 'psksecret': 'test_value_106',
- 'psksecret-remote': 'test_value_107',
- 'reauth': 'disable',
- 'rekey': 'enable',
- 'remote-gw': 'test_value_110',
- 'remote-gw6': 'test_value_111',
- 'remotegw-ddns': 'test_value_112',
- 'rsa-signature-format': 'pkcs1',
- 'save-password': 'disable',
- 'send-cert-chain': 'enable',
- 'signature-hash-alg': 'sha1',
- 'split-include-service': 'test_value_117',
- 'suite-b': 'disable',
- 'tunnel-search': 'selectors',
- 'type': 'static',
- 'unity-support': 'disable',
- 'usrgrp': 'test_value_122',
- 'vni': '123',
- 'wizard-type': 'custom',
- 'xauthtype': 'disable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase1-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase2.py b/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase2.py
deleted file mode 100644
index 69c8c362f7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase2.py
+++ /dev/null
@@ -1,599 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ipsec_phase2
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ipsec_phase2.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ipsec_phase2_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase2': {
- 'add_route': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_5',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_9',
- 'dst_end_ip6': 'test_value_10',
- 'dst_name': 'test_value_11',
- 'dst_name6': 'test_value_12',
- 'dst_port': '13',
- 'dst_start_ip': 'test_value_14',
- 'dst_start_ip6': 'test_value_15',
- 'dst_subnet': 'test_value_16',
- 'dst_subnet6': 'test_value_17',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '21',
- 'keylifeseconds': '22',
- 'l2tp': 'enable',
- 'name': 'default_name_24',
- 'pfs': 'enable',
- 'phase1name': 'test_value_26',
- 'proposal': 'null-md5',
- 'protocol': '28',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'selector_match': 'exact',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42',
- 'use_natip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'add-route': 'phase1',
- 'auto-negotiate': 'enable',
- 'comments': 'test_value_5',
- 'dhcp-ipsec': 'enable',
- 'dhgrp': '1',
- 'dst-addr-type': 'subnet',
- 'dst-end-ip': 'test_value_9',
- 'dst-end-ip6': 'test_value_10',
- 'dst-name': 'test_value_11',
- 'dst-name6': 'test_value_12',
- 'dst-port': '13',
- 'dst-start-ip': 'test_value_14',
- 'dst-start-ip6': 'test_value_15',
- 'dst-subnet': 'test_value_16',
- 'dst-subnet6': 'test_value_17',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife-type': 'seconds',
- 'keylifekbs': '21',
- 'keylifeseconds': '22',
- 'l2tp': 'enable',
- 'name': 'default_name_24',
- 'pfs': 'enable',
- 'phase1name': 'test_value_26',
- 'proposal': 'null-md5',
- 'protocol': '28',
- 'replay': 'enable',
- 'route-overlap': 'use-old',
- 'selector-match': 'exact',
- 'single-source': 'enable',
- 'src-addr-type': 'subnet',
- 'src-end-ip': 'test_value_34',
- 'src-end-ip6': 'test_value_35',
- 'src-name': 'test_value_36',
- 'src-name6': 'test_value_37',
- 'src-port': '38',
- 'src-start-ip': 'test_value_39',
- 'src-start-ip6': 'test_value_40',
- 'src-subnet': 'test_value_41',
- 'src-subnet6': 'test_value_42',
- 'use-natip': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase2', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_phase2_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase2': {
- 'add_route': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_5',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_9',
- 'dst_end_ip6': 'test_value_10',
- 'dst_name': 'test_value_11',
- 'dst_name6': 'test_value_12',
- 'dst_port': '13',
- 'dst_start_ip': 'test_value_14',
- 'dst_start_ip6': 'test_value_15',
- 'dst_subnet': 'test_value_16',
- 'dst_subnet6': 'test_value_17',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '21',
- 'keylifeseconds': '22',
- 'l2tp': 'enable',
- 'name': 'default_name_24',
- 'pfs': 'enable',
- 'phase1name': 'test_value_26',
- 'proposal': 'null-md5',
- 'protocol': '28',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'selector_match': 'exact',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42',
- 'use_natip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'add-route': 'phase1',
- 'auto-negotiate': 'enable',
- 'comments': 'test_value_5',
- 'dhcp-ipsec': 'enable',
- 'dhgrp': '1',
- 'dst-addr-type': 'subnet',
- 'dst-end-ip': 'test_value_9',
- 'dst-end-ip6': 'test_value_10',
- 'dst-name': 'test_value_11',
- 'dst-name6': 'test_value_12',
- 'dst-port': '13',
- 'dst-start-ip': 'test_value_14',
- 'dst-start-ip6': 'test_value_15',
- 'dst-subnet': 'test_value_16',
- 'dst-subnet6': 'test_value_17',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife-type': 'seconds',
- 'keylifekbs': '21',
- 'keylifeseconds': '22',
- 'l2tp': 'enable',
- 'name': 'default_name_24',
- 'pfs': 'enable',
- 'phase1name': 'test_value_26',
- 'proposal': 'null-md5',
- 'protocol': '28',
- 'replay': 'enable',
- 'route-overlap': 'use-old',
- 'selector-match': 'exact',
- 'single-source': 'enable',
- 'src-addr-type': 'subnet',
- 'src-end-ip': 'test_value_34',
- 'src-end-ip6': 'test_value_35',
- 'src-name': 'test_value_36',
- 'src-name6': 'test_value_37',
- 'src-port': '38',
- 'src-start-ip': 'test_value_39',
- 'src-start-ip6': 'test_value_40',
- 'src-subnet': 'test_value_41',
- 'src-subnet6': 'test_value_42',
- 'use-natip': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase2', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_phase2_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_phase2': {
- 'add_route': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_5',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_9',
- 'dst_end_ip6': 'test_value_10',
- 'dst_name': 'test_value_11',
- 'dst_name6': 'test_value_12',
- 'dst_port': '13',
- 'dst_start_ip': 'test_value_14',
- 'dst_start_ip6': 'test_value_15',
- 'dst_subnet': 'test_value_16',
- 'dst_subnet6': 'test_value_17',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '21',
- 'keylifeseconds': '22',
- 'l2tp': 'enable',
- 'name': 'default_name_24',
- 'pfs': 'enable',
- 'phase1name': 'test_value_26',
- 'proposal': 'null-md5',
- 'protocol': '28',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'selector_match': 'exact',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42',
- 'use_natip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'phase2', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_phase2_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_phase2': {
- 'add_route': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_5',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_9',
- 'dst_end_ip6': 'test_value_10',
- 'dst_name': 'test_value_11',
- 'dst_name6': 'test_value_12',
- 'dst_port': '13',
- 'dst_start_ip': 'test_value_14',
- 'dst_start_ip6': 'test_value_15',
- 'dst_subnet': 'test_value_16',
- 'dst_subnet6': 'test_value_17',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '21',
- 'keylifeseconds': '22',
- 'l2tp': 'enable',
- 'name': 'default_name_24',
- 'pfs': 'enable',
- 'phase1name': 'test_value_26',
- 'proposal': 'null-md5',
- 'protocol': '28',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'selector_match': 'exact',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42',
- 'use_natip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'phase2', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_phase2_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase2': {
- 'add_route': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_5',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_9',
- 'dst_end_ip6': 'test_value_10',
- 'dst_name': 'test_value_11',
- 'dst_name6': 'test_value_12',
- 'dst_port': '13',
- 'dst_start_ip': 'test_value_14',
- 'dst_start_ip6': 'test_value_15',
- 'dst_subnet': 'test_value_16',
- 'dst_subnet6': 'test_value_17',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '21',
- 'keylifeseconds': '22',
- 'l2tp': 'enable',
- 'name': 'default_name_24',
- 'pfs': 'enable',
- 'phase1name': 'test_value_26',
- 'proposal': 'null-md5',
- 'protocol': '28',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'selector_match': 'exact',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42',
- 'use_natip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'add-route': 'phase1',
- 'auto-negotiate': 'enable',
- 'comments': 'test_value_5',
- 'dhcp-ipsec': 'enable',
- 'dhgrp': '1',
- 'dst-addr-type': 'subnet',
- 'dst-end-ip': 'test_value_9',
- 'dst-end-ip6': 'test_value_10',
- 'dst-name': 'test_value_11',
- 'dst-name6': 'test_value_12',
- 'dst-port': '13',
- 'dst-start-ip': 'test_value_14',
- 'dst-start-ip6': 'test_value_15',
- 'dst-subnet': 'test_value_16',
- 'dst-subnet6': 'test_value_17',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife-type': 'seconds',
- 'keylifekbs': '21',
- 'keylifeseconds': '22',
- 'l2tp': 'enable',
- 'name': 'default_name_24',
- 'pfs': 'enable',
- 'phase1name': 'test_value_26',
- 'proposal': 'null-md5',
- 'protocol': '28',
- 'replay': 'enable',
- 'route-overlap': 'use-old',
- 'selector-match': 'exact',
- 'single-source': 'enable',
- 'src-addr-type': 'subnet',
- 'src-end-ip': 'test_value_34',
- 'src-end-ip6': 'test_value_35',
- 'src-name': 'test_value_36',
- 'src-name6': 'test_value_37',
- 'src-port': '38',
- 'src-start-ip': 'test_value_39',
- 'src-start-ip6': 'test_value_40',
- 'src-subnet': 'test_value_41',
- 'src-subnet6': 'test_value_42',
- 'use-natip': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase2', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ipsec_phase2_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase2': {
- 'random_attribute_not_valid': 'tag',
- 'add_route': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_5',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_9',
- 'dst_end_ip6': 'test_value_10',
- 'dst_name': 'test_value_11',
- 'dst_name6': 'test_value_12',
- 'dst_port': '13',
- 'dst_start_ip': 'test_value_14',
- 'dst_start_ip6': 'test_value_15',
- 'dst_subnet': 'test_value_16',
- 'dst_subnet6': 'test_value_17',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '21',
- 'keylifeseconds': '22',
- 'l2tp': 'enable',
- 'name': 'default_name_24',
- 'pfs': 'enable',
- 'phase1name': 'test_value_26',
- 'proposal': 'null-md5',
- 'protocol': '28',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'selector_match': 'exact',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42',
- 'use_natip': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'add-route': 'phase1',
- 'auto-negotiate': 'enable',
- 'comments': 'test_value_5',
- 'dhcp-ipsec': 'enable',
- 'dhgrp': '1',
- 'dst-addr-type': 'subnet',
- 'dst-end-ip': 'test_value_9',
- 'dst-end-ip6': 'test_value_10',
- 'dst-name': 'test_value_11',
- 'dst-name6': 'test_value_12',
- 'dst-port': '13',
- 'dst-start-ip': 'test_value_14',
- 'dst-start-ip6': 'test_value_15',
- 'dst-subnet': 'test_value_16',
- 'dst-subnet6': 'test_value_17',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife-type': 'seconds',
- 'keylifekbs': '21',
- 'keylifeseconds': '22',
- 'l2tp': 'enable',
- 'name': 'default_name_24',
- 'pfs': 'enable',
- 'phase1name': 'test_value_26',
- 'proposal': 'null-md5',
- 'protocol': '28',
- 'replay': 'enable',
- 'route-overlap': 'use-old',
- 'selector-match': 'exact',
- 'single-source': 'enable',
- 'src-addr-type': 'subnet',
- 'src-end-ip': 'test_value_34',
- 'src-end-ip6': 'test_value_35',
- 'src-name': 'test_value_36',
- 'src-name6': 'test_value_37',
- 'src-port': '38',
- 'src-start-ip': 'test_value_39',
- 'src-start-ip6': 'test_value_40',
- 'src-subnet': 'test_value_41',
- 'src-subnet6': 'test_value_42',
- 'use-natip': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase2', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase2_interface.py b/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase2_interface.py
deleted file mode 100644
index ea6130447b..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ipsec_phase2_interface.py
+++ /dev/null
@@ -1,589 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ipsec_phase2_interface
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ipsec_phase2_interface.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ipsec_phase2_interface_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase2_interface': {
- 'add_route': 'phase1',
- 'auto_discovery_forwarder': 'phase1',
- 'auto_discovery_sender': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_7',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_11',
- 'dst_end_ip6': 'test_value_12',
- 'dst_name': 'test_value_13',
- 'dst_name6': 'test_value_14',
- 'dst_port': '15',
- 'dst_start_ip': 'test_value_16',
- 'dst_start_ip6': 'test_value_17',
- 'dst_subnet': 'test_value_18',
- 'dst_subnet6': 'test_value_19',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '23',
- 'keylifeseconds': '24',
- 'l2tp': 'enable',
- 'name': 'default_name_26',
- 'pfs': 'enable',
- 'phase1name': 'test_value_28',
- 'protocol': '29',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'add-route': 'phase1',
- 'auto-discovery-forwarder': 'phase1',
- 'auto-discovery-sender': 'phase1',
- 'auto-negotiate': 'enable',
- 'comments': 'test_value_7',
- 'dhcp-ipsec': 'enable',
- 'dhgrp': '1',
- 'dst-addr-type': 'subnet',
- 'dst-end-ip': 'test_value_11',
- 'dst-end-ip6': 'test_value_12',
- 'dst-name': 'test_value_13',
- 'dst-name6': 'test_value_14',
- 'dst-port': '15',
- 'dst-start-ip': 'test_value_16',
- 'dst-start-ip6': 'test_value_17',
- 'dst-subnet': 'test_value_18',
- 'dst-subnet6': 'test_value_19',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife-type': 'seconds',
- 'keylifekbs': '23',
- 'keylifeseconds': '24',
- 'l2tp': 'enable',
- 'name': 'default_name_26',
- 'pfs': 'enable',
- 'phase1name': 'test_value_28',
- 'protocol': '29',
- 'replay': 'enable',
- 'route-overlap': 'use-old',
- 'single-source': 'enable',
- 'src-addr-type': 'subnet',
- 'src-end-ip': 'test_value_34',
- 'src-end-ip6': 'test_value_35',
- 'src-name': 'test_value_36',
- 'src-name6': 'test_value_37',
- 'src-port': '38',
- 'src-start-ip': 'test_value_39',
- 'src-start-ip6': 'test_value_40',
- 'src-subnet': 'test_value_41',
- 'src-subnet6': 'test_value_42'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase2-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_phase2_interface_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase2_interface': {
- 'add_route': 'phase1',
- 'auto_discovery_forwarder': 'phase1',
- 'auto_discovery_sender': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_7',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_11',
- 'dst_end_ip6': 'test_value_12',
- 'dst_name': 'test_value_13',
- 'dst_name6': 'test_value_14',
- 'dst_port': '15',
- 'dst_start_ip': 'test_value_16',
- 'dst_start_ip6': 'test_value_17',
- 'dst_subnet': 'test_value_18',
- 'dst_subnet6': 'test_value_19',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '23',
- 'keylifeseconds': '24',
- 'l2tp': 'enable',
- 'name': 'default_name_26',
- 'pfs': 'enable',
- 'phase1name': 'test_value_28',
- 'protocol': '29',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'add-route': 'phase1',
- 'auto-discovery-forwarder': 'phase1',
- 'auto-discovery-sender': 'phase1',
- 'auto-negotiate': 'enable',
- 'comments': 'test_value_7',
- 'dhcp-ipsec': 'enable',
- 'dhgrp': '1',
- 'dst-addr-type': 'subnet',
- 'dst-end-ip': 'test_value_11',
- 'dst-end-ip6': 'test_value_12',
- 'dst-name': 'test_value_13',
- 'dst-name6': 'test_value_14',
- 'dst-port': '15',
- 'dst-start-ip': 'test_value_16',
- 'dst-start-ip6': 'test_value_17',
- 'dst-subnet': 'test_value_18',
- 'dst-subnet6': 'test_value_19',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife-type': 'seconds',
- 'keylifekbs': '23',
- 'keylifeseconds': '24',
- 'l2tp': 'enable',
- 'name': 'default_name_26',
- 'pfs': 'enable',
- 'phase1name': 'test_value_28',
- 'protocol': '29',
- 'replay': 'enable',
- 'route-overlap': 'use-old',
- 'single-source': 'enable',
- 'src-addr-type': 'subnet',
- 'src-end-ip': 'test_value_34',
- 'src-end-ip6': 'test_value_35',
- 'src-name': 'test_value_36',
- 'src-name6': 'test_value_37',
- 'src-port': '38',
- 'src-start-ip': 'test_value_39',
- 'src-start-ip6': 'test_value_40',
- 'src-subnet': 'test_value_41',
- 'src-subnet6': 'test_value_42'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase2-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_phase2_interface_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_phase2_interface': {
- 'add_route': 'phase1',
- 'auto_discovery_forwarder': 'phase1',
- 'auto_discovery_sender': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_7',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_11',
- 'dst_end_ip6': 'test_value_12',
- 'dst_name': 'test_value_13',
- 'dst_name6': 'test_value_14',
- 'dst_port': '15',
- 'dst_start_ip': 'test_value_16',
- 'dst_start_ip6': 'test_value_17',
- 'dst_subnet': 'test_value_18',
- 'dst_subnet6': 'test_value_19',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '23',
- 'keylifeseconds': '24',
- 'l2tp': 'enable',
- 'name': 'default_name_26',
- 'pfs': 'enable',
- 'phase1name': 'test_value_28',
- 'protocol': '29',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'phase2-interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ipsec_phase2_interface_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ipsec_phase2_interface': {
- 'add_route': 'phase1',
- 'auto_discovery_forwarder': 'phase1',
- 'auto_discovery_sender': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_7',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_11',
- 'dst_end_ip6': 'test_value_12',
- 'dst_name': 'test_value_13',
- 'dst_name6': 'test_value_14',
- 'dst_port': '15',
- 'dst_start_ip': 'test_value_16',
- 'dst_start_ip6': 'test_value_17',
- 'dst_subnet': 'test_value_18',
- 'dst_subnet6': 'test_value_19',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '23',
- 'keylifeseconds': '24',
- 'l2tp': 'enable',
- 'name': 'default_name_26',
- 'pfs': 'enable',
- 'phase1name': 'test_value_28',
- 'protocol': '29',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ipsec', 'phase2-interface', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ipsec_phase2_interface_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase2_interface': {
- 'add_route': 'phase1',
- 'auto_discovery_forwarder': 'phase1',
- 'auto_discovery_sender': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_7',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_11',
- 'dst_end_ip6': 'test_value_12',
- 'dst_name': 'test_value_13',
- 'dst_name6': 'test_value_14',
- 'dst_port': '15',
- 'dst_start_ip': 'test_value_16',
- 'dst_start_ip6': 'test_value_17',
- 'dst_subnet': 'test_value_18',
- 'dst_subnet6': 'test_value_19',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '23',
- 'keylifeseconds': '24',
- 'l2tp': 'enable',
- 'name': 'default_name_26',
- 'pfs': 'enable',
- 'phase1name': 'test_value_28',
- 'protocol': '29',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'add-route': 'phase1',
- 'auto-discovery-forwarder': 'phase1',
- 'auto-discovery-sender': 'phase1',
- 'auto-negotiate': 'enable',
- 'comments': 'test_value_7',
- 'dhcp-ipsec': 'enable',
- 'dhgrp': '1',
- 'dst-addr-type': 'subnet',
- 'dst-end-ip': 'test_value_11',
- 'dst-end-ip6': 'test_value_12',
- 'dst-name': 'test_value_13',
- 'dst-name6': 'test_value_14',
- 'dst-port': '15',
- 'dst-start-ip': 'test_value_16',
- 'dst-start-ip6': 'test_value_17',
- 'dst-subnet': 'test_value_18',
- 'dst-subnet6': 'test_value_19',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife-type': 'seconds',
- 'keylifekbs': '23',
- 'keylifeseconds': '24',
- 'l2tp': 'enable',
- 'name': 'default_name_26',
- 'pfs': 'enable',
- 'phase1name': 'test_value_28',
- 'protocol': '29',
- 'replay': 'enable',
- 'route-overlap': 'use-old',
- 'single-source': 'enable',
- 'src-addr-type': 'subnet',
- 'src-end-ip': 'test_value_34',
- 'src-end-ip6': 'test_value_35',
- 'src-name': 'test_value_36',
- 'src-name6': 'test_value_37',
- 'src-port': '38',
- 'src-start-ip': 'test_value_39',
- 'src-start-ip6': 'test_value_40',
- 'src-subnet': 'test_value_41',
- 'src-subnet6': 'test_value_42'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase2-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ipsec_phase2_interface_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ipsec_phase2_interface': {
- 'random_attribute_not_valid': 'tag',
- 'add_route': 'phase1',
- 'auto_discovery_forwarder': 'phase1',
- 'auto_discovery_sender': 'phase1',
- 'auto_negotiate': 'enable',
- 'comments': 'test_value_7',
- 'dhcp_ipsec': 'enable',
- 'dhgrp': '1',
- 'dst_addr_type': 'subnet',
- 'dst_end_ip': 'test_value_11',
- 'dst_end_ip6': 'test_value_12',
- 'dst_name': 'test_value_13',
- 'dst_name6': 'test_value_14',
- 'dst_port': '15',
- 'dst_start_ip': 'test_value_16',
- 'dst_start_ip6': 'test_value_17',
- 'dst_subnet': 'test_value_18',
- 'dst_subnet6': 'test_value_19',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife_type': 'seconds',
- 'keylifekbs': '23',
- 'keylifeseconds': '24',
- 'l2tp': 'enable',
- 'name': 'default_name_26',
- 'pfs': 'enable',
- 'phase1name': 'test_value_28',
- 'protocol': '29',
- 'replay': 'enable',
- 'route_overlap': 'use-old',
- 'single_source': 'enable',
- 'src_addr_type': 'subnet',
- 'src_end_ip': 'test_value_34',
- 'src_end_ip6': 'test_value_35',
- 'src_name': 'test_value_36',
- 'src_name6': 'test_value_37',
- 'src_port': '38',
- 'src_start_ip': 'test_value_39',
- 'src_start_ip6': 'test_value_40',
- 'src_subnet': 'test_value_41',
- 'src_subnet6': 'test_value_42'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ipsec_phase2_interface.fortios_vpn_ipsec(input_data, fos_instance)
-
- expected_data = {
- 'add-route': 'phase1',
- 'auto-discovery-forwarder': 'phase1',
- 'auto-discovery-sender': 'phase1',
- 'auto-negotiate': 'enable',
- 'comments': 'test_value_7',
- 'dhcp-ipsec': 'enable',
- 'dhgrp': '1',
- 'dst-addr-type': 'subnet',
- 'dst-end-ip': 'test_value_11',
- 'dst-end-ip6': 'test_value_12',
- 'dst-name': 'test_value_13',
- 'dst-name6': 'test_value_14',
- 'dst-port': '15',
- 'dst-start-ip': 'test_value_16',
- 'dst-start-ip6': 'test_value_17',
- 'dst-subnet': 'test_value_18',
- 'dst-subnet6': 'test_value_19',
- 'encapsulation': 'tunnel-mode',
- 'keepalive': 'enable',
- 'keylife-type': 'seconds',
- 'keylifekbs': '23',
- 'keylifeseconds': '24',
- 'l2tp': 'enable',
- 'name': 'default_name_26',
- 'pfs': 'enable',
- 'phase1name': 'test_value_28',
- 'protocol': '29',
- 'replay': 'enable',
- 'route-overlap': 'use-old',
- 'single-source': 'enable',
- 'src-addr-type': 'subnet',
- 'src-end-ip': 'test_value_34',
- 'src-end-ip6': 'test_value_35',
- 'src-name': 'test_value_36',
- 'src-name6': 'test_value_37',
- 'src-port': '38',
- 'src-start-ip': 'test_value_39',
- 'src-start-ip6': 'test_value_40',
- 'src-subnet': 'test_value_41',
- 'src-subnet6': 'test_value_42'
- }
-
- set_method_mock.assert_called_with('vpn.ipsec', 'phase2-interface', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_l2tp.py b/test/units/modules/network/fortios/test_fortios_vpn_l2tp.py
deleted file mode 100644
index 6f06f10ea5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_l2tp.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_l2tp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_l2tp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_l2tp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_l2tp': {
- 'eip': 'test_value_3',
- 'enforce_ipsec': 'enable',
- 'sip': 'test_value_5',
- 'status': 'enable',
- 'usrgrp': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_l2tp.fortios_vpn(input_data, fos_instance)
-
- expected_data = {
- 'eip': 'test_value_3',
- 'enforce-ipsec': 'enable',
- 'sip': 'test_value_5',
- 'status': 'enable',
- 'usrgrp': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('vpn', 'l2tp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_l2tp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_l2tp': {
- 'eip': 'test_value_3',
- 'enforce_ipsec': 'enable',
- 'sip': 'test_value_5',
- 'status': 'enable',
- 'usrgrp': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_l2tp.fortios_vpn(input_data, fos_instance)
-
- expected_data = {
- 'eip': 'test_value_3',
- 'enforce-ipsec': 'enable',
- 'sip': 'test_value_5',
- 'status': 'enable',
- 'usrgrp': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('vpn', 'l2tp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_l2tp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_l2tp': {
- 'eip': 'test_value_3',
- 'enforce_ipsec': 'enable',
- 'sip': 'test_value_5',
- 'status': 'enable',
- 'usrgrp': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_l2tp.fortios_vpn(input_data, fos_instance)
-
- expected_data = {
- 'eip': 'test_value_3',
- 'enforce-ipsec': 'enable',
- 'sip': 'test_value_5',
- 'status': 'enable',
- 'usrgrp': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('vpn', 'l2tp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_l2tp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_l2tp': {
- 'random_attribute_not_valid': 'tag',
- 'eip': 'test_value_3',
- 'enforce_ipsec': 'enable',
- 'sip': 'test_value_5',
- 'status': 'enable',
- 'usrgrp': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_l2tp.fortios_vpn(input_data, fos_instance)
-
- expected_data = {
- 'eip': 'test_value_3',
- 'enforce-ipsec': 'enable',
- 'sip': 'test_value_5',
- 'status': 'enable',
- 'usrgrp': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('vpn', 'l2tp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_pptp.py b/test/units/modules/network/fortios/test_fortios_vpn_pptp.py
deleted file mode 100644
index 0957218c2f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_pptp.py
+++ /dev/null
@@ -1,191 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_pptp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_pptp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_pptp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_pptp': {
- 'eip': 'test_value_3',
- 'ip_mode': 'range',
- 'local_ip': 'test_value_5',
- 'sip': 'test_value_6',
- 'status': 'enable',
- 'usrgrp': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_pptp.fortios_vpn(input_data, fos_instance)
-
- expected_data = {
- 'eip': 'test_value_3',
- 'ip-mode': 'range',
- 'local-ip': 'test_value_5',
- 'sip': 'test_value_6',
- 'status': 'enable',
- 'usrgrp': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('vpn', 'pptp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_pptp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_pptp': {
- 'eip': 'test_value_3',
- 'ip_mode': 'range',
- 'local_ip': 'test_value_5',
- 'sip': 'test_value_6',
- 'status': 'enable',
- 'usrgrp': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_pptp.fortios_vpn(input_data, fos_instance)
-
- expected_data = {
- 'eip': 'test_value_3',
- 'ip-mode': 'range',
- 'local-ip': 'test_value_5',
- 'sip': 'test_value_6',
- 'status': 'enable',
- 'usrgrp': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('vpn', 'pptp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_pptp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_pptp': {
- 'eip': 'test_value_3',
- 'ip_mode': 'range',
- 'local_ip': 'test_value_5',
- 'sip': 'test_value_6',
- 'status': 'enable',
- 'usrgrp': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_pptp.fortios_vpn(input_data, fos_instance)
-
- expected_data = {
- 'eip': 'test_value_3',
- 'ip-mode': 'range',
- 'local-ip': 'test_value_5',
- 'sip': 'test_value_6',
- 'status': 'enable',
- 'usrgrp': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('vpn', 'pptp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_pptp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_pptp': {
- 'random_attribute_not_valid': 'tag',
- 'eip': 'test_value_3',
- 'ip_mode': 'range',
- 'local_ip': 'test_value_5',
- 'sip': 'test_value_6',
- 'status': 'enable',
- 'usrgrp': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_pptp.fortios_vpn(input_data, fos_instance)
-
- expected_data = {
- 'eip': 'test_value_3',
- 'ip-mode': 'range',
- 'local-ip': 'test_value_5',
- 'sip': 'test_value_6',
- 'status': 'enable',
- 'usrgrp': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('vpn', 'pptp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ssl_settings.py b/test/units/modules/network/fortios/test_fortios_vpn_ssl_settings.py
deleted file mode 100644
index 3eeca8e57a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ssl_settings.py
+++ /dev/null
@@ -1,495 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ssl_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ssl_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ssl_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_settings': {
- 'auth_timeout': '3',
- 'auto_tunnel_static_route': 'enable',
- 'banned_cipher': 'RSA',
- 'check_referer': 'enable',
- 'default_portal': 'test_value_7',
- 'deflate_compression_level': '8',
- 'deflate_min_data_size': '9',
- 'dns_server1': 'test_value_10',
- 'dns_server2': 'test_value_11',
- 'dns_suffix': 'test_value_12',
- 'dtls_hello_timeout': '13',
- 'dtls_tunnel': 'enable',
- 'force_two_factor_auth': 'enable',
- 'header_x_forwarded_for': 'pass',
- 'http_compression': 'enable',
- 'http_only_cookie': 'enable',
- 'http_request_body_timeout': '19',
- 'http_request_header_timeout': '20',
- 'https_redirect': 'enable',
- 'idle_timeout': '22',
- 'ipv6_dns_server1': 'test_value_23',
- 'ipv6_dns_server2': 'test_value_24',
- 'ipv6_wins_server1': 'test_value_25',
- 'ipv6_wins_server2': 'test_value_26',
- 'login_attempt_limit': '27',
- 'login_block_time': '28',
- 'login_timeout': '29',
- 'port': '30',
- 'port_precedence': 'enable',
- 'reqclientcert': 'enable',
- 'route_source_interface': 'enable',
- 'servercert': 'test_value_34',
- 'source_address_negate': 'enable',
- 'source_address6_negate': 'enable',
- 'ssl_client_renegotiation': 'disable',
- 'ssl_insert_empty_fragment': 'enable',
- 'tlsv1_0': 'enable',
- 'tlsv1_1': 'enable',
- 'tlsv1_2': 'enable',
- 'unsafe_legacy_renegotiation': 'enable',
- 'url_obscuration': 'enable',
- 'wins_server1': 'test_value_44',
- 'wins_server2': 'test_value_45',
- 'x_content_type_options': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_settings.fortios_vpn_ssl(input_data, fos_instance)
-
- expected_data = {
- 'auth-timeout': '3',
- 'auto-tunnel-static-route': 'enable',
- 'banned-cipher': 'RSA',
- 'check-referer': 'enable',
- 'default-portal': 'test_value_7',
- 'deflate-compression-level': '8',
- 'deflate-min-data-size': '9',
- 'dns-server1': 'test_value_10',
- 'dns-server2': 'test_value_11',
- 'dns-suffix': 'test_value_12',
- 'dtls-hello-timeout': '13',
- 'dtls-tunnel': 'enable',
- 'force-two-factor-auth': 'enable',
- 'header-x-forwarded-for': 'pass',
- 'http-compression': 'enable',
- 'http-only-cookie': 'enable',
- 'http-request-body-timeout': '19',
- 'http-request-header-timeout': '20',
- 'https-redirect': 'enable',
- 'idle-timeout': '22',
- 'ipv6-dns-server1': 'test_value_23',
- 'ipv6-dns-server2': 'test_value_24',
- 'ipv6-wins-server1': 'test_value_25',
- 'ipv6-wins-server2': 'test_value_26',
- 'login-attempt-limit': '27',
- 'login-block-time': '28',
- 'login-timeout': '29',
- 'port': '30',
- 'port-precedence': 'enable',
- 'reqclientcert': 'enable',
- 'route-source-interface': 'enable',
- 'servercert': 'test_value_34',
- 'source-address-negate': 'enable',
- 'source-address6-negate': 'enable',
- 'ssl-client-renegotiation': 'disable',
- 'ssl-insert-empty-fragment': 'enable',
- 'tlsv1-0': 'enable',
- 'tlsv1-1': 'enable',
- 'tlsv1-2': 'enable',
- 'unsafe-legacy-renegotiation': 'enable',
- 'url-obscuration': 'enable',
- 'wins-server1': 'test_value_44',
- 'wins-server2': 'test_value_45',
- 'x-content-type-options': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.ssl', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ssl_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_settings': {
- 'auth_timeout': '3',
- 'auto_tunnel_static_route': 'enable',
- 'banned_cipher': 'RSA',
- 'check_referer': 'enable',
- 'default_portal': 'test_value_7',
- 'deflate_compression_level': '8',
- 'deflate_min_data_size': '9',
- 'dns_server1': 'test_value_10',
- 'dns_server2': 'test_value_11',
- 'dns_suffix': 'test_value_12',
- 'dtls_hello_timeout': '13',
- 'dtls_tunnel': 'enable',
- 'force_two_factor_auth': 'enable',
- 'header_x_forwarded_for': 'pass',
- 'http_compression': 'enable',
- 'http_only_cookie': 'enable',
- 'http_request_body_timeout': '19',
- 'http_request_header_timeout': '20',
- 'https_redirect': 'enable',
- 'idle_timeout': '22',
- 'ipv6_dns_server1': 'test_value_23',
- 'ipv6_dns_server2': 'test_value_24',
- 'ipv6_wins_server1': 'test_value_25',
- 'ipv6_wins_server2': 'test_value_26',
- 'login_attempt_limit': '27',
- 'login_block_time': '28',
- 'login_timeout': '29',
- 'port': '30',
- 'port_precedence': 'enable',
- 'reqclientcert': 'enable',
- 'route_source_interface': 'enable',
- 'servercert': 'test_value_34',
- 'source_address_negate': 'enable',
- 'source_address6_negate': 'enable',
- 'ssl_client_renegotiation': 'disable',
- 'ssl_insert_empty_fragment': 'enable',
- 'tlsv1_0': 'enable',
- 'tlsv1_1': 'enable',
- 'tlsv1_2': 'enable',
- 'unsafe_legacy_renegotiation': 'enable',
- 'url_obscuration': 'enable',
- 'wins_server1': 'test_value_44',
- 'wins_server2': 'test_value_45',
- 'x_content_type_options': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_settings.fortios_vpn_ssl(input_data, fos_instance)
-
- expected_data = {
- 'auth-timeout': '3',
- 'auto-tunnel-static-route': 'enable',
- 'banned-cipher': 'RSA',
- 'check-referer': 'enable',
- 'default-portal': 'test_value_7',
- 'deflate-compression-level': '8',
- 'deflate-min-data-size': '9',
- 'dns-server1': 'test_value_10',
- 'dns-server2': 'test_value_11',
- 'dns-suffix': 'test_value_12',
- 'dtls-hello-timeout': '13',
- 'dtls-tunnel': 'enable',
- 'force-two-factor-auth': 'enable',
- 'header-x-forwarded-for': 'pass',
- 'http-compression': 'enable',
- 'http-only-cookie': 'enable',
- 'http-request-body-timeout': '19',
- 'http-request-header-timeout': '20',
- 'https-redirect': 'enable',
- 'idle-timeout': '22',
- 'ipv6-dns-server1': 'test_value_23',
- 'ipv6-dns-server2': 'test_value_24',
- 'ipv6-wins-server1': 'test_value_25',
- 'ipv6-wins-server2': 'test_value_26',
- 'login-attempt-limit': '27',
- 'login-block-time': '28',
- 'login-timeout': '29',
- 'port': '30',
- 'port-precedence': 'enable',
- 'reqclientcert': 'enable',
- 'route-source-interface': 'enable',
- 'servercert': 'test_value_34',
- 'source-address-negate': 'enable',
- 'source-address6-negate': 'enable',
- 'ssl-client-renegotiation': 'disable',
- 'ssl-insert-empty-fragment': 'enable',
- 'tlsv1-0': 'enable',
- 'tlsv1-1': 'enable',
- 'tlsv1-2': 'enable',
- 'unsafe-legacy-renegotiation': 'enable',
- 'url-obscuration': 'enable',
- 'wins-server1': 'test_value_44',
- 'wins-server2': 'test_value_45',
- 'x-content-type-options': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.ssl', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ssl_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_settings': {
- 'auth_timeout': '3',
- 'auto_tunnel_static_route': 'enable',
- 'banned_cipher': 'RSA',
- 'check_referer': 'enable',
- 'default_portal': 'test_value_7',
- 'deflate_compression_level': '8',
- 'deflate_min_data_size': '9',
- 'dns_server1': 'test_value_10',
- 'dns_server2': 'test_value_11',
- 'dns_suffix': 'test_value_12',
- 'dtls_hello_timeout': '13',
- 'dtls_tunnel': 'enable',
- 'force_two_factor_auth': 'enable',
- 'header_x_forwarded_for': 'pass',
- 'http_compression': 'enable',
- 'http_only_cookie': 'enable',
- 'http_request_body_timeout': '19',
- 'http_request_header_timeout': '20',
- 'https_redirect': 'enable',
- 'idle_timeout': '22',
- 'ipv6_dns_server1': 'test_value_23',
- 'ipv6_dns_server2': 'test_value_24',
- 'ipv6_wins_server1': 'test_value_25',
- 'ipv6_wins_server2': 'test_value_26',
- 'login_attempt_limit': '27',
- 'login_block_time': '28',
- 'login_timeout': '29',
- 'port': '30',
- 'port_precedence': 'enable',
- 'reqclientcert': 'enable',
- 'route_source_interface': 'enable',
- 'servercert': 'test_value_34',
- 'source_address_negate': 'enable',
- 'source_address6_negate': 'enable',
- 'ssl_client_renegotiation': 'disable',
- 'ssl_insert_empty_fragment': 'enable',
- 'tlsv1_0': 'enable',
- 'tlsv1_1': 'enable',
- 'tlsv1_2': 'enable',
- 'unsafe_legacy_renegotiation': 'enable',
- 'url_obscuration': 'enable',
- 'wins_server1': 'test_value_44',
- 'wins_server2': 'test_value_45',
- 'x_content_type_options': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_settings.fortios_vpn_ssl(input_data, fos_instance)
-
- expected_data = {
- 'auth-timeout': '3',
- 'auto-tunnel-static-route': 'enable',
- 'banned-cipher': 'RSA',
- 'check-referer': 'enable',
- 'default-portal': 'test_value_7',
- 'deflate-compression-level': '8',
- 'deflate-min-data-size': '9',
- 'dns-server1': 'test_value_10',
- 'dns-server2': 'test_value_11',
- 'dns-suffix': 'test_value_12',
- 'dtls-hello-timeout': '13',
- 'dtls-tunnel': 'enable',
- 'force-two-factor-auth': 'enable',
- 'header-x-forwarded-for': 'pass',
- 'http-compression': 'enable',
- 'http-only-cookie': 'enable',
- 'http-request-body-timeout': '19',
- 'http-request-header-timeout': '20',
- 'https-redirect': 'enable',
- 'idle-timeout': '22',
- 'ipv6-dns-server1': 'test_value_23',
- 'ipv6-dns-server2': 'test_value_24',
- 'ipv6-wins-server1': 'test_value_25',
- 'ipv6-wins-server2': 'test_value_26',
- 'login-attempt-limit': '27',
- 'login-block-time': '28',
- 'login-timeout': '29',
- 'port': '30',
- 'port-precedence': 'enable',
- 'reqclientcert': 'enable',
- 'route-source-interface': 'enable',
- 'servercert': 'test_value_34',
- 'source-address-negate': 'enable',
- 'source-address6-negate': 'enable',
- 'ssl-client-renegotiation': 'disable',
- 'ssl-insert-empty-fragment': 'enable',
- 'tlsv1-0': 'enable',
- 'tlsv1-1': 'enable',
- 'tlsv1-2': 'enable',
- 'unsafe-legacy-renegotiation': 'enable',
- 'url-obscuration': 'enable',
- 'wins-server1': 'test_value_44',
- 'wins-server2': 'test_value_45',
- 'x-content-type-options': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.ssl', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ssl_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_settings': {
- 'random_attribute_not_valid': 'tag',
- 'auth_timeout': '3',
- 'auto_tunnel_static_route': 'enable',
- 'banned_cipher': 'RSA',
- 'check_referer': 'enable',
- 'default_portal': 'test_value_7',
- 'deflate_compression_level': '8',
- 'deflate_min_data_size': '9',
- 'dns_server1': 'test_value_10',
- 'dns_server2': 'test_value_11',
- 'dns_suffix': 'test_value_12',
- 'dtls_hello_timeout': '13',
- 'dtls_tunnel': 'enable',
- 'force_two_factor_auth': 'enable',
- 'header_x_forwarded_for': 'pass',
- 'http_compression': 'enable',
- 'http_only_cookie': 'enable',
- 'http_request_body_timeout': '19',
- 'http_request_header_timeout': '20',
- 'https_redirect': 'enable',
- 'idle_timeout': '22',
- 'ipv6_dns_server1': 'test_value_23',
- 'ipv6_dns_server2': 'test_value_24',
- 'ipv6_wins_server1': 'test_value_25',
- 'ipv6_wins_server2': 'test_value_26',
- 'login_attempt_limit': '27',
- 'login_block_time': '28',
- 'login_timeout': '29',
- 'port': '30',
- 'port_precedence': 'enable',
- 'reqclientcert': 'enable',
- 'route_source_interface': 'enable',
- 'servercert': 'test_value_34',
- 'source_address_negate': 'enable',
- 'source_address6_negate': 'enable',
- 'ssl_client_renegotiation': 'disable',
- 'ssl_insert_empty_fragment': 'enable',
- 'tlsv1_0': 'enable',
- 'tlsv1_1': 'enable',
- 'tlsv1_2': 'enable',
- 'unsafe_legacy_renegotiation': 'enable',
- 'url_obscuration': 'enable',
- 'wins_server1': 'test_value_44',
- 'wins_server2': 'test_value_45',
- 'x_content_type_options': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_settings.fortios_vpn_ssl(input_data, fos_instance)
-
- expected_data = {
- 'auth-timeout': '3',
- 'auto-tunnel-static-route': 'enable',
- 'banned-cipher': 'RSA',
- 'check-referer': 'enable',
- 'default-portal': 'test_value_7',
- 'deflate-compression-level': '8',
- 'deflate-min-data-size': '9',
- 'dns-server1': 'test_value_10',
- 'dns-server2': 'test_value_11',
- 'dns-suffix': 'test_value_12',
- 'dtls-hello-timeout': '13',
- 'dtls-tunnel': 'enable',
- 'force-two-factor-auth': 'enable',
- 'header-x-forwarded-for': 'pass',
- 'http-compression': 'enable',
- 'http-only-cookie': 'enable',
- 'http-request-body-timeout': '19',
- 'http-request-header-timeout': '20',
- 'https-redirect': 'enable',
- 'idle-timeout': '22',
- 'ipv6-dns-server1': 'test_value_23',
- 'ipv6-dns-server2': 'test_value_24',
- 'ipv6-wins-server1': 'test_value_25',
- 'ipv6-wins-server2': 'test_value_26',
- 'login-attempt-limit': '27',
- 'login-block-time': '28',
- 'login-timeout': '29',
- 'port': '30',
- 'port-precedence': 'enable',
- 'reqclientcert': 'enable',
- 'route-source-interface': 'enable',
- 'servercert': 'test_value_34',
- 'source-address-negate': 'enable',
- 'source-address6-negate': 'enable',
- 'ssl-client-renegotiation': 'disable',
- 'ssl-insert-empty-fragment': 'enable',
- 'tlsv1-0': 'enable',
- 'tlsv1-1': 'enable',
- 'tlsv1-2': 'enable',
- 'unsafe-legacy-renegotiation': 'enable',
- 'url-obscuration': 'enable',
- 'wins-server1': 'test_value_44',
- 'wins-server2': 'test_value_45',
- 'x-content-type-options': 'enable'
- }
-
- set_method_mock.assert_called_with('vpn.ssl', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_host_check_software.py b/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_host_check_software.py
deleted file mode 100644
index 521a616945..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_host_check_software.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ssl_web_host_check_software
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ssl_web_host_check_software.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ssl_web_host_check_software_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_host_check_software': {'guid': 'test_value_3',
- 'name': 'default_name_4',
- 'os_type': 'windows',
- 'type': 'av',
- 'version': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_host_check_software.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'guid': 'test_value_3',
- 'name': 'default_name_4',
- 'os-type': 'windows',
- 'type': 'av',
- 'version': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'host-check-software', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ssl_web_host_check_software_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_host_check_software': {'guid': 'test_value_3',
- 'name': 'default_name_4',
- 'os_type': 'windows',
- 'type': 'av',
- 'version': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_host_check_software.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'guid': 'test_value_3',
- 'name': 'default_name_4',
- 'os-type': 'windows',
- 'type': 'av',
- 'version': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'host-check-software', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ssl_web_host_check_software_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ssl_web_host_check_software': {'guid': 'test_value_3',
- 'name': 'default_name_4',
- 'os_type': 'windows',
- 'type': 'av',
- 'version': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_host_check_software.fortios_vpn_ssl_web(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ssl.web', 'host-check-software', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ssl_web_host_check_software_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ssl_web_host_check_software': {'guid': 'test_value_3',
- 'name': 'default_name_4',
- 'os_type': 'windows',
- 'type': 'av',
- 'version': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_host_check_software.fortios_vpn_ssl_web(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ssl.web', 'host-check-software', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ssl_web_host_check_software_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_host_check_software': {'guid': 'test_value_3',
- 'name': 'default_name_4',
- 'os_type': 'windows',
- 'type': 'av',
- 'version': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_host_check_software.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'guid': 'test_value_3',
- 'name': 'default_name_4',
- 'os-type': 'windows',
- 'type': 'av',
- 'version': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'host-check-software', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ssl_web_host_check_software_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_host_check_software': {
- 'random_attribute_not_valid': 'tag', 'guid': 'test_value_3',
- 'name': 'default_name_4',
- 'os_type': 'windows',
- 'type': 'av',
- 'version': 'test_value_7'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_host_check_software.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'guid': 'test_value_3',
- 'name': 'default_name_4',
- 'os-type': 'windows',
- 'type': 'av',
- 'version': 'test_value_7'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'host-check-software', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_portal.py b/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_portal.py
deleted file mode 100644
index 46031edfd0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_portal.py
+++ /dev/null
@@ -1,689 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ssl_web_portal
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ssl_web_portal.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ssl_web_portal_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_portal': {
- 'allow_user_access': 'web',
- 'auto_connect': 'enable',
- 'custom_lang': 'test_value_5',
- 'customize_forticlient_download_url': 'enable',
- 'display_bookmark': 'enable',
- 'display_connection_tools': 'enable',
- 'display_history': 'enable',
- 'display_status': 'enable',
- 'dns_server1': 'test_value_11',
- 'dns_server2': 'test_value_12',
- 'dns_suffix': 'test_value_13',
- 'exclusive_routing': 'enable',
- 'forticlient_download': 'enable',
- 'forticlient_download_method': 'direct',
- 'heading': 'test_value_17',
- 'hide_sso_credential': 'enable',
- 'host_check': 'none',
- 'host_check_interval': '20',
- 'ip_mode': 'range',
- 'ipv6_dns_server1': 'test_value_22',
- 'ipv6_dns_server2': 'test_value_23',
- 'ipv6_exclusive_routing': 'enable',
- 'ipv6_service_restriction': 'enable',
- 'ipv6_split_tunneling': 'enable',
- 'ipv6_tunnel_mode': 'enable',
- 'ipv6_wins_server1': 'test_value_28',
- 'ipv6_wins_server2': 'test_value_29',
- 'keep_alive': 'enable',
- 'limit_user_logins': 'enable',
- 'mac_addr_action': 'allow',
- 'mac_addr_check': 'enable',
- 'macos_forticlient_download_url': 'test_value_34',
- 'name': 'default_name_35',
- 'os_check': 'enable',
- 'redir_url': 'test_value_37',
- 'save_password': 'enable',
- 'service_restriction': 'enable',
- 'skip_check_for_unsupported_browser': 'enable',
- 'skip_check_for_unsupported_os': 'enable',
- 'smb_ntlmv1_auth': 'enable',
- 'smbv1': 'enable',
- 'split_tunneling': 'enable',
- 'theme': 'blue',
- 'tunnel_mode': 'enable',
- 'user_bookmark': 'enable',
- 'user_group_bookmark': 'enable',
- 'web_mode': 'enable',
- 'windows_forticlient_download_url': 'test_value_50',
- 'wins_server1': 'test_value_51',
- 'wins_server2': 'test_value_52'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_portal.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {
- 'allow-user-access': 'web',
- 'auto-connect': 'enable',
- 'custom-lang': 'test_value_5',
- 'customize-forticlient-download-url': 'enable',
- 'display-bookmark': 'enable',
- 'display-connection-tools': 'enable',
- 'display-history': 'enable',
- 'display-status': 'enable',
- 'dns-server1': 'test_value_11',
- 'dns-server2': 'test_value_12',
- 'dns-suffix': 'test_value_13',
- 'exclusive-routing': 'enable',
- 'forticlient-download': 'enable',
- 'forticlient-download-method': 'direct',
- 'heading': 'test_value_17',
- 'hide-sso-credential': 'enable',
- 'host-check': 'none',
- 'host-check-interval': '20',
- 'ip-mode': 'range',
- 'ipv6-dns-server1': 'test_value_22',
- 'ipv6-dns-server2': 'test_value_23',
- 'ipv6-exclusive-routing': 'enable',
- 'ipv6-service-restriction': 'enable',
- 'ipv6-split-tunneling': 'enable',
- 'ipv6-tunnel-mode': 'enable',
- 'ipv6-wins-server1': 'test_value_28',
- 'ipv6-wins-server2': 'test_value_29',
- 'keep-alive': 'enable',
- 'limit-user-logins': 'enable',
- 'mac-addr-action': 'allow',
- 'mac-addr-check': 'enable',
- 'macos-forticlient-download-url': 'test_value_34',
- 'name': 'default_name_35',
- 'os-check': 'enable',
- 'redir-url': 'test_value_37',
- 'save-password': 'enable',
- 'service-restriction': 'enable',
- 'skip-check-for-unsupported-browser': 'enable',
- 'skip-check-for-unsupported-os': 'enable',
- 'smb-ntlmv1-auth': 'enable',
- 'smbv1': 'enable',
- 'split-tunneling': 'enable',
- 'theme': 'blue',
- 'tunnel-mode': 'enable',
- 'user-bookmark': 'enable',
- 'user-group-bookmark': 'enable',
- 'web-mode': 'enable',
- 'windows-forticlient-download-url': 'test_value_50',
- 'wins-server1': 'test_value_51',
- 'wins-server2': 'test_value_52'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ssl_web_portal_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_portal': {
- 'allow_user_access': 'web',
- 'auto_connect': 'enable',
- 'custom_lang': 'test_value_5',
- 'customize_forticlient_download_url': 'enable',
- 'display_bookmark': 'enable',
- 'display_connection_tools': 'enable',
- 'display_history': 'enable',
- 'display_status': 'enable',
- 'dns_server1': 'test_value_11',
- 'dns_server2': 'test_value_12',
- 'dns_suffix': 'test_value_13',
- 'exclusive_routing': 'enable',
- 'forticlient_download': 'enable',
- 'forticlient_download_method': 'direct',
- 'heading': 'test_value_17',
- 'hide_sso_credential': 'enable',
- 'host_check': 'none',
- 'host_check_interval': '20',
- 'ip_mode': 'range',
- 'ipv6_dns_server1': 'test_value_22',
- 'ipv6_dns_server2': 'test_value_23',
- 'ipv6_exclusive_routing': 'enable',
- 'ipv6_service_restriction': 'enable',
- 'ipv6_split_tunneling': 'enable',
- 'ipv6_tunnel_mode': 'enable',
- 'ipv6_wins_server1': 'test_value_28',
- 'ipv6_wins_server2': 'test_value_29',
- 'keep_alive': 'enable',
- 'limit_user_logins': 'enable',
- 'mac_addr_action': 'allow',
- 'mac_addr_check': 'enable',
- 'macos_forticlient_download_url': 'test_value_34',
- 'name': 'default_name_35',
- 'os_check': 'enable',
- 'redir_url': 'test_value_37',
- 'save_password': 'enable',
- 'service_restriction': 'enable',
- 'skip_check_for_unsupported_browser': 'enable',
- 'skip_check_for_unsupported_os': 'enable',
- 'smb_ntlmv1_auth': 'enable',
- 'smbv1': 'enable',
- 'split_tunneling': 'enable',
- 'theme': 'blue',
- 'tunnel_mode': 'enable',
- 'user_bookmark': 'enable',
- 'user_group_bookmark': 'enable',
- 'web_mode': 'enable',
- 'windows_forticlient_download_url': 'test_value_50',
- 'wins_server1': 'test_value_51',
- 'wins_server2': 'test_value_52'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_portal.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {
- 'allow-user-access': 'web',
- 'auto-connect': 'enable',
- 'custom-lang': 'test_value_5',
- 'customize-forticlient-download-url': 'enable',
- 'display-bookmark': 'enable',
- 'display-connection-tools': 'enable',
- 'display-history': 'enable',
- 'display-status': 'enable',
- 'dns-server1': 'test_value_11',
- 'dns-server2': 'test_value_12',
- 'dns-suffix': 'test_value_13',
- 'exclusive-routing': 'enable',
- 'forticlient-download': 'enable',
- 'forticlient-download-method': 'direct',
- 'heading': 'test_value_17',
- 'hide-sso-credential': 'enable',
- 'host-check': 'none',
- 'host-check-interval': '20',
- 'ip-mode': 'range',
- 'ipv6-dns-server1': 'test_value_22',
- 'ipv6-dns-server2': 'test_value_23',
- 'ipv6-exclusive-routing': 'enable',
- 'ipv6-service-restriction': 'enable',
- 'ipv6-split-tunneling': 'enable',
- 'ipv6-tunnel-mode': 'enable',
- 'ipv6-wins-server1': 'test_value_28',
- 'ipv6-wins-server2': 'test_value_29',
- 'keep-alive': 'enable',
- 'limit-user-logins': 'enable',
- 'mac-addr-action': 'allow',
- 'mac-addr-check': 'enable',
- 'macos-forticlient-download-url': 'test_value_34',
- 'name': 'default_name_35',
- 'os-check': 'enable',
- 'redir-url': 'test_value_37',
- 'save-password': 'enable',
- 'service-restriction': 'enable',
- 'skip-check-for-unsupported-browser': 'enable',
- 'skip-check-for-unsupported-os': 'enable',
- 'smb-ntlmv1-auth': 'enable',
- 'smbv1': 'enable',
- 'split-tunneling': 'enable',
- 'theme': 'blue',
- 'tunnel-mode': 'enable',
- 'user-bookmark': 'enable',
- 'user-group-bookmark': 'enable',
- 'web-mode': 'enable',
- 'windows-forticlient-download-url': 'test_value_50',
- 'wins-server1': 'test_value_51',
- 'wins-server2': 'test_value_52'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ssl_web_portal_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ssl_web_portal': {
- 'allow_user_access': 'web',
- 'auto_connect': 'enable',
- 'custom_lang': 'test_value_5',
- 'customize_forticlient_download_url': 'enable',
- 'display_bookmark': 'enable',
- 'display_connection_tools': 'enable',
- 'display_history': 'enable',
- 'display_status': 'enable',
- 'dns_server1': 'test_value_11',
- 'dns_server2': 'test_value_12',
- 'dns_suffix': 'test_value_13',
- 'exclusive_routing': 'enable',
- 'forticlient_download': 'enable',
- 'forticlient_download_method': 'direct',
- 'heading': 'test_value_17',
- 'hide_sso_credential': 'enable',
- 'host_check': 'none',
- 'host_check_interval': '20',
- 'ip_mode': 'range',
- 'ipv6_dns_server1': 'test_value_22',
- 'ipv6_dns_server2': 'test_value_23',
- 'ipv6_exclusive_routing': 'enable',
- 'ipv6_service_restriction': 'enable',
- 'ipv6_split_tunneling': 'enable',
- 'ipv6_tunnel_mode': 'enable',
- 'ipv6_wins_server1': 'test_value_28',
- 'ipv6_wins_server2': 'test_value_29',
- 'keep_alive': 'enable',
- 'limit_user_logins': 'enable',
- 'mac_addr_action': 'allow',
- 'mac_addr_check': 'enable',
- 'macos_forticlient_download_url': 'test_value_34',
- 'name': 'default_name_35',
- 'os_check': 'enable',
- 'redir_url': 'test_value_37',
- 'save_password': 'enable',
- 'service_restriction': 'enable',
- 'skip_check_for_unsupported_browser': 'enable',
- 'skip_check_for_unsupported_os': 'enable',
- 'smb_ntlmv1_auth': 'enable',
- 'smbv1': 'enable',
- 'split_tunneling': 'enable',
- 'theme': 'blue',
- 'tunnel_mode': 'enable',
- 'user_bookmark': 'enable',
- 'user_group_bookmark': 'enable',
- 'web_mode': 'enable',
- 'windows_forticlient_download_url': 'test_value_50',
- 'wins_server1': 'test_value_51',
- 'wins_server2': 'test_value_52'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_portal.fortios_vpn_ssl_web(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ssl.web', 'portal', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ssl_web_portal_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ssl_web_portal': {
- 'allow_user_access': 'web',
- 'auto_connect': 'enable',
- 'custom_lang': 'test_value_5',
- 'customize_forticlient_download_url': 'enable',
- 'display_bookmark': 'enable',
- 'display_connection_tools': 'enable',
- 'display_history': 'enable',
- 'display_status': 'enable',
- 'dns_server1': 'test_value_11',
- 'dns_server2': 'test_value_12',
- 'dns_suffix': 'test_value_13',
- 'exclusive_routing': 'enable',
- 'forticlient_download': 'enable',
- 'forticlient_download_method': 'direct',
- 'heading': 'test_value_17',
- 'hide_sso_credential': 'enable',
- 'host_check': 'none',
- 'host_check_interval': '20',
- 'ip_mode': 'range',
- 'ipv6_dns_server1': 'test_value_22',
- 'ipv6_dns_server2': 'test_value_23',
- 'ipv6_exclusive_routing': 'enable',
- 'ipv6_service_restriction': 'enable',
- 'ipv6_split_tunneling': 'enable',
- 'ipv6_tunnel_mode': 'enable',
- 'ipv6_wins_server1': 'test_value_28',
- 'ipv6_wins_server2': 'test_value_29',
- 'keep_alive': 'enable',
- 'limit_user_logins': 'enable',
- 'mac_addr_action': 'allow',
- 'mac_addr_check': 'enable',
- 'macos_forticlient_download_url': 'test_value_34',
- 'name': 'default_name_35',
- 'os_check': 'enable',
- 'redir_url': 'test_value_37',
- 'save_password': 'enable',
- 'service_restriction': 'enable',
- 'skip_check_for_unsupported_browser': 'enable',
- 'skip_check_for_unsupported_os': 'enable',
- 'smb_ntlmv1_auth': 'enable',
- 'smbv1': 'enable',
- 'split_tunneling': 'enable',
- 'theme': 'blue',
- 'tunnel_mode': 'enable',
- 'user_bookmark': 'enable',
- 'user_group_bookmark': 'enable',
- 'web_mode': 'enable',
- 'windows_forticlient_download_url': 'test_value_50',
- 'wins_server1': 'test_value_51',
- 'wins_server2': 'test_value_52'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_portal.fortios_vpn_ssl_web(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ssl.web', 'portal', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ssl_web_portal_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_portal': {
- 'allow_user_access': 'web',
- 'auto_connect': 'enable',
- 'custom_lang': 'test_value_5',
- 'customize_forticlient_download_url': 'enable',
- 'display_bookmark': 'enable',
- 'display_connection_tools': 'enable',
- 'display_history': 'enable',
- 'display_status': 'enable',
- 'dns_server1': 'test_value_11',
- 'dns_server2': 'test_value_12',
- 'dns_suffix': 'test_value_13',
- 'exclusive_routing': 'enable',
- 'forticlient_download': 'enable',
- 'forticlient_download_method': 'direct',
- 'heading': 'test_value_17',
- 'hide_sso_credential': 'enable',
- 'host_check': 'none',
- 'host_check_interval': '20',
- 'ip_mode': 'range',
- 'ipv6_dns_server1': 'test_value_22',
- 'ipv6_dns_server2': 'test_value_23',
- 'ipv6_exclusive_routing': 'enable',
- 'ipv6_service_restriction': 'enable',
- 'ipv6_split_tunneling': 'enable',
- 'ipv6_tunnel_mode': 'enable',
- 'ipv6_wins_server1': 'test_value_28',
- 'ipv6_wins_server2': 'test_value_29',
- 'keep_alive': 'enable',
- 'limit_user_logins': 'enable',
- 'mac_addr_action': 'allow',
- 'mac_addr_check': 'enable',
- 'macos_forticlient_download_url': 'test_value_34',
- 'name': 'default_name_35',
- 'os_check': 'enable',
- 'redir_url': 'test_value_37',
- 'save_password': 'enable',
- 'service_restriction': 'enable',
- 'skip_check_for_unsupported_browser': 'enable',
- 'skip_check_for_unsupported_os': 'enable',
- 'smb_ntlmv1_auth': 'enable',
- 'smbv1': 'enable',
- 'split_tunneling': 'enable',
- 'theme': 'blue',
- 'tunnel_mode': 'enable',
- 'user_bookmark': 'enable',
- 'user_group_bookmark': 'enable',
- 'web_mode': 'enable',
- 'windows_forticlient_download_url': 'test_value_50',
- 'wins_server1': 'test_value_51',
- 'wins_server2': 'test_value_52'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_portal.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {
- 'allow-user-access': 'web',
- 'auto-connect': 'enable',
- 'custom-lang': 'test_value_5',
- 'customize-forticlient-download-url': 'enable',
- 'display-bookmark': 'enable',
- 'display-connection-tools': 'enable',
- 'display-history': 'enable',
- 'display-status': 'enable',
- 'dns-server1': 'test_value_11',
- 'dns-server2': 'test_value_12',
- 'dns-suffix': 'test_value_13',
- 'exclusive-routing': 'enable',
- 'forticlient-download': 'enable',
- 'forticlient-download-method': 'direct',
- 'heading': 'test_value_17',
- 'hide-sso-credential': 'enable',
- 'host-check': 'none',
- 'host-check-interval': '20',
- 'ip-mode': 'range',
- 'ipv6-dns-server1': 'test_value_22',
- 'ipv6-dns-server2': 'test_value_23',
- 'ipv6-exclusive-routing': 'enable',
- 'ipv6-service-restriction': 'enable',
- 'ipv6-split-tunneling': 'enable',
- 'ipv6-tunnel-mode': 'enable',
- 'ipv6-wins-server1': 'test_value_28',
- 'ipv6-wins-server2': 'test_value_29',
- 'keep-alive': 'enable',
- 'limit-user-logins': 'enable',
- 'mac-addr-action': 'allow',
- 'mac-addr-check': 'enable',
- 'macos-forticlient-download-url': 'test_value_34',
- 'name': 'default_name_35',
- 'os-check': 'enable',
- 'redir-url': 'test_value_37',
- 'save-password': 'enable',
- 'service-restriction': 'enable',
- 'skip-check-for-unsupported-browser': 'enable',
- 'skip-check-for-unsupported-os': 'enable',
- 'smb-ntlmv1-auth': 'enable',
- 'smbv1': 'enable',
- 'split-tunneling': 'enable',
- 'theme': 'blue',
- 'tunnel-mode': 'enable',
- 'user-bookmark': 'enable',
- 'user-group-bookmark': 'enable',
- 'web-mode': 'enable',
- 'windows-forticlient-download-url': 'test_value_50',
- 'wins-server1': 'test_value_51',
- 'wins-server2': 'test_value_52'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ssl_web_portal_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_portal': {
- 'random_attribute_not_valid': 'tag',
- 'allow_user_access': 'web',
- 'auto_connect': 'enable',
- 'custom_lang': 'test_value_5',
- 'customize_forticlient_download_url': 'enable',
- 'display_bookmark': 'enable',
- 'display_connection_tools': 'enable',
- 'display_history': 'enable',
- 'display_status': 'enable',
- 'dns_server1': 'test_value_11',
- 'dns_server2': 'test_value_12',
- 'dns_suffix': 'test_value_13',
- 'exclusive_routing': 'enable',
- 'forticlient_download': 'enable',
- 'forticlient_download_method': 'direct',
- 'heading': 'test_value_17',
- 'hide_sso_credential': 'enable',
- 'host_check': 'none',
- 'host_check_interval': '20',
- 'ip_mode': 'range',
- 'ipv6_dns_server1': 'test_value_22',
- 'ipv6_dns_server2': 'test_value_23',
- 'ipv6_exclusive_routing': 'enable',
- 'ipv6_service_restriction': 'enable',
- 'ipv6_split_tunneling': 'enable',
- 'ipv6_tunnel_mode': 'enable',
- 'ipv6_wins_server1': 'test_value_28',
- 'ipv6_wins_server2': 'test_value_29',
- 'keep_alive': 'enable',
- 'limit_user_logins': 'enable',
- 'mac_addr_action': 'allow',
- 'mac_addr_check': 'enable',
- 'macos_forticlient_download_url': 'test_value_34',
- 'name': 'default_name_35',
- 'os_check': 'enable',
- 'redir_url': 'test_value_37',
- 'save_password': 'enable',
- 'service_restriction': 'enable',
- 'skip_check_for_unsupported_browser': 'enable',
- 'skip_check_for_unsupported_os': 'enable',
- 'smb_ntlmv1_auth': 'enable',
- 'smbv1': 'enable',
- 'split_tunneling': 'enable',
- 'theme': 'blue',
- 'tunnel_mode': 'enable',
- 'user_bookmark': 'enable',
- 'user_group_bookmark': 'enable',
- 'web_mode': 'enable',
- 'windows_forticlient_download_url': 'test_value_50',
- 'wins_server1': 'test_value_51',
- 'wins_server2': 'test_value_52'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_portal.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {
- 'allow-user-access': 'web',
- 'auto-connect': 'enable',
- 'custom-lang': 'test_value_5',
- 'customize-forticlient-download-url': 'enable',
- 'display-bookmark': 'enable',
- 'display-connection-tools': 'enable',
- 'display-history': 'enable',
- 'display-status': 'enable',
- 'dns-server1': 'test_value_11',
- 'dns-server2': 'test_value_12',
- 'dns-suffix': 'test_value_13',
- 'exclusive-routing': 'enable',
- 'forticlient-download': 'enable',
- 'forticlient-download-method': 'direct',
- 'heading': 'test_value_17',
- 'hide-sso-credential': 'enable',
- 'host-check': 'none',
- 'host-check-interval': '20',
- 'ip-mode': 'range',
- 'ipv6-dns-server1': 'test_value_22',
- 'ipv6-dns-server2': 'test_value_23',
- 'ipv6-exclusive-routing': 'enable',
- 'ipv6-service-restriction': 'enable',
- 'ipv6-split-tunneling': 'enable',
- 'ipv6-tunnel-mode': 'enable',
- 'ipv6-wins-server1': 'test_value_28',
- 'ipv6-wins-server2': 'test_value_29',
- 'keep-alive': 'enable',
- 'limit-user-logins': 'enable',
- 'mac-addr-action': 'allow',
- 'mac-addr-check': 'enable',
- 'macos-forticlient-download-url': 'test_value_34',
- 'name': 'default_name_35',
- 'os-check': 'enable',
- 'redir-url': 'test_value_37',
- 'save-password': 'enable',
- 'service-restriction': 'enable',
- 'skip-check-for-unsupported-browser': 'enable',
- 'skip-check-for-unsupported-os': 'enable',
- 'smb-ntlmv1-auth': 'enable',
- 'smbv1': 'enable',
- 'split-tunneling': 'enable',
- 'theme': 'blue',
- 'tunnel-mode': 'enable',
- 'user-bookmark': 'enable',
- 'user-group-bookmark': 'enable',
- 'web-mode': 'enable',
- 'windows-forticlient-download-url': 'test_value_50',
- 'wins-server1': 'test_value_51',
- 'wins-server2': 'test_value_52'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'portal', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_realm.py b/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_realm.py
deleted file mode 100644
index bc254f4b5d..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_realm.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ssl_web_realm
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ssl_web_realm.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ssl_web_realm_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_realm': {
- 'login_page': 'test_value_3',
- 'max_concurrent_user': '4',
- 'url_path': 'test_value_5',
- 'virtual_host': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_realm.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {
- 'login-page': 'test_value_3',
- 'max-concurrent-user': '4',
- 'url-path': 'test_value_5',
- 'virtual-host': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'realm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ssl_web_realm_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_realm': {
- 'login_page': 'test_value_3',
- 'max_concurrent_user': '4',
- 'url_path': 'test_value_5',
- 'virtual_host': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_realm.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {
- 'login-page': 'test_value_3',
- 'max-concurrent-user': '4',
- 'url-path': 'test_value_5',
- 'virtual-host': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'realm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ssl_web_realm_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ssl_web_realm': {
- 'login_page': 'test_value_3',
- 'max_concurrent_user': '4',
- 'url_path': 'test_value_5',
- 'virtual_host': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_realm.fortios_vpn_ssl_web(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ssl.web', 'realm', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ssl_web_realm_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ssl_web_realm': {
- 'login_page': 'test_value_3',
- 'max_concurrent_user': '4',
- 'url_path': 'test_value_5',
- 'virtual_host': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_realm.fortios_vpn_ssl_web(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ssl.web', 'realm', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ssl_web_realm_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_realm': {
- 'login_page': 'test_value_3',
- 'max_concurrent_user': '4',
- 'url_path': 'test_value_5',
- 'virtual_host': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_realm.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {
- 'login-page': 'test_value_3',
- 'max-concurrent-user': '4',
- 'url-path': 'test_value_5',
- 'virtual-host': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'realm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ssl_web_realm_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_realm': {
- 'random_attribute_not_valid': 'tag',
- 'login_page': 'test_value_3',
- 'max_concurrent_user': '4',
- 'url_path': 'test_value_5',
- 'virtual_host': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_realm.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {
- 'login-page': 'test_value_3',
- 'max-concurrent-user': '4',
- 'url-path': 'test_value_5',
- 'virtual-host': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'realm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_user_bookmark.py b/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_user_bookmark.py
deleted file mode 100644
index 072492463c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_user_bookmark.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ssl_web_user_bookmark
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ssl_web_user_bookmark.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ssl_web_user_bookmark_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_user_bookmark': {'custom_lang': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'custom-lang': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'user-bookmark', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ssl_web_user_bookmark_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_user_bookmark': {'custom_lang': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'custom-lang': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'user-bookmark', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ssl_web_user_bookmark_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ssl_web_user_bookmark': {'custom_lang': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ssl.web', 'user-bookmark', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ssl_web_user_bookmark_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ssl_web_user_bookmark': {'custom_lang': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ssl.web', 'user-bookmark', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ssl_web_user_bookmark_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_user_bookmark': {'custom_lang': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'custom-lang': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'user-bookmark', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ssl_web_user_bookmark_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_user_bookmark': {
- 'random_attribute_not_valid': 'tag', 'custom_lang': 'test_value_3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'custom-lang': 'test_value_3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'user-bookmark', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_user_group_bookmark.py b/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_user_group_bookmark.py
deleted file mode 100644
index 9697256593..0000000000
--- a/test/units/modules/network/fortios/test_fortios_vpn_ssl_web_user_group_bookmark.py
+++ /dev/null
@@ -1,189 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_vpn_ssl_web_user_group_bookmark
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_vpn_ssl_web_user_group_bookmark.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_vpn_ssl_web_user_group_bookmark_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_user_group_bookmark': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_group_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'user-group-bookmark', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ssl_web_user_group_bookmark_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_user_group_bookmark': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_group_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'user-group-bookmark', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ssl_web_user_group_bookmark_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ssl_web_user_group_bookmark': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_group_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ssl.web', 'user-group-bookmark', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_vpn_ssl_web_user_group_bookmark_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'vpn_ssl_web_user_group_bookmark': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_group_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('vpn.ssl.web', 'user-group-bookmark', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_vpn_ssl_web_user_group_bookmark_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_user_group_bookmark': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_group_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'user-group-bookmark', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_vpn_ssl_web_user_group_bookmark_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'vpn_ssl_web_user_group_bookmark': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_vpn_ssl_web_user_group_bookmark.fortios_vpn_ssl_web(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('vpn.ssl.web', 'user-group-bookmark', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_waf_main_class.py b/test/units/modules/network/fortios/test_fortios_waf_main_class.py
deleted file mode 100644
index 7bacc32027..0000000000
--- a/test/units/modules/network/fortios/test_fortios_waf_main_class.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_waf_main_class
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_waf_main_class.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_waf_main_class_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_main_class': {
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_main_class.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('waf', 'main-class', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_waf_main_class_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_main_class': {
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_main_class.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('waf', 'main-class', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_waf_main_class_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'waf_main_class': {
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_main_class.fortios_waf(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('waf', 'main-class', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_waf_main_class_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'waf_main_class': {
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_main_class.fortios_waf(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('waf', 'main-class', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_waf_main_class_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_main_class': {
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_main_class.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('waf', 'main-class', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_waf_main_class_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_main_class': {
- 'random_attribute_not_valid': 'tag',
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_main_class.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('waf', 'main-class', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_waf_profile.py b/test/units/modules/network/fortios/test_fortios_waf_profile.py
deleted file mode 100644
index c31da79551..0000000000
--- a/test/units/modules/network/fortios/test_fortios_waf_profile.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_waf_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_waf_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_waf_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_profile': {'comment': 'Comment.',
- 'extended_log': 'enable',
- 'external': 'disable',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_profile.fortios_waf(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment.',
- 'extended-log': 'enable',
- 'external': 'disable',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('waf', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_waf_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_profile': {'comment': 'Comment.',
- 'extended_log': 'enable',
- 'external': 'disable',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_profile.fortios_waf(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment.',
- 'extended-log': 'enable',
- 'external': 'disable',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('waf', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_waf_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'waf_profile': {'comment': 'Comment.',
- 'extended_log': 'enable',
- 'external': 'disable',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_profile.fortios_waf(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('waf', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_waf_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'waf_profile': {'comment': 'Comment.',
- 'extended_log': 'enable',
- 'external': 'disable',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_profile.fortios_waf(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('waf', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_waf_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_profile': {'comment': 'Comment.',
- 'extended_log': 'enable',
- 'external': 'disable',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_profile.fortios_waf(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment.',
- 'extended-log': 'enable',
- 'external': 'disable',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('waf', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_waf_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_profile': {
- 'random_attribute_not_valid': 'tag', 'comment': 'Comment.',
- 'extended_log': 'enable',
- 'external': 'disable',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_profile.fortios_waf(input_data, fos_instance)
-
- expected_data = {'comment': 'Comment.',
- 'extended-log': 'enable',
- 'external': 'disable',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('waf', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_waf_signature.py b/test/units/modules/network/fortios/test_fortios_waf_signature.py
deleted file mode 100644
index 2dfefd2626..0000000000
--- a/test/units/modules/network/fortios/test_fortios_waf_signature.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_waf_signature
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_waf_signature.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_waf_signature_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_signature': {
- 'desc': 'test_value_3',
- 'id': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_signature.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'desc': 'test_value_3',
- 'id': '4'
- }
-
- set_method_mock.assert_called_with('waf', 'signature', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_waf_signature_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_signature': {
- 'desc': 'test_value_3',
- 'id': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_signature.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'desc': 'test_value_3',
- 'id': '4'
- }
-
- set_method_mock.assert_called_with('waf', 'signature', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_waf_signature_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'waf_signature': {
- 'desc': 'test_value_3',
- 'id': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_signature.fortios_waf(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('waf', 'signature', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_waf_signature_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'waf_signature': {
- 'desc': 'test_value_3',
- 'id': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_signature.fortios_waf(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('waf', 'signature', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_waf_signature_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_signature': {
- 'desc': 'test_value_3',
- 'id': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_signature.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'desc': 'test_value_3',
- 'id': '4'
- }
-
- set_method_mock.assert_called_with('waf', 'signature', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_waf_signature_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_signature': {
- 'random_attribute_not_valid': 'tag',
- 'desc': 'test_value_3',
- 'id': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_signature.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'desc': 'test_value_3',
- 'id': '4'
- }
-
- set_method_mock.assert_called_with('waf', 'signature', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_waf_sub_class.py b/test/units/modules/network/fortios/test_fortios_waf_sub_class.py
deleted file mode 100644
index bb72047c24..0000000000
--- a/test/units/modules/network/fortios/test_fortios_waf_sub_class.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_waf_sub_class
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_waf_sub_class.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_waf_sub_class_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_sub_class': {
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_sub_class.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('waf', 'sub-class', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_waf_sub_class_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_sub_class': {
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_sub_class.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('waf', 'sub-class', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_waf_sub_class_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'waf_sub_class': {
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_sub_class.fortios_waf(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('waf', 'sub-class', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_waf_sub_class_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'waf_sub_class': {
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_sub_class.fortios_waf(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('waf', 'sub-class', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_waf_sub_class_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_sub_class': {
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_sub_class.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('waf', 'sub-class', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_waf_sub_class_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'waf_sub_class': {
- 'random_attribute_not_valid': 'tag',
- 'id': '3',
- 'name': 'default_name_4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_waf_sub_class.fortios_waf(input_data, fos_instance)
-
- expected_data = {
- 'id': '3',
- 'name': 'default_name_4'
- }
-
- set_method_mock.assert_called_with('waf', 'sub-class', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wanopt_auth_group.py b/test/units/modules/network/fortios/test_fortios_wanopt_auth_group.py
deleted file mode 100644
index 0347443902..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wanopt_auth_group.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wanopt_auth_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wanopt_auth_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wanopt_auth_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_auth_group': {
- 'auth_method': 'cert',
- 'cert': 'test_value_4',
- 'name': 'default_name_5',
- 'peer': 'test_value_6',
- 'peer_accept': 'any',
- 'psk': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_auth_group.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auth-method': 'cert',
- 'cert': 'test_value_4',
- 'name': 'default_name_5',
- 'peer': 'test_value_6',
- 'peer-accept': 'any',
- 'psk': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('wanopt', 'auth-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_auth_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_auth_group': {
- 'auth_method': 'cert',
- 'cert': 'test_value_4',
- 'name': 'default_name_5',
- 'peer': 'test_value_6',
- 'peer_accept': 'any',
- 'psk': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_auth_group.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auth-method': 'cert',
- 'cert': 'test_value_4',
- 'name': 'default_name_5',
- 'peer': 'test_value_6',
- 'peer-accept': 'any',
- 'psk': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('wanopt', 'auth-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_auth_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wanopt_auth_group': {
- 'auth_method': 'cert',
- 'cert': 'test_value_4',
- 'name': 'default_name_5',
- 'peer': 'test_value_6',
- 'peer_accept': 'any',
- 'psk': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_auth_group.fortios_wanopt(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wanopt', 'auth-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_auth_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wanopt_auth_group': {
- 'auth_method': 'cert',
- 'cert': 'test_value_4',
- 'name': 'default_name_5',
- 'peer': 'test_value_6',
- 'peer_accept': 'any',
- 'psk': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_auth_group.fortios_wanopt(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wanopt', 'auth-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_auth_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_auth_group': {
- 'auth_method': 'cert',
- 'cert': 'test_value_4',
- 'name': 'default_name_5',
- 'peer': 'test_value_6',
- 'peer_accept': 'any',
- 'psk': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_auth_group.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auth-method': 'cert',
- 'cert': 'test_value_4',
- 'name': 'default_name_5',
- 'peer': 'test_value_6',
- 'peer-accept': 'any',
- 'psk': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('wanopt', 'auth-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wanopt_auth_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_auth_group': {
- 'random_attribute_not_valid': 'tag',
- 'auth_method': 'cert',
- 'cert': 'test_value_4',
- 'name': 'default_name_5',
- 'peer': 'test_value_6',
- 'peer_accept': 'any',
- 'psk': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_auth_group.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auth-method': 'cert',
- 'cert': 'test_value_4',
- 'name': 'default_name_5',
- 'peer': 'test_value_6',
- 'peer-accept': 'any',
- 'psk': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('wanopt', 'auth-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wanopt_cache_service.py b/test/units/modules/network/fortios/test_fortios_wanopt_cache_service.py
deleted file mode 100644
index b95db689f0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wanopt_cache_service.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wanopt_cache_service
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wanopt_cache_service.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wanopt_cache_service_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_cache_service': {
- 'acceptable_connections': 'any',
- 'collaboration': 'enable',
- 'device_id': 'test_value_5',
- 'prefer_scenario': 'balance',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_cache_service.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'acceptable-connections': 'any',
- 'collaboration': 'enable',
- 'device-id': 'test_value_5',
- 'prefer-scenario': 'balance',
-
- }
-
- set_method_mock.assert_called_with('wanopt', 'cache-service', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_cache_service_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_cache_service': {
- 'acceptable_connections': 'any',
- 'collaboration': 'enable',
- 'device_id': 'test_value_5',
- 'prefer_scenario': 'balance',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_cache_service.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'acceptable-connections': 'any',
- 'collaboration': 'enable',
- 'device-id': 'test_value_5',
- 'prefer-scenario': 'balance',
-
- }
-
- set_method_mock.assert_called_with('wanopt', 'cache-service', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_cache_service_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_cache_service': {
- 'acceptable_connections': 'any',
- 'collaboration': 'enable',
- 'device_id': 'test_value_5',
- 'prefer_scenario': 'balance',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_cache_service.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'acceptable-connections': 'any',
- 'collaboration': 'enable',
- 'device-id': 'test_value_5',
- 'prefer-scenario': 'balance',
-
- }
-
- set_method_mock.assert_called_with('wanopt', 'cache-service', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wanopt_cache_service_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_cache_service': {
- 'random_attribute_not_valid': 'tag',
- 'acceptable_connections': 'any',
- 'collaboration': 'enable',
- 'device_id': 'test_value_5',
- 'prefer_scenario': 'balance',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_cache_service.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'acceptable-connections': 'any',
- 'collaboration': 'enable',
- 'device-id': 'test_value_5',
- 'prefer-scenario': 'balance',
-
- }
-
- set_method_mock.assert_called_with('wanopt', 'cache-service', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wanopt_content_delivery_network_rule.py b/test/units/modules/network/fortios/test_fortios_wanopt_content_delivery_network_rule.py
deleted file mode 100644
index 7d444104f9..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wanopt_content_delivery_network_rule.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wanopt_content_delivery_network_rule
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wanopt_content_delivery_network_rule.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wanopt_content_delivery_network_rule_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_content_delivery_network_rule': {
- 'category': 'vcache',
- 'comment': 'Comment about this CDN-rule.',
- 'name': 'default_name_5',
- 'request_cache_control': 'enable',
- 'response_cache_control': 'enable',
- 'response_expires': 'enable',
- 'status': 'enable',
- 'text_response_vcache': 'enable',
- 'updateserver': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_content_delivery_network_rule.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'category': 'vcache',
- 'comment': 'Comment about this CDN-rule.',
- 'name': 'default_name_5',
- 'request-cache-control': 'enable',
- 'response-cache-control': 'enable',
- 'response-expires': 'enable',
- 'status': 'enable',
- 'text-response-vcache': 'enable',
- 'updateserver': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'content-delivery-network-rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_content_delivery_network_rule_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_content_delivery_network_rule': {
- 'category': 'vcache',
- 'comment': 'Comment about this CDN-rule.',
- 'name': 'default_name_5',
- 'request_cache_control': 'enable',
- 'response_cache_control': 'enable',
- 'response_expires': 'enable',
- 'status': 'enable',
- 'text_response_vcache': 'enable',
- 'updateserver': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_content_delivery_network_rule.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'category': 'vcache',
- 'comment': 'Comment about this CDN-rule.',
- 'name': 'default_name_5',
- 'request-cache-control': 'enable',
- 'response-cache-control': 'enable',
- 'response-expires': 'enable',
- 'status': 'enable',
- 'text-response-vcache': 'enable',
- 'updateserver': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'content-delivery-network-rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_content_delivery_network_rule_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wanopt_content_delivery_network_rule': {
- 'category': 'vcache',
- 'comment': 'Comment about this CDN-rule.',
- 'name': 'default_name_5',
- 'request_cache_control': 'enable',
- 'response_cache_control': 'enable',
- 'response_expires': 'enable',
- 'status': 'enable',
- 'text_response_vcache': 'enable',
- 'updateserver': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_content_delivery_network_rule.fortios_wanopt(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wanopt', 'content-delivery-network-rule', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_content_delivery_network_rule_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wanopt_content_delivery_network_rule': {
- 'category': 'vcache',
- 'comment': 'Comment about this CDN-rule.',
- 'name': 'default_name_5',
- 'request_cache_control': 'enable',
- 'response_cache_control': 'enable',
- 'response_expires': 'enable',
- 'status': 'enable',
- 'text_response_vcache': 'enable',
- 'updateserver': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_content_delivery_network_rule.fortios_wanopt(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wanopt', 'content-delivery-network-rule', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_content_delivery_network_rule_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_content_delivery_network_rule': {
- 'category': 'vcache',
- 'comment': 'Comment about this CDN-rule.',
- 'name': 'default_name_5',
- 'request_cache_control': 'enable',
- 'response_cache_control': 'enable',
- 'response_expires': 'enable',
- 'status': 'enable',
- 'text_response_vcache': 'enable',
- 'updateserver': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_content_delivery_network_rule.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'category': 'vcache',
- 'comment': 'Comment about this CDN-rule.',
- 'name': 'default_name_5',
- 'request-cache-control': 'enable',
- 'response-cache-control': 'enable',
- 'response-expires': 'enable',
- 'status': 'enable',
- 'text-response-vcache': 'enable',
- 'updateserver': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'content-delivery-network-rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wanopt_content_delivery_network_rule_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_content_delivery_network_rule': {
- 'random_attribute_not_valid': 'tag',
- 'category': 'vcache',
- 'comment': 'Comment about this CDN-rule.',
- 'name': 'default_name_5',
- 'request_cache_control': 'enable',
- 'response_cache_control': 'enable',
- 'response_expires': 'enable',
- 'status': 'enable',
- 'text_response_vcache': 'enable',
- 'updateserver': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_content_delivery_network_rule.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'category': 'vcache',
- 'comment': 'Comment about this CDN-rule.',
- 'name': 'default_name_5',
- 'request-cache-control': 'enable',
- 'response-cache-control': 'enable',
- 'response-expires': 'enable',
- 'status': 'enable',
- 'text-response-vcache': 'enable',
- 'updateserver': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'content-delivery-network-rule', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wanopt_peer.py b/test/units/modules/network/fortios/test_fortios_wanopt_peer.py
deleted file mode 100644
index e247137dc8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wanopt_peer.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wanopt_peer
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wanopt_peer.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wanopt_peer_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_peer': {
- 'ip': 'test_value_3',
- 'peer_host_id': 'myhostname4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_peer.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'ip': 'test_value_3',
- 'peer-host-id': 'myhostname4'
- }
-
- set_method_mock.assert_called_with('wanopt', 'peer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_peer_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_peer': {
- 'ip': 'test_value_3',
- 'peer_host_id': 'myhostname4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_peer.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'ip': 'test_value_3',
- 'peer-host-id': 'myhostname4'
- }
-
- set_method_mock.assert_called_with('wanopt', 'peer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_peer_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wanopt_peer': {
- 'ip': 'test_value_3',
- 'peer_host_id': 'myhostname4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_peer.fortios_wanopt(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wanopt', 'peer', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_peer_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wanopt_peer': {
- 'ip': 'test_value_3',
- 'peer_host_id': 'myhostname4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_peer.fortios_wanopt(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wanopt', 'peer', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_peer_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_peer': {
- 'ip': 'test_value_3',
- 'peer_host_id': 'myhostname4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_peer.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'ip': 'test_value_3',
- 'peer-host-id': 'myhostname4'
- }
-
- set_method_mock.assert_called_with('wanopt', 'peer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wanopt_peer_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_peer': {
- 'random_attribute_not_valid': 'tag',
- 'ip': 'test_value_3',
- 'peer_host_id': 'myhostname4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_peer.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'ip': 'test_value_3',
- 'peer-host-id': 'myhostname4'
- }
-
- set_method_mock.assert_called_with('wanopt', 'peer', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wanopt_profile.py b/test/units/modules/network/fortios/test_fortios_wanopt_profile.py
deleted file mode 100644
index 7d149512e8..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wanopt_profile.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wanopt_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wanopt_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wanopt_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_profile': {
- 'auth_group': 'test_value_3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'transparent': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_profile.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auth-group': 'test_value_3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'transparent': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_profile': {
- 'auth_group': 'test_value_3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'transparent': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_profile.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auth-group': 'test_value_3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'transparent': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wanopt_profile': {
- 'auth_group': 'test_value_3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'transparent': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_profile.fortios_wanopt(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wanopt', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wanopt_profile': {
- 'auth_group': 'test_value_3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'transparent': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_profile.fortios_wanopt(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wanopt', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_profile': {
- 'auth_group': 'test_value_3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'transparent': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_profile.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auth-group': 'test_value_3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'transparent': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wanopt_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_profile': {
- 'random_attribute_not_valid': 'tag',
- 'auth_group': 'test_value_3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'transparent': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_profile.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auth-group': 'test_value_3',
- 'comments': 'test_value_4',
- 'name': 'default_name_5',
- 'transparent': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wanopt_remote_storage.py b/test/units/modules/network/fortios/test_fortios_wanopt_remote_storage.py
deleted file mode 100644
index 004bf8c551..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wanopt_remote_storage.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wanopt_remote_storage
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wanopt_remote_storage.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wanopt_remote_storage_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_remote_storage': {
- 'local_cache_id': 'test_value_3',
- 'remote_cache_id': 'test_value_4',
- 'remote_cache_ip': 'test_value_5',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_remote_storage.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'local-cache-id': 'test_value_3',
- 'remote-cache-id': 'test_value_4',
- 'remote-cache-ip': 'test_value_5',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'remote-storage', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_remote_storage_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_remote_storage': {
- 'local_cache_id': 'test_value_3',
- 'remote_cache_id': 'test_value_4',
- 'remote_cache_ip': 'test_value_5',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_remote_storage.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'local-cache-id': 'test_value_3',
- 'remote-cache-id': 'test_value_4',
- 'remote-cache-ip': 'test_value_5',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'remote-storage', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_remote_storage_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_remote_storage': {
- 'local_cache_id': 'test_value_3',
- 'remote_cache_id': 'test_value_4',
- 'remote_cache_ip': 'test_value_5',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_remote_storage.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'local-cache-id': 'test_value_3',
- 'remote-cache-id': 'test_value_4',
- 'remote-cache-ip': 'test_value_5',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'remote-storage', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wanopt_remote_storage_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_remote_storage': {
- 'random_attribute_not_valid': 'tag',
- 'local_cache_id': 'test_value_3',
- 'remote_cache_id': 'test_value_4',
- 'remote_cache_ip': 'test_value_5',
- 'status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_remote_storage.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'local-cache-id': 'test_value_3',
- 'remote-cache-id': 'test_value_4',
- 'remote-cache-ip': 'test_value_5',
- 'status': 'disable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'remote-storage', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wanopt_settings.py b/test/units/modules/network/fortios/test_fortios_wanopt_settings.py
deleted file mode 100644
index fc61a2eeea..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wanopt_settings.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wanopt_settings
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wanopt_settings.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wanopt_settings_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_settings': {
- 'auto_detect_algorithm': 'simple',
- 'host_id': 'myhostname4',
- 'tunnel_ssl_algorithm': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_settings.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auto-detect-algorithm': 'simple',
- 'host-id': 'myhostname4',
- 'tunnel-ssl-algorithm': 'low'
- }
-
- set_method_mock.assert_called_with('wanopt', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_settings_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_settings': {
- 'auto_detect_algorithm': 'simple',
- 'host_id': 'myhostname4',
- 'tunnel_ssl_algorithm': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_settings.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auto-detect-algorithm': 'simple',
- 'host-id': 'myhostname4',
- 'tunnel-ssl-algorithm': 'low'
- }
-
- set_method_mock.assert_called_with('wanopt', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_settings_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_settings': {
- 'auto_detect_algorithm': 'simple',
- 'host_id': 'myhostname4',
- 'tunnel_ssl_algorithm': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_settings.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auto-detect-algorithm': 'simple',
- 'host-id': 'myhostname4',
- 'tunnel-ssl-algorithm': 'low'
- }
-
- set_method_mock.assert_called_with('wanopt', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wanopt_settings_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_settings': {
- 'random_attribute_not_valid': 'tag',
- 'auto_detect_algorithm': 'simple',
- 'host_id': 'myhostname4',
- 'tunnel_ssl_algorithm': 'low'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_settings.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'auto-detect-algorithm': 'simple',
- 'host-id': 'myhostname4',
- 'tunnel-ssl-algorithm': 'low'
- }
-
- set_method_mock.assert_called_with('wanopt', 'settings', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wanopt_webcache.py b/test/units/modules/network/fortios/test_fortios_wanopt_webcache.py
deleted file mode 100644
index c2b4e421fe..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wanopt_webcache.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wanopt_webcache
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wanopt_webcache.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wanopt_webcache_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_webcache': {
- 'always_revalidate': 'enable',
- 'cache_by_default': 'enable',
- 'cache_cookie': 'enable',
- 'cache_expired': 'enable',
- 'default_ttl': '7',
- 'external': 'enable',
- 'fresh_factor': '9',
- 'host_validate': 'enable',
- 'ignore_conditional': 'enable',
- 'ignore_ie_reload': 'enable',
- 'ignore_ims': 'enable',
- 'ignore_pnc': 'enable',
- 'max_object_size': '15',
- 'max_ttl': '16',
- 'min_ttl': '17',
- 'neg_resp_time': '18',
- 'reval_pnc': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_webcache.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'always-revalidate': 'enable',
- 'cache-by-default': 'enable',
- 'cache-cookie': 'enable',
- 'cache-expired': 'enable',
- 'default-ttl': '7',
- 'external': 'enable',
- 'fresh-factor': '9',
- 'host-validate': 'enable',
- 'ignore-conditional': 'enable',
- 'ignore-ie-reload': 'enable',
- 'ignore-ims': 'enable',
- 'ignore-pnc': 'enable',
- 'max-object-size': '15',
- 'max-ttl': '16',
- 'min-ttl': '17',
- 'neg-resp-time': '18',
- 'reval-pnc': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'webcache', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wanopt_webcache_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_webcache': {
- 'always_revalidate': 'enable',
- 'cache_by_default': 'enable',
- 'cache_cookie': 'enable',
- 'cache_expired': 'enable',
- 'default_ttl': '7',
- 'external': 'enable',
- 'fresh_factor': '9',
- 'host_validate': 'enable',
- 'ignore_conditional': 'enable',
- 'ignore_ie_reload': 'enable',
- 'ignore_ims': 'enable',
- 'ignore_pnc': 'enable',
- 'max_object_size': '15',
- 'max_ttl': '16',
- 'min_ttl': '17',
- 'neg_resp_time': '18',
- 'reval_pnc': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_webcache.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'always-revalidate': 'enable',
- 'cache-by-default': 'enable',
- 'cache-cookie': 'enable',
- 'cache-expired': 'enable',
- 'default-ttl': '7',
- 'external': 'enable',
- 'fresh-factor': '9',
- 'host-validate': 'enable',
- 'ignore-conditional': 'enable',
- 'ignore-ie-reload': 'enable',
- 'ignore-ims': 'enable',
- 'ignore-pnc': 'enable',
- 'max-object-size': '15',
- 'max-ttl': '16',
- 'min-ttl': '17',
- 'neg-resp-time': '18',
- 'reval-pnc': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'webcache', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wanopt_webcache_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_webcache': {
- 'always_revalidate': 'enable',
- 'cache_by_default': 'enable',
- 'cache_cookie': 'enable',
- 'cache_expired': 'enable',
- 'default_ttl': '7',
- 'external': 'enable',
- 'fresh_factor': '9',
- 'host_validate': 'enable',
- 'ignore_conditional': 'enable',
- 'ignore_ie_reload': 'enable',
- 'ignore_ims': 'enable',
- 'ignore_pnc': 'enable',
- 'max_object_size': '15',
- 'max_ttl': '16',
- 'min_ttl': '17',
- 'neg_resp_time': '18',
- 'reval_pnc': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_webcache.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'always-revalidate': 'enable',
- 'cache-by-default': 'enable',
- 'cache-cookie': 'enable',
- 'cache-expired': 'enable',
- 'default-ttl': '7',
- 'external': 'enable',
- 'fresh-factor': '9',
- 'host-validate': 'enable',
- 'ignore-conditional': 'enable',
- 'ignore-ie-reload': 'enable',
- 'ignore-ims': 'enable',
- 'ignore-pnc': 'enable',
- 'max-object-size': '15',
- 'max-ttl': '16',
- 'min-ttl': '17',
- 'neg-resp-time': '18',
- 'reval-pnc': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'webcache', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wanopt_webcache_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wanopt_webcache': {
- 'random_attribute_not_valid': 'tag',
- 'always_revalidate': 'enable',
- 'cache_by_default': 'enable',
- 'cache_cookie': 'enable',
- 'cache_expired': 'enable',
- 'default_ttl': '7',
- 'external': 'enable',
- 'fresh_factor': '9',
- 'host_validate': 'enable',
- 'ignore_conditional': 'enable',
- 'ignore_ie_reload': 'enable',
- 'ignore_ims': 'enable',
- 'ignore_pnc': 'enable',
- 'max_object_size': '15',
- 'max_ttl': '16',
- 'min_ttl': '17',
- 'neg_resp_time': '18',
- 'reval_pnc': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wanopt_webcache.fortios_wanopt(input_data, fos_instance)
-
- expected_data = {
- 'always-revalidate': 'enable',
- 'cache-by-default': 'enable',
- 'cache-cookie': 'enable',
- 'cache-expired': 'enable',
- 'default-ttl': '7',
- 'external': 'enable',
- 'fresh-factor': '9',
- 'host-validate': 'enable',
- 'ignore-conditional': 'enable',
- 'ignore-ie-reload': 'enable',
- 'ignore-ims': 'enable',
- 'ignore-pnc': 'enable',
- 'max-object-size': '15',
- 'max-ttl': '16',
- 'min-ttl': '17',
- 'neg-resp-time': '18',
- 'reval-pnc': 'enable'
- }
-
- set_method_mock.assert_called_with('wanopt', 'webcache', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_web_proxy_debug_url.py b/test/units/modules/network/fortios/test_fortios_web_proxy_debug_url.py
deleted file mode 100644
index 75247b23a9..0000000000
--- a/test/units/modules/network/fortios/test_fortios_web_proxy_debug_url.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_web_proxy_debug_url
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_web_proxy_debug_url.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_web_proxy_debug_url_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_debug_url': {
- 'exact': 'enable',
- 'name': 'default_name_4',
- 'status': 'enable',
- 'url_pattern': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_debug_url.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'exact': 'enable',
- 'name': 'default_name_4',
- 'status': 'enable',
- 'url-pattern': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'debug-url', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_debug_url_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_debug_url': {
- 'exact': 'enable',
- 'name': 'default_name_4',
- 'status': 'enable',
- 'url_pattern': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_debug_url.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'exact': 'enable',
- 'name': 'default_name_4',
- 'status': 'enable',
- 'url-pattern': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'debug-url', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_debug_url_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_debug_url': {
- 'exact': 'enable',
- 'name': 'default_name_4',
- 'status': 'enable',
- 'url_pattern': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_debug_url.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'debug-url', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_debug_url_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_debug_url': {
- 'exact': 'enable',
- 'name': 'default_name_4',
- 'status': 'enable',
- 'url_pattern': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_debug_url.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'debug-url', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_debug_url_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_debug_url': {
- 'exact': 'enable',
- 'name': 'default_name_4',
- 'status': 'enable',
- 'url_pattern': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_debug_url.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'exact': 'enable',
- 'name': 'default_name_4',
- 'status': 'enable',
- 'url-pattern': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'debug-url', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_web_proxy_debug_url_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_debug_url': {
- 'random_attribute_not_valid': 'tag',
- 'exact': 'enable',
- 'name': 'default_name_4',
- 'status': 'enable',
- 'url_pattern': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_debug_url.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'exact': 'enable',
- 'name': 'default_name_4',
- 'status': 'enable',
- 'url-pattern': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'debug-url', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_web_proxy_explicit.py b/test/units/modules/network/fortios/test_fortios_web_proxy_explicit.py
deleted file mode 100644
index 013fa3a52c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_web_proxy_explicit.py
+++ /dev/null
@@ -1,351 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_web_proxy_explicit
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_web_proxy_explicit.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_web_proxy_explicit_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_explicit': {
- 'ftp_incoming_port': 'test_value_3',
- 'ftp_over_http': 'enable',
- 'http_incoming_port': 'test_value_5',
- 'https_incoming_port': 'test_value_6',
- 'https_replacement_message': 'enable',
- 'incoming_ip': 'test_value_8',
- 'incoming_ip6': 'test_value_9',
- 'ipv6_status': 'enable',
- 'message_upon_server_error': 'enable',
- 'outgoing_ip': 'test_value_12',
- 'outgoing_ip6': 'test_value_13',
- 'pac_file_data': 'test_value_14',
- 'pac_file_name': 'test_value_15',
- 'pac_file_server_port': 'test_value_16',
- 'pac_file_server_status': 'enable',
- 'pac_file_url': 'test_value_18',
- 'pref_dns_result': 'ipv4',
- 'realm': 'test_value_20',
- 'sec_default_action': 'accept',
- 'socks': 'enable',
- 'socks_incoming_port': 'test_value_23',
- 'ssl_algorithm': 'low',
- 'status': 'enable',
- 'strict_guest': 'enable',
- 'trace_auth_no_rsp': 'enable',
- 'unknown_http_version': 'reject'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_explicit.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'ftp-incoming-port': 'test_value_3',
- 'ftp-over-http': 'enable',
- 'http-incoming-port': 'test_value_5',
- 'https-incoming-port': 'test_value_6',
- 'https-replacement-message': 'enable',
- 'incoming-ip': 'test_value_8',
- 'incoming-ip6': 'test_value_9',
- 'ipv6-status': 'enable',
- 'message-upon-server-error': 'enable',
- 'outgoing-ip': 'test_value_12',
- 'outgoing-ip6': 'test_value_13',
- 'pac-file-data': 'test_value_14',
- 'pac-file-name': 'test_value_15',
- 'pac-file-server-port': 'test_value_16',
- 'pac-file-server-status': 'enable',
- 'pac-file-url': 'test_value_18',
- 'pref-dns-result': 'ipv4',
- 'realm': 'test_value_20',
- 'sec-default-action': 'accept',
- 'socks': 'enable',
- 'socks-incoming-port': 'test_value_23',
- 'ssl-algorithm': 'low',
- 'status': 'enable',
- 'strict-guest': 'enable',
- 'trace-auth-no-rsp': 'enable',
- 'unknown-http-version': 'reject'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'explicit', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_explicit_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_explicit': {
- 'ftp_incoming_port': 'test_value_3',
- 'ftp_over_http': 'enable',
- 'http_incoming_port': 'test_value_5',
- 'https_incoming_port': 'test_value_6',
- 'https_replacement_message': 'enable',
- 'incoming_ip': 'test_value_8',
- 'incoming_ip6': 'test_value_9',
- 'ipv6_status': 'enable',
- 'message_upon_server_error': 'enable',
- 'outgoing_ip': 'test_value_12',
- 'outgoing_ip6': 'test_value_13',
- 'pac_file_data': 'test_value_14',
- 'pac_file_name': 'test_value_15',
- 'pac_file_server_port': 'test_value_16',
- 'pac_file_server_status': 'enable',
- 'pac_file_url': 'test_value_18',
- 'pref_dns_result': 'ipv4',
- 'realm': 'test_value_20',
- 'sec_default_action': 'accept',
- 'socks': 'enable',
- 'socks_incoming_port': 'test_value_23',
- 'ssl_algorithm': 'low',
- 'status': 'enable',
- 'strict_guest': 'enable',
- 'trace_auth_no_rsp': 'enable',
- 'unknown_http_version': 'reject'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_explicit.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'ftp-incoming-port': 'test_value_3',
- 'ftp-over-http': 'enable',
- 'http-incoming-port': 'test_value_5',
- 'https-incoming-port': 'test_value_6',
- 'https-replacement-message': 'enable',
- 'incoming-ip': 'test_value_8',
- 'incoming-ip6': 'test_value_9',
- 'ipv6-status': 'enable',
- 'message-upon-server-error': 'enable',
- 'outgoing-ip': 'test_value_12',
- 'outgoing-ip6': 'test_value_13',
- 'pac-file-data': 'test_value_14',
- 'pac-file-name': 'test_value_15',
- 'pac-file-server-port': 'test_value_16',
- 'pac-file-server-status': 'enable',
- 'pac-file-url': 'test_value_18',
- 'pref-dns-result': 'ipv4',
- 'realm': 'test_value_20',
- 'sec-default-action': 'accept',
- 'socks': 'enable',
- 'socks-incoming-port': 'test_value_23',
- 'ssl-algorithm': 'low',
- 'status': 'enable',
- 'strict-guest': 'enable',
- 'trace-auth-no-rsp': 'enable',
- 'unknown-http-version': 'reject'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'explicit', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_explicit_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_explicit': {
- 'ftp_incoming_port': 'test_value_3',
- 'ftp_over_http': 'enable',
- 'http_incoming_port': 'test_value_5',
- 'https_incoming_port': 'test_value_6',
- 'https_replacement_message': 'enable',
- 'incoming_ip': 'test_value_8',
- 'incoming_ip6': 'test_value_9',
- 'ipv6_status': 'enable',
- 'message_upon_server_error': 'enable',
- 'outgoing_ip': 'test_value_12',
- 'outgoing_ip6': 'test_value_13',
- 'pac_file_data': 'test_value_14',
- 'pac_file_name': 'test_value_15',
- 'pac_file_server_port': 'test_value_16',
- 'pac_file_server_status': 'enable',
- 'pac_file_url': 'test_value_18',
- 'pref_dns_result': 'ipv4',
- 'realm': 'test_value_20',
- 'sec_default_action': 'accept',
- 'socks': 'enable',
- 'socks_incoming_port': 'test_value_23',
- 'ssl_algorithm': 'low',
- 'status': 'enable',
- 'strict_guest': 'enable',
- 'trace_auth_no_rsp': 'enable',
- 'unknown_http_version': 'reject'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_explicit.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'ftp-incoming-port': 'test_value_3',
- 'ftp-over-http': 'enable',
- 'http-incoming-port': 'test_value_5',
- 'https-incoming-port': 'test_value_6',
- 'https-replacement-message': 'enable',
- 'incoming-ip': 'test_value_8',
- 'incoming-ip6': 'test_value_9',
- 'ipv6-status': 'enable',
- 'message-upon-server-error': 'enable',
- 'outgoing-ip': 'test_value_12',
- 'outgoing-ip6': 'test_value_13',
- 'pac-file-data': 'test_value_14',
- 'pac-file-name': 'test_value_15',
- 'pac-file-server-port': 'test_value_16',
- 'pac-file-server-status': 'enable',
- 'pac-file-url': 'test_value_18',
- 'pref-dns-result': 'ipv4',
- 'realm': 'test_value_20',
- 'sec-default-action': 'accept',
- 'socks': 'enable',
- 'socks-incoming-port': 'test_value_23',
- 'ssl-algorithm': 'low',
- 'status': 'enable',
- 'strict-guest': 'enable',
- 'trace-auth-no-rsp': 'enable',
- 'unknown-http-version': 'reject'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'explicit', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_web_proxy_explicit_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_explicit': {
- 'random_attribute_not_valid': 'tag',
- 'ftp_incoming_port': 'test_value_3',
- 'ftp_over_http': 'enable',
- 'http_incoming_port': 'test_value_5',
- 'https_incoming_port': 'test_value_6',
- 'https_replacement_message': 'enable',
- 'incoming_ip': 'test_value_8',
- 'incoming_ip6': 'test_value_9',
- 'ipv6_status': 'enable',
- 'message_upon_server_error': 'enable',
- 'outgoing_ip': 'test_value_12',
- 'outgoing_ip6': 'test_value_13',
- 'pac_file_data': 'test_value_14',
- 'pac_file_name': 'test_value_15',
- 'pac_file_server_port': 'test_value_16',
- 'pac_file_server_status': 'enable',
- 'pac_file_url': 'test_value_18',
- 'pref_dns_result': 'ipv4',
- 'realm': 'test_value_20',
- 'sec_default_action': 'accept',
- 'socks': 'enable',
- 'socks_incoming_port': 'test_value_23',
- 'ssl_algorithm': 'low',
- 'status': 'enable',
- 'strict_guest': 'enable',
- 'trace_auth_no_rsp': 'enable',
- 'unknown_http_version': 'reject'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_explicit.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'ftp-incoming-port': 'test_value_3',
- 'ftp-over-http': 'enable',
- 'http-incoming-port': 'test_value_5',
- 'https-incoming-port': 'test_value_6',
- 'https-replacement-message': 'enable',
- 'incoming-ip': 'test_value_8',
- 'incoming-ip6': 'test_value_9',
- 'ipv6-status': 'enable',
- 'message-upon-server-error': 'enable',
- 'outgoing-ip': 'test_value_12',
- 'outgoing-ip6': 'test_value_13',
- 'pac-file-data': 'test_value_14',
- 'pac-file-name': 'test_value_15',
- 'pac-file-server-port': 'test_value_16',
- 'pac-file-server-status': 'enable',
- 'pac-file-url': 'test_value_18',
- 'pref-dns-result': 'ipv4',
- 'realm': 'test_value_20',
- 'sec-default-action': 'accept',
- 'socks': 'enable',
- 'socks-incoming-port': 'test_value_23',
- 'ssl-algorithm': 'low',
- 'status': 'enable',
- 'strict-guest': 'enable',
- 'trace-auth-no-rsp': 'enable',
- 'unknown-http-version': 'reject'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'explicit', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_web_proxy_forward_server.py b/test/units/modules/network/fortios/test_fortios_web_proxy_forward_server.py
deleted file mode 100644
index 9fd70e615f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_web_proxy_forward_server.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_web_proxy_forward_server
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_web_proxy_forward_server.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_web_proxy_forward_server_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_forward_server': {
- 'addr_type': 'ip',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_5',
- 'healthcheck': 'disable',
- 'ip': 'test_value_7',
- 'monitor': 'test_value_8',
- 'name': 'default_name_9',
- 'port': '10',
- 'server_down_option': 'block'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'addr-type': 'ip',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_5',
- 'healthcheck': 'disable',
- 'ip': 'test_value_7',
- 'monitor': 'test_value_8',
- 'name': 'default_name_9',
- 'port': '10',
- 'server-down-option': 'block'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'forward-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_forward_server_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_forward_server': {
- 'addr_type': 'ip',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_5',
- 'healthcheck': 'disable',
- 'ip': 'test_value_7',
- 'monitor': 'test_value_8',
- 'name': 'default_name_9',
- 'port': '10',
- 'server_down_option': 'block'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'addr-type': 'ip',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_5',
- 'healthcheck': 'disable',
- 'ip': 'test_value_7',
- 'monitor': 'test_value_8',
- 'name': 'default_name_9',
- 'port': '10',
- 'server-down-option': 'block'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'forward-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_forward_server_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_forward_server': {
- 'addr_type': 'ip',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_5',
- 'healthcheck': 'disable',
- 'ip': 'test_value_7',
- 'monitor': 'test_value_8',
- 'name': 'default_name_9',
- 'port': '10',
- 'server_down_option': 'block'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'forward-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_forward_server_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_forward_server': {
- 'addr_type': 'ip',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_5',
- 'healthcheck': 'disable',
- 'ip': 'test_value_7',
- 'monitor': 'test_value_8',
- 'name': 'default_name_9',
- 'port': '10',
- 'server_down_option': 'block'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'forward-server', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_forward_server_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_forward_server': {
- 'addr_type': 'ip',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_5',
- 'healthcheck': 'disable',
- 'ip': 'test_value_7',
- 'monitor': 'test_value_8',
- 'name': 'default_name_9',
- 'port': '10',
- 'server_down_option': 'block'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'addr-type': 'ip',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_5',
- 'healthcheck': 'disable',
- 'ip': 'test_value_7',
- 'monitor': 'test_value_8',
- 'name': 'default_name_9',
- 'port': '10',
- 'server-down-option': 'block'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'forward-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_web_proxy_forward_server_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_forward_server': {
- 'random_attribute_not_valid': 'tag',
- 'addr_type': 'ip',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_5',
- 'healthcheck': 'disable',
- 'ip': 'test_value_7',
- 'monitor': 'test_value_8',
- 'name': 'default_name_9',
- 'port': '10',
- 'server_down_option': 'block'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'addr-type': 'ip',
- 'comment': 'Comment.',
- 'fqdn': 'test_value_5',
- 'healthcheck': 'disable',
- 'ip': 'test_value_7',
- 'monitor': 'test_value_8',
- 'name': 'default_name_9',
- 'port': '10',
- 'server-down-option': 'block'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'forward-server', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_web_proxy_forward_server_group.py b/test/units/modules/network/fortios/test_fortios_web_proxy_forward_server_group.py
deleted file mode 100644
index 21e15b88ed..0000000000
--- a/test/units/modules/network/fortios/test_fortios_web_proxy_forward_server_group.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_web_proxy_forward_server_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_web_proxy_forward_server_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_web_proxy_forward_server_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_forward_server_group': {
- 'affinity': 'enable',
- 'group_down_option': 'block',
- 'ldb_method': 'weighted',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server_group.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'affinity': 'enable',
- 'group-down-option': 'block',
- 'ldb-method': 'weighted',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('web-proxy', 'forward-server-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_forward_server_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_forward_server_group': {
- 'affinity': 'enable',
- 'group_down_option': 'block',
- 'ldb_method': 'weighted',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server_group.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'affinity': 'enable',
- 'group-down-option': 'block',
- 'ldb-method': 'weighted',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('web-proxy', 'forward-server-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_forward_server_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_forward_server_group': {
- 'affinity': 'enable',
- 'group_down_option': 'block',
- 'ldb_method': 'weighted',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server_group.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'forward-server-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_forward_server_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_forward_server_group': {
- 'affinity': 'enable',
- 'group_down_option': 'block',
- 'ldb_method': 'weighted',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server_group.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'forward-server-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_forward_server_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_forward_server_group': {
- 'affinity': 'enable',
- 'group_down_option': 'block',
- 'ldb_method': 'weighted',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server_group.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'affinity': 'enable',
- 'group-down-option': 'block',
- 'ldb-method': 'weighted',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('web-proxy', 'forward-server-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_web_proxy_forward_server_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_forward_server_group': {
- 'random_attribute_not_valid': 'tag',
- 'affinity': 'enable',
- 'group_down_option': 'block',
- 'ldb_method': 'weighted',
- 'name': 'default_name_6',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_forward_server_group.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'affinity': 'enable',
- 'group-down-option': 'block',
- 'ldb-method': 'weighted',
- 'name': 'default_name_6',
-
- }
-
- set_method_mock.assert_called_with('web-proxy', 'forward-server-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_web_proxy_global.py b/test/units/modules/network/fortios/test_fortios_web_proxy_global.py
deleted file mode 100644
index 24d4236eea..0000000000
--- a/test/units/modules/network/fortios/test_fortios_web_proxy_global.py
+++ /dev/null
@@ -1,247 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_web_proxy_global
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_web_proxy_global.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_web_proxy_global_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_global': {
- 'fast_policy_match': 'enable',
- 'forward_proxy_auth': 'enable',
- 'forward_server_affinity_timeout': '5',
- 'learn_client_ip': 'enable',
- 'learn_client_ip_from_header': 'true-client-ip',
- 'max_message_length': '8',
- 'max_request_length': '9',
- 'max_waf_body_cache_length': '10',
- 'proxy_fqdn': 'test_value_11',
- 'strict_web_check': 'enable',
- 'tunnel_non_http': 'enable',
- 'unknown_http_version': 'reject',
- 'webproxy_profile': 'test_value_15'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_global.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'fast-policy-match': 'enable',
- 'forward-proxy-auth': 'enable',
- 'forward-server-affinity-timeout': '5',
- 'learn-client-ip': 'enable',
- 'learn-client-ip-from-header': 'true-client-ip',
- 'max-message-length': '8',
- 'max-request-length': '9',
- 'max-waf-body-cache-length': '10',
- 'proxy-fqdn': 'test_value_11',
- 'strict-web-check': 'enable',
- 'tunnel-non-http': 'enable',
- 'unknown-http-version': 'reject',
- 'webproxy-profile': 'test_value_15'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_global_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_global': {
- 'fast_policy_match': 'enable',
- 'forward_proxy_auth': 'enable',
- 'forward_server_affinity_timeout': '5',
- 'learn_client_ip': 'enable',
- 'learn_client_ip_from_header': 'true-client-ip',
- 'max_message_length': '8',
- 'max_request_length': '9',
- 'max_waf_body_cache_length': '10',
- 'proxy_fqdn': 'test_value_11',
- 'strict_web_check': 'enable',
- 'tunnel_non_http': 'enable',
- 'unknown_http_version': 'reject',
- 'webproxy_profile': 'test_value_15'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_global.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'fast-policy-match': 'enable',
- 'forward-proxy-auth': 'enable',
- 'forward-server-affinity-timeout': '5',
- 'learn-client-ip': 'enable',
- 'learn-client-ip-from-header': 'true-client-ip',
- 'max-message-length': '8',
- 'max-request-length': '9',
- 'max-waf-body-cache-length': '10',
- 'proxy-fqdn': 'test_value_11',
- 'strict-web-check': 'enable',
- 'tunnel-non-http': 'enable',
- 'unknown-http-version': 'reject',
- 'webproxy-profile': 'test_value_15'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_global_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_global': {
- 'fast_policy_match': 'enable',
- 'forward_proxy_auth': 'enable',
- 'forward_server_affinity_timeout': '5',
- 'learn_client_ip': 'enable',
- 'learn_client_ip_from_header': 'true-client-ip',
- 'max_message_length': '8',
- 'max_request_length': '9',
- 'max_waf_body_cache_length': '10',
- 'proxy_fqdn': 'test_value_11',
- 'strict_web_check': 'enable',
- 'tunnel_non_http': 'enable',
- 'unknown_http_version': 'reject',
- 'webproxy_profile': 'test_value_15'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_global.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'fast-policy-match': 'enable',
- 'forward-proxy-auth': 'enable',
- 'forward-server-affinity-timeout': '5',
- 'learn-client-ip': 'enable',
- 'learn-client-ip-from-header': 'true-client-ip',
- 'max-message-length': '8',
- 'max-request-length': '9',
- 'max-waf-body-cache-length': '10',
- 'proxy-fqdn': 'test_value_11',
- 'strict-web-check': 'enable',
- 'tunnel-non-http': 'enable',
- 'unknown-http-version': 'reject',
- 'webproxy-profile': 'test_value_15'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_web_proxy_global_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_global': {
- 'random_attribute_not_valid': 'tag',
- 'fast_policy_match': 'enable',
- 'forward_proxy_auth': 'enable',
- 'forward_server_affinity_timeout': '5',
- 'learn_client_ip': 'enable',
- 'learn_client_ip_from_header': 'true-client-ip',
- 'max_message_length': '8',
- 'max_request_length': '9',
- 'max_waf_body_cache_length': '10',
- 'proxy_fqdn': 'test_value_11',
- 'strict_web_check': 'enable',
- 'tunnel_non_http': 'enable',
- 'unknown_http_version': 'reject',
- 'webproxy_profile': 'test_value_15'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_global.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'fast-policy-match': 'enable',
- 'forward-proxy-auth': 'enable',
- 'forward-server-affinity-timeout': '5',
- 'learn-client-ip': 'enable',
- 'learn-client-ip-from-header': 'true-client-ip',
- 'max-message-length': '8',
- 'max-request-length': '9',
- 'max-waf-body-cache-length': '10',
- 'proxy-fqdn': 'test_value_11',
- 'strict-web-check': 'enable',
- 'tunnel-non-http': 'enable',
- 'unknown-http-version': 'reject',
- 'webproxy-profile': 'test_value_15'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_web_proxy_profile.py b/test/units/modules/network/fortios/test_fortios_web_proxy_profile.py
deleted file mode 100644
index d401b30116..0000000000
--- a/test/units/modules/network/fortios/test_fortios_web_proxy_profile.py
+++ /dev/null
@@ -1,289 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_web_proxy_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_web_proxy_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_web_proxy_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_profile': {
- 'header_client_ip': 'pass',
- 'header_front_end_https': 'pass',
- 'header_via_request': 'pass',
- 'header_via_response': 'pass',
- 'header_x_authenticated_groups': 'pass',
- 'header_x_authenticated_user': 'pass',
- 'header_x_forwarded_for': 'pass',
- 'log_header_change': 'enable',
- 'name': 'default_name_11',
- 'strip_encoding': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_profile.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'header-client-ip': 'pass',
- 'header-front-end-https': 'pass',
- 'header-via-request': 'pass',
- 'header-via-response': 'pass',
- 'header-x-authenticated-groups': 'pass',
- 'header-x-authenticated-user': 'pass',
- 'header-x-forwarded-for': 'pass',
- 'log-header-change': 'enable',
- 'name': 'default_name_11',
- 'strip-encoding': 'enable'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_profile': {
- 'header_client_ip': 'pass',
- 'header_front_end_https': 'pass',
- 'header_via_request': 'pass',
- 'header_via_response': 'pass',
- 'header_x_authenticated_groups': 'pass',
- 'header_x_authenticated_user': 'pass',
- 'header_x_forwarded_for': 'pass',
- 'log_header_change': 'enable',
- 'name': 'default_name_11',
- 'strip_encoding': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_profile.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'header-client-ip': 'pass',
- 'header-front-end-https': 'pass',
- 'header-via-request': 'pass',
- 'header-via-response': 'pass',
- 'header-x-authenticated-groups': 'pass',
- 'header-x-authenticated-user': 'pass',
- 'header-x-forwarded-for': 'pass',
- 'log-header-change': 'enable',
- 'name': 'default_name_11',
- 'strip-encoding': 'enable'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_profile': {
- 'header_client_ip': 'pass',
- 'header_front_end_https': 'pass',
- 'header_via_request': 'pass',
- 'header_via_response': 'pass',
- 'header_x_authenticated_groups': 'pass',
- 'header_x_authenticated_user': 'pass',
- 'header_x_forwarded_for': 'pass',
- 'log_header_change': 'enable',
- 'name': 'default_name_11',
- 'strip_encoding': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_profile.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_profile': {
- 'header_client_ip': 'pass',
- 'header_front_end_https': 'pass',
- 'header_via_request': 'pass',
- 'header_via_response': 'pass',
- 'header_x_authenticated_groups': 'pass',
- 'header_x_authenticated_user': 'pass',
- 'header_x_forwarded_for': 'pass',
- 'log_header_change': 'enable',
- 'name': 'default_name_11',
- 'strip_encoding': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_profile.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_profile': {
- 'header_client_ip': 'pass',
- 'header_front_end_https': 'pass',
- 'header_via_request': 'pass',
- 'header_via_response': 'pass',
- 'header_x_authenticated_groups': 'pass',
- 'header_x_authenticated_user': 'pass',
- 'header_x_forwarded_for': 'pass',
- 'log_header_change': 'enable',
- 'name': 'default_name_11',
- 'strip_encoding': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_profile.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'header-client-ip': 'pass',
- 'header-front-end-https': 'pass',
- 'header-via-request': 'pass',
- 'header-via-response': 'pass',
- 'header-x-authenticated-groups': 'pass',
- 'header-x-authenticated-user': 'pass',
- 'header-x-forwarded-for': 'pass',
- 'log-header-change': 'enable',
- 'name': 'default_name_11',
- 'strip-encoding': 'enable'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_web_proxy_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_profile': {
- 'random_attribute_not_valid': 'tag',
- 'header_client_ip': 'pass',
- 'header_front_end_https': 'pass',
- 'header_via_request': 'pass',
- 'header_via_response': 'pass',
- 'header_x_authenticated_groups': 'pass',
- 'header_x_authenticated_user': 'pass',
- 'header_x_forwarded_for': 'pass',
- 'log_header_change': 'enable',
- 'name': 'default_name_11',
- 'strip_encoding': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_profile.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'header-client-ip': 'pass',
- 'header-front-end-https': 'pass',
- 'header-via-request': 'pass',
- 'header-via-response': 'pass',
- 'header-x-authenticated-groups': 'pass',
- 'header-x-authenticated-user': 'pass',
- 'header-x-forwarded-for': 'pass',
- 'log-header-change': 'enable',
- 'name': 'default_name_11',
- 'strip-encoding': 'enable'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_web_proxy_url_match.py b/test/units/modules/network/fortios/test_fortios_web_proxy_url_match.py
deleted file mode 100644
index c3f6a66672..0000000000
--- a/test/units/modules/network/fortios/test_fortios_web_proxy_url_match.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_web_proxy_url_match
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_web_proxy_url_match.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_web_proxy_url_match_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_url_match': {
- 'cache_exemption': 'enable',
- 'comment': 'Comment.',
- 'forward_server': 'test_value_5',
- 'name': 'default_name_6',
- 'status': 'enable',
- 'url_pattern': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_url_match.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'cache-exemption': 'enable',
- 'comment': 'Comment.',
- 'forward-server': 'test_value_5',
- 'name': 'default_name_6',
- 'status': 'enable',
- 'url-pattern': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'url-match', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_url_match_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_url_match': {
- 'cache_exemption': 'enable',
- 'comment': 'Comment.',
- 'forward_server': 'test_value_5',
- 'name': 'default_name_6',
- 'status': 'enable',
- 'url_pattern': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_url_match.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'cache-exemption': 'enable',
- 'comment': 'Comment.',
- 'forward-server': 'test_value_5',
- 'name': 'default_name_6',
- 'status': 'enable',
- 'url-pattern': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'url-match', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_url_match_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_url_match': {
- 'cache_exemption': 'enable',
- 'comment': 'Comment.',
- 'forward_server': 'test_value_5',
- 'name': 'default_name_6',
- 'status': 'enable',
- 'url_pattern': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_url_match.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'url-match', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_url_match_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_url_match': {
- 'cache_exemption': 'enable',
- 'comment': 'Comment.',
- 'forward_server': 'test_value_5',
- 'name': 'default_name_6',
- 'status': 'enable',
- 'url_pattern': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_url_match.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'url-match', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_url_match_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_url_match': {
- 'cache_exemption': 'enable',
- 'comment': 'Comment.',
- 'forward_server': 'test_value_5',
- 'name': 'default_name_6',
- 'status': 'enable',
- 'url_pattern': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_url_match.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'cache-exemption': 'enable',
- 'comment': 'Comment.',
- 'forward-server': 'test_value_5',
- 'name': 'default_name_6',
- 'status': 'enable',
- 'url-pattern': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'url-match', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_web_proxy_url_match_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_url_match': {
- 'random_attribute_not_valid': 'tag',
- 'cache_exemption': 'enable',
- 'comment': 'Comment.',
- 'forward_server': 'test_value_5',
- 'name': 'default_name_6',
- 'status': 'enable',
- 'url_pattern': 'test_value_8'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_url_match.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'cache-exemption': 'enable',
- 'comment': 'Comment.',
- 'forward-server': 'test_value_5',
- 'name': 'default_name_6',
- 'status': 'enable',
- 'url-pattern': 'test_value_8'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'url-match', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_web_proxy_wisp.py b/test/units/modules/network/fortios/test_fortios_web_proxy_wisp.py
deleted file mode 100644
index 3630a314e0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_web_proxy_wisp.py
+++ /dev/null
@@ -1,259 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_web_proxy_wisp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_web_proxy_wisp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_web_proxy_wisp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_wisp': {
- 'comment': 'Comment.',
- 'max_connections': '4',
- 'name': 'default_name_5',
- 'outgoing_ip': 'test_value_6',
- 'server_ip': 'test_value_7',
- 'server_port': '8',
- 'timeout': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_wisp.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'max-connections': '4',
- 'name': 'default_name_5',
- 'outgoing-ip': 'test_value_6',
- 'server-ip': 'test_value_7',
- 'server-port': '8',
- 'timeout': '9'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'wisp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_wisp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_wisp': {
- 'comment': 'Comment.',
- 'max_connections': '4',
- 'name': 'default_name_5',
- 'outgoing_ip': 'test_value_6',
- 'server_ip': 'test_value_7',
- 'server_port': '8',
- 'timeout': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_wisp.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'max-connections': '4',
- 'name': 'default_name_5',
- 'outgoing-ip': 'test_value_6',
- 'server-ip': 'test_value_7',
- 'server-port': '8',
- 'timeout': '9'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'wisp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_wisp_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_wisp': {
- 'comment': 'Comment.',
- 'max_connections': '4',
- 'name': 'default_name_5',
- 'outgoing_ip': 'test_value_6',
- 'server_ip': 'test_value_7',
- 'server_port': '8',
- 'timeout': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_wisp.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'wisp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_web_proxy_wisp_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'web_proxy_wisp': {
- 'comment': 'Comment.',
- 'max_connections': '4',
- 'name': 'default_name_5',
- 'outgoing_ip': 'test_value_6',
- 'server_ip': 'test_value_7',
- 'server_port': '8',
- 'timeout': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_wisp.fortios_web_proxy(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('web-proxy', 'wisp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_web_proxy_wisp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_wisp': {
- 'comment': 'Comment.',
- 'max_connections': '4',
- 'name': 'default_name_5',
- 'outgoing_ip': 'test_value_6',
- 'server_ip': 'test_value_7',
- 'server_port': '8',
- 'timeout': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_wisp.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'max-connections': '4',
- 'name': 'default_name_5',
- 'outgoing-ip': 'test_value_6',
- 'server-ip': 'test_value_7',
- 'server-port': '8',
- 'timeout': '9'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'wisp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_web_proxy_wisp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'web_proxy_wisp': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'max_connections': '4',
- 'name': 'default_name_5',
- 'outgoing_ip': 'test_value_6',
- 'server_ip': 'test_value_7',
- 'server_port': '8',
- 'timeout': '9'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_web_proxy_wisp.fortios_web_proxy(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'max-connections': '4',
- 'name': 'default_name_5',
- 'outgoing-ip': 'test_value_6',
- 'server-ip': 'test_value_7',
- 'server-port': '8',
- 'timeout': '9'
- }
-
- set_method_mock.assert_called_with('web-proxy', 'wisp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_content.py b/test/units/modules/network/fortios/test_fortios_webfilter_content.py
deleted file mode 100644
index 65e66a2742..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_content.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_content
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_content.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_content_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_content': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('webfilter', 'content', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_content_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_content': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('webfilter', 'content', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_content_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_content': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'content', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_content_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_content': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'content', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_content_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_content': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('webfilter', 'content', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_content_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_content': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('webfilter', 'content', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_content_header.py b/test/units/modules/network/fortios/test_fortios_webfilter_content_header.py
deleted file mode 100644
index ba937476f5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_content_header.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_content_header
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_content_header.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_content_header_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_content_header': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content_header.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('webfilter', 'content-header', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_content_header_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_content_header': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content_header.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('webfilter', 'content-header', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_content_header_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_content_header': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content_header.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'content-header', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_content_header_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_content_header': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content_header.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'content-header', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_content_header_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_content_header': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content_header.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('webfilter', 'content-header', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_content_header_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_content_header': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_content_header.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('webfilter', 'content-header', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_fortiguard.py b/test/units/modules/network/fortios/test_fortios_webfilter_fortiguard.py
deleted file mode 100644
index f46455ec2e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_fortiguard.py
+++ /dev/null
@@ -1,231 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_fortiguard
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_fortiguard.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_fortiguard_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_fortiguard': {
- 'cache_mem_percent': '3',
- 'cache_mode': 'ttl',
- 'cache_prefix_match': 'enable',
- 'close_ports': 'enable',
- 'ovrd_auth_https': 'enable',
- 'ovrd_auth_port': '8',
- 'ovrd_auth_port_http': '9',
- 'ovrd_auth_port_https': '10',
- 'ovrd_auth_port_warning': '11',
- 'request_packet_size_limit': '12',
- 'warn_auth_https': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_fortiguard.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'cache-mem-percent': '3',
- 'cache-mode': 'ttl',
- 'cache-prefix-match': 'enable',
- 'close-ports': 'enable',
- 'ovrd-auth-https': 'enable',
- 'ovrd-auth-port': '8',
- 'ovrd-auth-port-http': '9',
- 'ovrd-auth-port-https': '10',
- 'ovrd-auth-port-warning': '11',
- 'request-packet-size-limit': '12',
- 'warn-auth-https': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'fortiguard', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_fortiguard_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_fortiguard': {
- 'cache_mem_percent': '3',
- 'cache_mode': 'ttl',
- 'cache_prefix_match': 'enable',
- 'close_ports': 'enable',
- 'ovrd_auth_https': 'enable',
- 'ovrd_auth_port': '8',
- 'ovrd_auth_port_http': '9',
- 'ovrd_auth_port_https': '10',
- 'ovrd_auth_port_warning': '11',
- 'request_packet_size_limit': '12',
- 'warn_auth_https': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_fortiguard.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'cache-mem-percent': '3',
- 'cache-mode': 'ttl',
- 'cache-prefix-match': 'enable',
- 'close-ports': 'enable',
- 'ovrd-auth-https': 'enable',
- 'ovrd-auth-port': '8',
- 'ovrd-auth-port-http': '9',
- 'ovrd-auth-port-https': '10',
- 'ovrd-auth-port-warning': '11',
- 'request-packet-size-limit': '12',
- 'warn-auth-https': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'fortiguard', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_fortiguard_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_fortiguard': {
- 'cache_mem_percent': '3',
- 'cache_mode': 'ttl',
- 'cache_prefix_match': 'enable',
- 'close_ports': 'enable',
- 'ovrd_auth_https': 'enable',
- 'ovrd_auth_port': '8',
- 'ovrd_auth_port_http': '9',
- 'ovrd_auth_port_https': '10',
- 'ovrd_auth_port_warning': '11',
- 'request_packet_size_limit': '12',
- 'warn_auth_https': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_fortiguard.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'cache-mem-percent': '3',
- 'cache-mode': 'ttl',
- 'cache-prefix-match': 'enable',
- 'close-ports': 'enable',
- 'ovrd-auth-https': 'enable',
- 'ovrd-auth-port': '8',
- 'ovrd-auth-port-http': '9',
- 'ovrd-auth-port-https': '10',
- 'ovrd-auth-port-warning': '11',
- 'request-packet-size-limit': '12',
- 'warn-auth-https': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'fortiguard', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_fortiguard_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_fortiguard': {
- 'random_attribute_not_valid': 'tag',
- 'cache_mem_percent': '3',
- 'cache_mode': 'ttl',
- 'cache_prefix_match': 'enable',
- 'close_ports': 'enable',
- 'ovrd_auth_https': 'enable',
- 'ovrd_auth_port': '8',
- 'ovrd_auth_port_http': '9',
- 'ovrd_auth_port_https': '10',
- 'ovrd_auth_port_warning': '11',
- 'request_packet_size_limit': '12',
- 'warn_auth_https': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_fortiguard.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'cache-mem-percent': '3',
- 'cache-mode': 'ttl',
- 'cache-prefix-match': 'enable',
- 'close-ports': 'enable',
- 'ovrd-auth-https': 'enable',
- 'ovrd-auth-port': '8',
- 'ovrd-auth-port-http': '9',
- 'ovrd-auth-port-https': '10',
- 'ovrd-auth-port-warning': '11',
- 'request-packet-size-limit': '12',
- 'warn-auth-https': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'fortiguard', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_ftgd_local_cat.py b/test/units/modules/network/fortios/test_fortios_webfilter_ftgd_local_cat.py
deleted file mode 100644
index ae1374a400..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_ftgd_local_cat.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_ftgd_local_cat
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_ftgd_local_cat.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_ftgd_local_cat_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ftgd_local_cat': {
- 'desc': 'test_value_3',
- 'id': '4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_cat.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'desc': 'test_value_3',
- 'id': '4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ftgd-local-cat', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_ftgd_local_cat_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ftgd_local_cat': {
- 'desc': 'test_value_3',
- 'id': '4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_cat.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'desc': 'test_value_3',
- 'id': '4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ftgd-local-cat', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_ftgd_local_cat_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_ftgd_local_cat': {
- 'desc': 'test_value_3',
- 'id': '4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_cat.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'ftgd-local-cat', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_ftgd_local_cat_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_ftgd_local_cat': {
- 'desc': 'test_value_3',
- 'id': '4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_cat.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'ftgd-local-cat', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_ftgd_local_cat_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ftgd_local_cat': {
- 'desc': 'test_value_3',
- 'id': '4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_cat.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'desc': 'test_value_3',
- 'id': '4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ftgd-local-cat', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_ftgd_local_cat_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ftgd_local_cat': {
- 'random_attribute_not_valid': 'tag',
- 'desc': 'test_value_3',
- 'id': '4',
- 'status': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_cat.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'desc': 'test_value_3',
- 'id': '4',
- 'status': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ftgd-local-cat', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_ftgd_local_rating.py b/test/units/modules/network/fortios/test_fortios_webfilter_ftgd_local_rating.py
deleted file mode 100644
index 377ada0958..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_ftgd_local_rating.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_ftgd_local_rating
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_ftgd_local_rating.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_ftgd_local_rating_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ftgd_local_rating': {
- 'rating': 'test_value_3',
- 'status': 'enable',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_rating.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'rating': 'test_value_3',
- 'status': 'enable',
- 'url': 'myurl_5.com'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ftgd-local-rating', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_ftgd_local_rating_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ftgd_local_rating': {
- 'rating': 'test_value_3',
- 'status': 'enable',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_rating.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'rating': 'test_value_3',
- 'status': 'enable',
- 'url': 'myurl_5.com'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ftgd-local-rating', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_ftgd_local_rating_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_ftgd_local_rating': {
- 'rating': 'test_value_3',
- 'status': 'enable',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_rating.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'ftgd-local-rating', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_ftgd_local_rating_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_ftgd_local_rating': {
- 'rating': 'test_value_3',
- 'status': 'enable',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_rating.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'ftgd-local-rating', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_ftgd_local_rating_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ftgd_local_rating': {
- 'rating': 'test_value_3',
- 'status': 'enable',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_rating.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'rating': 'test_value_3',
- 'status': 'enable',
- 'url': 'myurl_5.com'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ftgd-local-rating', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_ftgd_local_rating_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ftgd_local_rating': {
- 'random_attribute_not_valid': 'tag',
- 'rating': 'test_value_3',
- 'status': 'enable',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ftgd_local_rating.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'rating': 'test_value_3',
- 'status': 'enable',
- 'url': 'myurl_5.com'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ftgd-local-rating', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_cache_setting.py b/test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_cache_setting.py
deleted file mode 100644
index 688afd3edd..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_cache_setting.py
+++ /dev/null
@@ -1,159 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_ips_urlfilter_cache_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_ips_urlfilter_cache_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_ips_urlfilter_cache_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_cache_setting': {
- 'dns_retry_interval': '3',
- 'extended_ttl': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_cache_setting.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'dns-retry-interval': '3',
- 'extended-ttl': '4'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-cache-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_ips_urlfilter_cache_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_cache_setting': {
- 'dns_retry_interval': '3',
- 'extended_ttl': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_cache_setting.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'dns-retry-interval': '3',
- 'extended-ttl': '4'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-cache-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_ips_urlfilter_cache_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_cache_setting': {
- 'dns_retry_interval': '3',
- 'extended_ttl': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_cache_setting.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'dns-retry-interval': '3',
- 'extended-ttl': '4'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-cache-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_ips_urlfilter_cache_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_cache_setting': {
- 'random_attribute_not_valid': 'tag',
- 'dns_retry_interval': '3',
- 'extended_ttl': '4'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_cache_setting.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'dns-retry-interval': '3',
- 'extended-ttl': '4'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-cache-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_setting.py b/test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_setting.py
deleted file mode 100644
index d79a65760c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_setting.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_ips_urlfilter_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_ips_urlfilter_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_ips_urlfilter_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_setting': {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway': 'test_value_5',
- 'geo_filter': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_setting.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway': 'test_value_5',
- 'geo-filter': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_ips_urlfilter_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_setting': {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway': 'test_value_5',
- 'geo_filter': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_setting.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway': 'test_value_5',
- 'geo-filter': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_ips_urlfilter_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_setting': {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway': 'test_value_5',
- 'geo_filter': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_setting.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway': 'test_value_5',
- 'geo-filter': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_ips_urlfilter_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_setting': {
- 'random_attribute_not_valid': 'tag',
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway': 'test_value_5',
- 'geo_filter': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_setting.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway': 'test_value_5',
- 'geo-filter': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_setting6.py b/test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_setting6.py
deleted file mode 100644
index 32b7006391..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_ips_urlfilter_setting6.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_ips_urlfilter_setting6
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_ips_urlfilter_setting6.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_ips_urlfilter_setting6_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_setting6': {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway6': 'test_value_5',
- 'geo_filter': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_setting6.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway6': 'test_value_5',
- 'geo-filter': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-setting6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_ips_urlfilter_setting6_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_setting6': {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway6': 'test_value_5',
- 'geo_filter': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_setting6.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway6': 'test_value_5',
- 'geo-filter': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-setting6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_ips_urlfilter_setting6_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_setting6': {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway6': 'test_value_5',
- 'geo_filter': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_setting6.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway6': 'test_value_5',
- 'geo-filter': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-setting6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_ips_urlfilter_setting6_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_ips_urlfilter_setting6': {
- 'random_attribute_not_valid': 'tag',
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway6': 'test_value_5',
- 'geo_filter': 'test_value_6'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_ips_urlfilter_setting6.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'device': 'test_value_3',
- 'distance': '4',
- 'gateway6': 'test_value_5',
- 'geo-filter': 'test_value_6'
- }
-
- set_method_mock.assert_called_with('webfilter', 'ips-urlfilter-setting6', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_override.py b/test/units/modules/network/fortios/test_fortios_webfilter_override.py
deleted file mode 100644
index 0594217dc7..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_override.py
+++ /dev/null
@@ -1,299 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_override
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_override.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_override_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_override': {
- 'expires': 'test_value_3',
- 'id': '4',
- 'initiator': 'test_value_5',
- 'ip': 'test_value_6',
- 'ip6': 'test_value_7',
- 'new_profile': 'test_value_8',
- 'old_profile': 'test_value_9',
- 'scope': 'user',
- 'status': 'enable',
- 'user': 'test_value_12',
- 'user_group': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_override.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'expires': 'test_value_3',
- 'id': '4',
- 'initiator': 'test_value_5',
- 'ip': 'test_value_6',
- 'ip6': 'test_value_7',
- 'new-profile': 'test_value_8',
- 'old-profile': 'test_value_9',
- 'scope': 'user',
- 'status': 'enable',
- 'user': 'test_value_12',
- 'user-group': 'test_value_13'
- }
-
- set_method_mock.assert_called_with('webfilter', 'override', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_override_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_override': {
- 'expires': 'test_value_3',
- 'id': '4',
- 'initiator': 'test_value_5',
- 'ip': 'test_value_6',
- 'ip6': 'test_value_7',
- 'new_profile': 'test_value_8',
- 'old_profile': 'test_value_9',
- 'scope': 'user',
- 'status': 'enable',
- 'user': 'test_value_12',
- 'user_group': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_override.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'expires': 'test_value_3',
- 'id': '4',
- 'initiator': 'test_value_5',
- 'ip': 'test_value_6',
- 'ip6': 'test_value_7',
- 'new-profile': 'test_value_8',
- 'old-profile': 'test_value_9',
- 'scope': 'user',
- 'status': 'enable',
- 'user': 'test_value_12',
- 'user-group': 'test_value_13'
- }
-
- set_method_mock.assert_called_with('webfilter', 'override', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_override_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_override': {
- 'expires': 'test_value_3',
- 'id': '4',
- 'initiator': 'test_value_5',
- 'ip': 'test_value_6',
- 'ip6': 'test_value_7',
- 'new_profile': 'test_value_8',
- 'old_profile': 'test_value_9',
- 'scope': 'user',
- 'status': 'enable',
- 'user': 'test_value_12',
- 'user_group': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_override.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'override', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_override_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_override': {
- 'expires': 'test_value_3',
- 'id': '4',
- 'initiator': 'test_value_5',
- 'ip': 'test_value_6',
- 'ip6': 'test_value_7',
- 'new_profile': 'test_value_8',
- 'old_profile': 'test_value_9',
- 'scope': 'user',
- 'status': 'enable',
- 'user': 'test_value_12',
- 'user_group': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_override.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'override', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_override_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_override': {
- 'expires': 'test_value_3',
- 'id': '4',
- 'initiator': 'test_value_5',
- 'ip': 'test_value_6',
- 'ip6': 'test_value_7',
- 'new_profile': 'test_value_8',
- 'old_profile': 'test_value_9',
- 'scope': 'user',
- 'status': 'enable',
- 'user': 'test_value_12',
- 'user_group': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_override.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'expires': 'test_value_3',
- 'id': '4',
- 'initiator': 'test_value_5',
- 'ip': 'test_value_6',
- 'ip6': 'test_value_7',
- 'new-profile': 'test_value_8',
- 'old-profile': 'test_value_9',
- 'scope': 'user',
- 'status': 'enable',
- 'user': 'test_value_12',
- 'user-group': 'test_value_13'
- }
-
- set_method_mock.assert_called_with('webfilter', 'override', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_override_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_override': {
- 'random_attribute_not_valid': 'tag',
- 'expires': 'test_value_3',
- 'id': '4',
- 'initiator': 'test_value_5',
- 'ip': 'test_value_6',
- 'ip6': 'test_value_7',
- 'new_profile': 'test_value_8',
- 'old_profile': 'test_value_9',
- 'scope': 'user',
- 'status': 'enable',
- 'user': 'test_value_12',
- 'user_group': 'test_value_13'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_override.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'expires': 'test_value_3',
- 'id': '4',
- 'initiator': 'test_value_5',
- 'ip': 'test_value_6',
- 'ip6': 'test_value_7',
- 'new-profile': 'test_value_8',
- 'old-profile': 'test_value_9',
- 'scope': 'user',
- 'status': 'enable',
- 'user': 'test_value_12',
- 'user-group': 'test_value_13'
- }
-
- set_method_mock.assert_called_with('webfilter', 'override', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_profile.py b/test/units/modules/network/fortios/test_fortios_webfilter_profile.py
deleted file mode 100644
index 07efbfcbd5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_profile.py
+++ /dev/null
@@ -1,479 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_profile': {
- 'comment': 'Optional comments.',
- 'extended_log': 'enable',
- 'https_replacemsg': 'enable',
- 'inspection_mode': 'proxy',
- 'log_all_url': 'enable',
- 'name': 'default_name_8',
- 'options': 'activexfilter',
- 'ovrd_perm': 'bannedword-override',
- 'post_action': 'normal',
- 'replacemsg_group': 'test_value_12',
- 'web_content_log': 'enable',
- 'web_extended_all_action_log': 'enable',
- 'web_filter_activex_log': 'enable',
- 'web_filter_applet_log': 'enable',
- 'web_filter_command_block_log': 'enable',
- 'web_filter_cookie_log': 'enable',
- 'web_filter_cookie_removal_log': 'enable',
- 'web_filter_js_log': 'enable',
- 'web_filter_jscript_log': 'enable',
- 'web_filter_referer_log': 'enable',
- 'web_filter_unknown_log': 'enable',
- 'web_filter_vbs_log': 'enable',
- 'web_ftgd_err_log': 'enable',
- 'web_ftgd_quota_usage': 'enable',
- 'web_invalid_domain_log': 'enable',
- 'web_url_log': 'enable',
- 'wisp': 'enable',
- 'wisp_algorithm': 'primary-secondary',
- 'youtube_channel_status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_profile.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'extended-log': 'enable',
- 'https-replacemsg': 'enable',
- 'inspection-mode': 'proxy',
- 'log-all-url': 'enable',
- 'name': 'default_name_8',
- 'options': 'activexfilter',
- 'ovrd-perm': 'bannedword-override',
- 'post-action': 'normal',
- 'replacemsg-group': 'test_value_12',
- 'web-content-log': 'enable',
- 'web-extended-all-action-log': 'enable',
- 'web-filter-activex-log': 'enable',
- 'web-filter-applet-log': 'enable',
- 'web-filter-command-block-log': 'enable',
- 'web-filter-cookie-log': 'enable',
- 'web-filter-cookie-removal-log': 'enable',
- 'web-filter-js-log': 'enable',
- 'web-filter-jscript-log': 'enable',
- 'web-filter-referer-log': 'enable',
- 'web-filter-unknown-log': 'enable',
- 'web-filter-vbs-log': 'enable',
- 'web-ftgd-err-log': 'enable',
- 'web-ftgd-quota-usage': 'enable',
- 'web-invalid-domain-log': 'enable',
- 'web-url-log': 'enable',
- 'wisp': 'enable',
- 'wisp-algorithm': 'primary-secondary',
- 'youtube-channel-status': 'disable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_profile': {
- 'comment': 'Optional comments.',
- 'extended_log': 'enable',
- 'https_replacemsg': 'enable',
- 'inspection_mode': 'proxy',
- 'log_all_url': 'enable',
- 'name': 'default_name_8',
- 'options': 'activexfilter',
- 'ovrd_perm': 'bannedword-override',
- 'post_action': 'normal',
- 'replacemsg_group': 'test_value_12',
- 'web_content_log': 'enable',
- 'web_extended_all_action_log': 'enable',
- 'web_filter_activex_log': 'enable',
- 'web_filter_applet_log': 'enable',
- 'web_filter_command_block_log': 'enable',
- 'web_filter_cookie_log': 'enable',
- 'web_filter_cookie_removal_log': 'enable',
- 'web_filter_js_log': 'enable',
- 'web_filter_jscript_log': 'enable',
- 'web_filter_referer_log': 'enable',
- 'web_filter_unknown_log': 'enable',
- 'web_filter_vbs_log': 'enable',
- 'web_ftgd_err_log': 'enable',
- 'web_ftgd_quota_usage': 'enable',
- 'web_invalid_domain_log': 'enable',
- 'web_url_log': 'enable',
- 'wisp': 'enable',
- 'wisp_algorithm': 'primary-secondary',
- 'youtube_channel_status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_profile.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'extended-log': 'enable',
- 'https-replacemsg': 'enable',
- 'inspection-mode': 'proxy',
- 'log-all-url': 'enable',
- 'name': 'default_name_8',
- 'options': 'activexfilter',
- 'ovrd-perm': 'bannedword-override',
- 'post-action': 'normal',
- 'replacemsg-group': 'test_value_12',
- 'web-content-log': 'enable',
- 'web-extended-all-action-log': 'enable',
- 'web-filter-activex-log': 'enable',
- 'web-filter-applet-log': 'enable',
- 'web-filter-command-block-log': 'enable',
- 'web-filter-cookie-log': 'enable',
- 'web-filter-cookie-removal-log': 'enable',
- 'web-filter-js-log': 'enable',
- 'web-filter-jscript-log': 'enable',
- 'web-filter-referer-log': 'enable',
- 'web-filter-unknown-log': 'enable',
- 'web-filter-vbs-log': 'enable',
- 'web-ftgd-err-log': 'enable',
- 'web-ftgd-quota-usage': 'enable',
- 'web-invalid-domain-log': 'enable',
- 'web-url-log': 'enable',
- 'wisp': 'enable',
- 'wisp-algorithm': 'primary-secondary',
- 'youtube-channel-status': 'disable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_profile': {
- 'comment': 'Optional comments.',
- 'extended_log': 'enable',
- 'https_replacemsg': 'enable',
- 'inspection_mode': 'proxy',
- 'log_all_url': 'enable',
- 'name': 'default_name_8',
- 'options': 'activexfilter',
- 'ovrd_perm': 'bannedword-override',
- 'post_action': 'normal',
- 'replacemsg_group': 'test_value_12',
- 'web_content_log': 'enable',
- 'web_extended_all_action_log': 'enable',
- 'web_filter_activex_log': 'enable',
- 'web_filter_applet_log': 'enable',
- 'web_filter_command_block_log': 'enable',
- 'web_filter_cookie_log': 'enable',
- 'web_filter_cookie_removal_log': 'enable',
- 'web_filter_js_log': 'enable',
- 'web_filter_jscript_log': 'enable',
- 'web_filter_referer_log': 'enable',
- 'web_filter_unknown_log': 'enable',
- 'web_filter_vbs_log': 'enable',
- 'web_ftgd_err_log': 'enable',
- 'web_ftgd_quota_usage': 'enable',
- 'web_invalid_domain_log': 'enable',
- 'web_url_log': 'enable',
- 'wisp': 'enable',
- 'wisp_algorithm': 'primary-secondary',
- 'youtube_channel_status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_profile.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_profile': {
- 'comment': 'Optional comments.',
- 'extended_log': 'enable',
- 'https_replacemsg': 'enable',
- 'inspection_mode': 'proxy',
- 'log_all_url': 'enable',
- 'name': 'default_name_8',
- 'options': 'activexfilter',
- 'ovrd_perm': 'bannedword-override',
- 'post_action': 'normal',
- 'replacemsg_group': 'test_value_12',
- 'web_content_log': 'enable',
- 'web_extended_all_action_log': 'enable',
- 'web_filter_activex_log': 'enable',
- 'web_filter_applet_log': 'enable',
- 'web_filter_command_block_log': 'enable',
- 'web_filter_cookie_log': 'enable',
- 'web_filter_cookie_removal_log': 'enable',
- 'web_filter_js_log': 'enable',
- 'web_filter_jscript_log': 'enable',
- 'web_filter_referer_log': 'enable',
- 'web_filter_unknown_log': 'enable',
- 'web_filter_vbs_log': 'enable',
- 'web_ftgd_err_log': 'enable',
- 'web_ftgd_quota_usage': 'enable',
- 'web_invalid_domain_log': 'enable',
- 'web_url_log': 'enable',
- 'wisp': 'enable',
- 'wisp_algorithm': 'primary-secondary',
- 'youtube_channel_status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_profile.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_profile': {
- 'comment': 'Optional comments.',
- 'extended_log': 'enable',
- 'https_replacemsg': 'enable',
- 'inspection_mode': 'proxy',
- 'log_all_url': 'enable',
- 'name': 'default_name_8',
- 'options': 'activexfilter',
- 'ovrd_perm': 'bannedword-override',
- 'post_action': 'normal',
- 'replacemsg_group': 'test_value_12',
- 'web_content_log': 'enable',
- 'web_extended_all_action_log': 'enable',
- 'web_filter_activex_log': 'enable',
- 'web_filter_applet_log': 'enable',
- 'web_filter_command_block_log': 'enable',
- 'web_filter_cookie_log': 'enable',
- 'web_filter_cookie_removal_log': 'enable',
- 'web_filter_js_log': 'enable',
- 'web_filter_jscript_log': 'enable',
- 'web_filter_referer_log': 'enable',
- 'web_filter_unknown_log': 'enable',
- 'web_filter_vbs_log': 'enable',
- 'web_ftgd_err_log': 'enable',
- 'web_ftgd_quota_usage': 'enable',
- 'web_invalid_domain_log': 'enable',
- 'web_url_log': 'enable',
- 'wisp': 'enable',
- 'wisp_algorithm': 'primary-secondary',
- 'youtube_channel_status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_profile.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'extended-log': 'enable',
- 'https-replacemsg': 'enable',
- 'inspection-mode': 'proxy',
- 'log-all-url': 'enable',
- 'name': 'default_name_8',
- 'options': 'activexfilter',
- 'ovrd-perm': 'bannedword-override',
- 'post-action': 'normal',
- 'replacemsg-group': 'test_value_12',
- 'web-content-log': 'enable',
- 'web-extended-all-action-log': 'enable',
- 'web-filter-activex-log': 'enable',
- 'web-filter-applet-log': 'enable',
- 'web-filter-command-block-log': 'enable',
- 'web-filter-cookie-log': 'enable',
- 'web-filter-cookie-removal-log': 'enable',
- 'web-filter-js-log': 'enable',
- 'web-filter-jscript-log': 'enable',
- 'web-filter-referer-log': 'enable',
- 'web-filter-unknown-log': 'enable',
- 'web-filter-vbs-log': 'enable',
- 'web-ftgd-err-log': 'enable',
- 'web-ftgd-quota-usage': 'enable',
- 'web-invalid-domain-log': 'enable',
- 'web-url-log': 'enable',
- 'wisp': 'enable',
- 'wisp-algorithm': 'primary-secondary',
- 'youtube-channel-status': 'disable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_profile': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'extended_log': 'enable',
- 'https_replacemsg': 'enable',
- 'inspection_mode': 'proxy',
- 'log_all_url': 'enable',
- 'name': 'default_name_8',
- 'options': 'activexfilter',
- 'ovrd_perm': 'bannedword-override',
- 'post_action': 'normal',
- 'replacemsg_group': 'test_value_12',
- 'web_content_log': 'enable',
- 'web_extended_all_action_log': 'enable',
- 'web_filter_activex_log': 'enable',
- 'web_filter_applet_log': 'enable',
- 'web_filter_command_block_log': 'enable',
- 'web_filter_cookie_log': 'enable',
- 'web_filter_cookie_removal_log': 'enable',
- 'web_filter_js_log': 'enable',
- 'web_filter_jscript_log': 'enable',
- 'web_filter_referer_log': 'enable',
- 'web_filter_unknown_log': 'enable',
- 'web_filter_vbs_log': 'enable',
- 'web_ftgd_err_log': 'enable',
- 'web_ftgd_quota_usage': 'enable',
- 'web_invalid_domain_log': 'enable',
- 'web_url_log': 'enable',
- 'wisp': 'enable',
- 'wisp_algorithm': 'primary-secondary',
- 'youtube_channel_status': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_profile.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'extended-log': 'enable',
- 'https-replacemsg': 'enable',
- 'inspection-mode': 'proxy',
- 'log-all-url': 'enable',
- 'name': 'default_name_8',
- 'options': 'activexfilter',
- 'ovrd-perm': 'bannedword-override',
- 'post-action': 'normal',
- 'replacemsg-group': 'test_value_12',
- 'web-content-log': 'enable',
- 'web-extended-all-action-log': 'enable',
- 'web-filter-activex-log': 'enable',
- 'web-filter-applet-log': 'enable',
- 'web-filter-command-block-log': 'enable',
- 'web-filter-cookie-log': 'enable',
- 'web-filter-cookie-removal-log': 'enable',
- 'web-filter-js-log': 'enable',
- 'web-filter-jscript-log': 'enable',
- 'web-filter-referer-log': 'enable',
- 'web-filter-unknown-log': 'enable',
- 'web-filter-vbs-log': 'enable',
- 'web-ftgd-err-log': 'enable',
- 'web-ftgd-quota-usage': 'enable',
- 'web-invalid-domain-log': 'enable',
- 'web-url-log': 'enable',
- 'wisp': 'enable',
- 'wisp-algorithm': 'primary-secondary',
- 'youtube-channel-status': 'disable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_search_engine.py b/test/units/modules/network/fortios/test_fortios_webfilter_search_engine.py
deleted file mode 100644
index ef6cd8a47a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_search_engine.py
+++ /dev/null
@@ -1,259 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_search_engine
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_search_engine.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_search_engine_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_search_engine': {
- 'charset': 'utf-8',
- 'hostname': 'myhostname4',
- 'name': 'default_name_5',
- 'query': 'test_value_6',
- 'safesearch': 'disable',
- 'safesearch_str': 'test_value_8',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_search_engine.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'charset': 'utf-8',
- 'hostname': 'myhostname4',
- 'name': 'default_name_5',
- 'query': 'test_value_6',
- 'safesearch': 'disable',
- 'safesearch-str': 'test_value_8',
- 'url': 'myurl_9.com'
- }
-
- set_method_mock.assert_called_with('webfilter', 'search-engine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_search_engine_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_search_engine': {
- 'charset': 'utf-8',
- 'hostname': 'myhostname4',
- 'name': 'default_name_5',
- 'query': 'test_value_6',
- 'safesearch': 'disable',
- 'safesearch_str': 'test_value_8',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_search_engine.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'charset': 'utf-8',
- 'hostname': 'myhostname4',
- 'name': 'default_name_5',
- 'query': 'test_value_6',
- 'safesearch': 'disable',
- 'safesearch-str': 'test_value_8',
- 'url': 'myurl_9.com'
- }
-
- set_method_mock.assert_called_with('webfilter', 'search-engine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_search_engine_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_search_engine': {
- 'charset': 'utf-8',
- 'hostname': 'myhostname4',
- 'name': 'default_name_5',
- 'query': 'test_value_6',
- 'safesearch': 'disable',
- 'safesearch_str': 'test_value_8',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_search_engine.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'search-engine', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_search_engine_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_search_engine': {
- 'charset': 'utf-8',
- 'hostname': 'myhostname4',
- 'name': 'default_name_5',
- 'query': 'test_value_6',
- 'safesearch': 'disable',
- 'safesearch_str': 'test_value_8',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_search_engine.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'search-engine', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_search_engine_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_search_engine': {
- 'charset': 'utf-8',
- 'hostname': 'myhostname4',
- 'name': 'default_name_5',
- 'query': 'test_value_6',
- 'safesearch': 'disable',
- 'safesearch_str': 'test_value_8',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_search_engine.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'charset': 'utf-8',
- 'hostname': 'myhostname4',
- 'name': 'default_name_5',
- 'query': 'test_value_6',
- 'safesearch': 'disable',
- 'safesearch-str': 'test_value_8',
- 'url': 'myurl_9.com'
- }
-
- set_method_mock.assert_called_with('webfilter', 'search-engine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_search_engine_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_search_engine': {
- 'random_attribute_not_valid': 'tag',
- 'charset': 'utf-8',
- 'hostname': 'myhostname4',
- 'name': 'default_name_5',
- 'query': 'test_value_6',
- 'safesearch': 'disable',
- 'safesearch_str': 'test_value_8',
- 'url': 'myurl_9.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_search_engine.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'charset': 'utf-8',
- 'hostname': 'myhostname4',
- 'name': 'default_name_5',
- 'query': 'test_value_6',
- 'safesearch': 'disable',
- 'safesearch-str': 'test_value_8',
- 'url': 'myurl_9.com'
- }
-
- set_method_mock.assert_called_with('webfilter', 'search-engine', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_webfilter_urlfilter.py b/test/units/modules/network/fortios/test_fortios_webfilter_urlfilter.py
deleted file mode 100644
index 2272b0af7c..0000000000
--- a/test/units/modules/network/fortios/test_fortios_webfilter_urlfilter.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_webfilter_urlfilter
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_webfilter_urlfilter.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_webfilter_urlfilter_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_urlfilter': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'ip_addr_block': 'enable',
- 'name': 'default_name_6',
- 'one_arm_ips_urlfilter': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_urlfilter.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'ip-addr-block': 'enable',
- 'name': 'default_name_6',
- 'one-arm-ips-urlfilter': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'urlfilter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_urlfilter_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_urlfilter': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'ip_addr_block': 'enable',
- 'name': 'default_name_6',
- 'one_arm_ips_urlfilter': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_urlfilter.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'ip-addr-block': 'enable',
- 'name': 'default_name_6',
- 'one-arm-ips-urlfilter': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'urlfilter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_urlfilter_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_urlfilter': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'ip_addr_block': 'enable',
- 'name': 'default_name_6',
- 'one_arm_ips_urlfilter': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_urlfilter.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'urlfilter', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_webfilter_urlfilter_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'webfilter_urlfilter': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'ip_addr_block': 'enable',
- 'name': 'default_name_6',
- 'one_arm_ips_urlfilter': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_urlfilter.fortios_webfilter(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('webfilter', 'urlfilter', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_webfilter_urlfilter_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_urlfilter': {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'ip_addr_block': 'enable',
- 'name': 'default_name_6',
- 'one_arm_ips_urlfilter': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_urlfilter.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'ip-addr-block': 'enable',
- 'name': 'default_name_6',
- 'one-arm-ips-urlfilter': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'urlfilter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_webfilter_urlfilter_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'webfilter_urlfilter': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Optional comments.',
- 'id': '4',
- 'ip_addr_block': 'enable',
- 'name': 'default_name_6',
- 'one_arm_ips_urlfilter': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_webfilter_urlfilter.fortios_webfilter(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Optional comments.',
- 'id': '4',
- 'ip-addr-block': 'enable',
- 'name': 'default_name_6',
- 'one-arm-ips-urlfilter': 'enable'
- }
-
- set_method_mock.assert_called_with('webfilter', 'urlfilter', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_ap_status.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_ap_status.py
deleted file mode 100644
index a19f7c21d6..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_ap_status.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_ap_status
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_ap_status.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_ap_status_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_ap_status': {
- 'bssid': 'test_value_3',
- 'id': '4',
- 'ssid': 'test_value_5',
- 'status': 'rogue'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ap_status.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'bssid': 'test_value_3',
- 'id': '4',
- 'ssid': 'test_value_5',
- 'status': 'rogue'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'ap-status', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_ap_status_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_ap_status': {
- 'bssid': 'test_value_3',
- 'id': '4',
- 'ssid': 'test_value_5',
- 'status': 'rogue'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ap_status.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'bssid': 'test_value_3',
- 'id': '4',
- 'ssid': 'test_value_5',
- 'status': 'rogue'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'ap-status', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_ap_status_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_ap_status': {
- 'bssid': 'test_value_3',
- 'id': '4',
- 'ssid': 'test_value_5',
- 'status': 'rogue'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ap_status.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'ap-status', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_ap_status_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_ap_status': {
- 'bssid': 'test_value_3',
- 'id': '4',
- 'ssid': 'test_value_5',
- 'status': 'rogue'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ap_status.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'ap-status', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_ap_status_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_ap_status': {
- 'bssid': 'test_value_3',
- 'id': '4',
- 'ssid': 'test_value_5',
- 'status': 'rogue'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ap_status.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'bssid': 'test_value_3',
- 'id': '4',
- 'ssid': 'test_value_5',
- 'status': 'rogue'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'ap-status', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_ap_status_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_ap_status': {
- 'random_attribute_not_valid': 'tag',
- 'bssid': 'test_value_3',
- 'id': '4',
- 'ssid': 'test_value_5',
- 'status': 'rogue'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ap_status.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'bssid': 'test_value_3',
- 'id': '4',
- 'ssid': 'test_value_5',
- 'status': 'rogue'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'ap-status', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_ble_profile.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_ble_profile.py
deleted file mode 100644
index 075d52af99..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_ble_profile.py
+++ /dev/null
@@ -1,319 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_ble_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_ble_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_ble_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_ble_profile': {
- 'advertising': 'ibeacon',
- 'beacon_interval': '4',
- 'ble_scanning': 'enable',
- 'comment': 'Comment.',
- 'eddystone_instance': 'test_value_7',
- 'eddystone_namespace': 'test_value_8',
- 'eddystone_url': 'test_value_9',
- 'eddystone_url_encode_hex': 'test_value_10',
- 'ibeacon_uuid': 'test_value_11',
- 'major_id': '12',
- 'minor_id': '13',
- 'name': 'default_name_14',
- 'txpower': '0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ble_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'advertising': 'ibeacon',
- 'beacon-interval': '4',
- 'ble-scanning': 'enable',
- 'comment': 'Comment.',
- 'eddystone-instance': 'test_value_7',
- 'eddystone-namespace': 'test_value_8',
- 'eddystone-url': 'test_value_9',
- 'eddystone-url-encode-hex': 'test_value_10',
- 'ibeacon-uuid': 'test_value_11',
- 'major-id': '12',
- 'minor-id': '13',
- 'name': 'default_name_14',
- 'txpower': '0'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'ble-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_ble_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_ble_profile': {
- 'advertising': 'ibeacon',
- 'beacon_interval': '4',
- 'ble_scanning': 'enable',
- 'comment': 'Comment.',
- 'eddystone_instance': 'test_value_7',
- 'eddystone_namespace': 'test_value_8',
- 'eddystone_url': 'test_value_9',
- 'eddystone_url_encode_hex': 'test_value_10',
- 'ibeacon_uuid': 'test_value_11',
- 'major_id': '12',
- 'minor_id': '13',
- 'name': 'default_name_14',
- 'txpower': '0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ble_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'advertising': 'ibeacon',
- 'beacon-interval': '4',
- 'ble-scanning': 'enable',
- 'comment': 'Comment.',
- 'eddystone-instance': 'test_value_7',
- 'eddystone-namespace': 'test_value_8',
- 'eddystone-url': 'test_value_9',
- 'eddystone-url-encode-hex': 'test_value_10',
- 'ibeacon-uuid': 'test_value_11',
- 'major-id': '12',
- 'minor-id': '13',
- 'name': 'default_name_14',
- 'txpower': '0'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'ble-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_ble_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_ble_profile': {
- 'advertising': 'ibeacon',
- 'beacon_interval': '4',
- 'ble_scanning': 'enable',
- 'comment': 'Comment.',
- 'eddystone_instance': 'test_value_7',
- 'eddystone_namespace': 'test_value_8',
- 'eddystone_url': 'test_value_9',
- 'eddystone_url_encode_hex': 'test_value_10',
- 'ibeacon_uuid': 'test_value_11',
- 'major_id': '12',
- 'minor_id': '13',
- 'name': 'default_name_14',
- 'txpower': '0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ble_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'ble-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_ble_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_ble_profile': {
- 'advertising': 'ibeacon',
- 'beacon_interval': '4',
- 'ble_scanning': 'enable',
- 'comment': 'Comment.',
- 'eddystone_instance': 'test_value_7',
- 'eddystone_namespace': 'test_value_8',
- 'eddystone_url': 'test_value_9',
- 'eddystone_url_encode_hex': 'test_value_10',
- 'ibeacon_uuid': 'test_value_11',
- 'major_id': '12',
- 'minor_id': '13',
- 'name': 'default_name_14',
- 'txpower': '0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ble_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'ble-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_ble_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_ble_profile': {
- 'advertising': 'ibeacon',
- 'beacon_interval': '4',
- 'ble_scanning': 'enable',
- 'comment': 'Comment.',
- 'eddystone_instance': 'test_value_7',
- 'eddystone_namespace': 'test_value_8',
- 'eddystone_url': 'test_value_9',
- 'eddystone_url_encode_hex': 'test_value_10',
- 'ibeacon_uuid': 'test_value_11',
- 'major_id': '12',
- 'minor_id': '13',
- 'name': 'default_name_14',
- 'txpower': '0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ble_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'advertising': 'ibeacon',
- 'beacon-interval': '4',
- 'ble-scanning': 'enable',
- 'comment': 'Comment.',
- 'eddystone-instance': 'test_value_7',
- 'eddystone-namespace': 'test_value_8',
- 'eddystone-url': 'test_value_9',
- 'eddystone-url-encode-hex': 'test_value_10',
- 'ibeacon-uuid': 'test_value_11',
- 'major-id': '12',
- 'minor-id': '13',
- 'name': 'default_name_14',
- 'txpower': '0'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'ble-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_ble_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_ble_profile': {
- 'random_attribute_not_valid': 'tag',
- 'advertising': 'ibeacon',
- 'beacon_interval': '4',
- 'ble_scanning': 'enable',
- 'comment': 'Comment.',
- 'eddystone_instance': 'test_value_7',
- 'eddystone_namespace': 'test_value_8',
- 'eddystone_url': 'test_value_9',
- 'eddystone_url_encode_hex': 'test_value_10',
- 'ibeacon_uuid': 'test_value_11',
- 'major_id': '12',
- 'minor_id': '13',
- 'name': 'default_name_14',
- 'txpower': '0'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_ble_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'advertising': 'ibeacon',
- 'beacon-interval': '4',
- 'ble-scanning': 'enable',
- 'comment': 'Comment.',
- 'eddystone-instance': 'test_value_7',
- 'eddystone-namespace': 'test_value_8',
- 'eddystone-url': 'test_value_9',
- 'eddystone-url-encode-hex': 'test_value_10',
- 'ibeacon-uuid': 'test_value_11',
- 'major-id': '12',
- 'minor-id': '13',
- 'name': 'default_name_14',
- 'txpower': '0'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'ble-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_bonjour_profile.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_bonjour_profile.py
deleted file mode 100644
index b3aa0ab6ef..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_bonjour_profile.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_bonjour_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_bonjour_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_bonjour_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_bonjour_profile': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_bonjour_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'bonjour-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_bonjour_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_bonjour_profile': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_bonjour_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'bonjour-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_bonjour_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_bonjour_profile': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_bonjour_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'bonjour-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_bonjour_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_bonjour_profile': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_bonjour_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'bonjour-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_bonjour_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_bonjour_profile': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_bonjour_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'bonjour-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_bonjour_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_bonjour_profile': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_bonjour_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'bonjour-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_global.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_global.py
deleted file mode 100644
index 50cc589823..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_global.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_global
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_global.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_global_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_global': {
- 'ap_log_server': 'enable',
- 'ap_log_server_ip': 'test_value_4',
- 'ap_log_server_port': '5',
- 'control_message_offload': 'ebp-frame',
- 'data_ethernet_II': 'enable',
- 'discovery_mc_addr': 'test_value_8',
- 'fiapp_eth_type': '9',
- 'image_download': 'enable',
- 'ipsec_base_ip': 'test_value_11',
- 'link_aggregation': 'enable',
- 'location': 'test_value_13',
- 'max_clients': '14',
- 'max_retransmit': '15',
- 'mesh_eth_type': '16',
- 'name': 'default_name_17',
- 'rogue_scan_mac_adjacency': '18',
- 'wtp_share': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_global.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ap-log-server': 'enable',
- 'ap-log-server-ip': 'test_value_4',
- 'ap-log-server-port': '5',
- 'control-message-offload': 'ebp-frame',
- 'data-ethernet-II': 'enable',
- 'discovery-mc-addr': 'test_value_8',
- 'fiapp-eth-type': '9',
- 'image-download': 'enable',
- 'ipsec-base-ip': 'test_value_11',
- 'link-aggregation': 'enable',
- 'location': 'test_value_13',
- 'max-clients': '14',
- 'max-retransmit': '15',
- 'mesh-eth-type': '16',
- 'name': 'default_name_17',
- 'rogue-scan-mac-adjacency': '18',
- 'wtp-share': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_global_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_global': {
- 'ap_log_server': 'enable',
- 'ap_log_server_ip': 'test_value_4',
- 'ap_log_server_port': '5',
- 'control_message_offload': 'ebp-frame',
- 'data_ethernet_II': 'enable',
- 'discovery_mc_addr': 'test_value_8',
- 'fiapp_eth_type': '9',
- 'image_download': 'enable',
- 'ipsec_base_ip': 'test_value_11',
- 'link_aggregation': 'enable',
- 'location': 'test_value_13',
- 'max_clients': '14',
- 'max_retransmit': '15',
- 'mesh_eth_type': '16',
- 'name': 'default_name_17',
- 'rogue_scan_mac_adjacency': '18',
- 'wtp_share': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_global.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ap-log-server': 'enable',
- 'ap-log-server-ip': 'test_value_4',
- 'ap-log-server-port': '5',
- 'control-message-offload': 'ebp-frame',
- 'data-ethernet-II': 'enable',
- 'discovery-mc-addr': 'test_value_8',
- 'fiapp-eth-type': '9',
- 'image-download': 'enable',
- 'ipsec-base-ip': 'test_value_11',
- 'link-aggregation': 'enable',
- 'location': 'test_value_13',
- 'max-clients': '14',
- 'max-retransmit': '15',
- 'mesh-eth-type': '16',
- 'name': 'default_name_17',
- 'rogue-scan-mac-adjacency': '18',
- 'wtp-share': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_global_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_global': {
- 'ap_log_server': 'enable',
- 'ap_log_server_ip': 'test_value_4',
- 'ap_log_server_port': '5',
- 'control_message_offload': 'ebp-frame',
- 'data_ethernet_II': 'enable',
- 'discovery_mc_addr': 'test_value_8',
- 'fiapp_eth_type': '9',
- 'image_download': 'enable',
- 'ipsec_base_ip': 'test_value_11',
- 'link_aggregation': 'enable',
- 'location': 'test_value_13',
- 'max_clients': '14',
- 'max_retransmit': '15',
- 'mesh_eth_type': '16',
- 'name': 'default_name_17',
- 'rogue_scan_mac_adjacency': '18',
- 'wtp_share': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_global.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ap-log-server': 'enable',
- 'ap-log-server-ip': 'test_value_4',
- 'ap-log-server-port': '5',
- 'control-message-offload': 'ebp-frame',
- 'data-ethernet-II': 'enable',
- 'discovery-mc-addr': 'test_value_8',
- 'fiapp-eth-type': '9',
- 'image-download': 'enable',
- 'ipsec-base-ip': 'test_value_11',
- 'link-aggregation': 'enable',
- 'location': 'test_value_13',
- 'max-clients': '14',
- 'max-retransmit': '15',
- 'mesh-eth-type': '16',
- 'name': 'default_name_17',
- 'rogue-scan-mac-adjacency': '18',
- 'wtp-share': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_global_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_global': {
- 'random_attribute_not_valid': 'tag',
- 'ap_log_server': 'enable',
- 'ap_log_server_ip': 'test_value_4',
- 'ap_log_server_port': '5',
- 'control_message_offload': 'ebp-frame',
- 'data_ethernet_II': 'enable',
- 'discovery_mc_addr': 'test_value_8',
- 'fiapp_eth_type': '9',
- 'image_download': 'enable',
- 'ipsec_base_ip': 'test_value_11',
- 'link_aggregation': 'enable',
- 'location': 'test_value_13',
- 'max_clients': '14',
- 'max_retransmit': '15',
- 'mesh_eth_type': '16',
- 'name': 'default_name_17',
- 'rogue_scan_mac_adjacency': '18',
- 'wtp_share': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_global.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ap-log-server': 'enable',
- 'ap-log-server-ip': 'test_value_4',
- 'ap-log-server-port': '5',
- 'control-message-offload': 'ebp-frame',
- 'data-ethernet-II': 'enable',
- 'discovery-mc-addr': 'test_value_8',
- 'fiapp-eth-type': '9',
- 'image-download': 'enable',
- 'ipsec-base-ip': 'test_value_11',
- 'link-aggregation': 'enable',
- 'location': 'test_value_13',
- 'max-clients': '14',
- 'max-retransmit': '15',
- 'mesh-eth-type': '16',
- 'name': 'default_name_17',
- 'rogue-scan-mac-adjacency': '18',
- 'wtp-share': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'global', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_3gpp_cellular.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_3gpp_cellular.py
deleted file mode 100644
index 57d36cd1b0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_3gpp_cellular.py
+++ /dev/null
@@ -1,189 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_anqp_3gpp_cellular
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_anqp_3gpp_cellular.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_anqp_3gpp_cellular_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_3gpp_cellular': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_3gpp_cellular.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-3gpp-cellular', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_3gpp_cellular_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_3gpp_cellular': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_3gpp_cellular.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-3gpp-cellular', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_3gpp_cellular_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_3gpp_cellular': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_3gpp_cellular.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-3gpp-cellular', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_3gpp_cellular_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_3gpp_cellular': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_3gpp_cellular.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-3gpp-cellular', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_3gpp_cellular_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_3gpp_cellular': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_3gpp_cellular.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-3gpp-cellular', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_anqp_3gpp_cellular_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_3gpp_cellular': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_3gpp_cellular.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-3gpp-cellular', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_ip_address_type.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_ip_address_type.py
deleted file mode 100644
index 75777d1563..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_ip_address_type.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_anqp_ip_address_type
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_anqp_ip_address_type.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_anqp_ip_address_type_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_ip_address_type': {
- 'ipv4_address_type': 'not-available',
- 'ipv6_address_type': 'not-available',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_ip_address_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'ipv4-address-type': 'not-available',
- 'ipv6-address-type': 'not-available',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-ip-address-type', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_ip_address_type_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_ip_address_type': {
- 'ipv4_address_type': 'not-available',
- 'ipv6_address_type': 'not-available',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_ip_address_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'ipv4-address-type': 'not-available',
- 'ipv6-address-type': 'not-available',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-ip-address-type', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_ip_address_type_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_ip_address_type': {
- 'ipv4_address_type': 'not-available',
- 'ipv6_address_type': 'not-available',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_ip_address_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-ip-address-type', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_ip_address_type_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_ip_address_type': {
- 'ipv4_address_type': 'not-available',
- 'ipv6_address_type': 'not-available',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_ip_address_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-ip-address-type', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_ip_address_type_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_ip_address_type': {
- 'ipv4_address_type': 'not-available',
- 'ipv6_address_type': 'not-available',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_ip_address_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'ipv4-address-type': 'not-available',
- 'ipv6-address-type': 'not-available',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-ip-address-type', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_anqp_ip_address_type_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_ip_address_type': {
- 'random_attribute_not_valid': 'tag',
- 'ipv4_address_type': 'not-available',
- 'ipv6_address_type': 'not-available',
- 'name': 'default_name_5'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_ip_address_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'ipv4-address-type': 'not-available',
- 'ipv6-address-type': 'not-available',
- 'name': 'default_name_5'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-ip-address-type', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_nai_realm.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_nai_realm.py
deleted file mode 100644
index 12e833d9f3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_nai_realm.py
+++ /dev/null
@@ -1,189 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_anqp_nai_realm
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_anqp_nai_realm.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_anqp_nai_realm_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_nai_realm': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_nai_realm.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-nai-realm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_nai_realm_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_nai_realm': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_nai_realm.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-nai-realm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_nai_realm_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_nai_realm': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_nai_realm.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-nai-realm', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_nai_realm_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_nai_realm': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_nai_realm.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-nai-realm', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_nai_realm_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_nai_realm': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_nai_realm.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-nai-realm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_anqp_nai_realm_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_nai_realm': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_nai_realm.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-nai-realm', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_network_auth_type.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_network_auth_type.py
deleted file mode 100644
index 42318f14da..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_network_auth_type.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_anqp_network_auth_type
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_anqp_network_auth_type.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_anqp_network_auth_type_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_network_auth_type': {
- 'auth_type': 'acceptance-of-terms',
- 'name': 'default_name_4',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_network_auth_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'auth-type': 'acceptance-of-terms',
- 'name': 'default_name_4',
- 'url': 'myurl_5.com'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-network-auth-type', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_network_auth_type_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_network_auth_type': {
- 'auth_type': 'acceptance-of-terms',
- 'name': 'default_name_4',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_network_auth_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'auth-type': 'acceptance-of-terms',
- 'name': 'default_name_4',
- 'url': 'myurl_5.com'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-network-auth-type', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_network_auth_type_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_network_auth_type': {
- 'auth_type': 'acceptance-of-terms',
- 'name': 'default_name_4',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_network_auth_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-network-auth-type', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_network_auth_type_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_network_auth_type': {
- 'auth_type': 'acceptance-of-terms',
- 'name': 'default_name_4',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_network_auth_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-network-auth-type', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_network_auth_type_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_network_auth_type': {
- 'auth_type': 'acceptance-of-terms',
- 'name': 'default_name_4',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_network_auth_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'auth-type': 'acceptance-of-terms',
- 'name': 'default_name_4',
- 'url': 'myurl_5.com'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-network-auth-type', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_anqp_network_auth_type_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_network_auth_type': {
- 'random_attribute_not_valid': 'tag',
- 'auth_type': 'acceptance-of-terms',
- 'name': 'default_name_4',
- 'url': 'myurl_5.com'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_network_auth_type.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'auth-type': 'acceptance-of-terms',
- 'name': 'default_name_4',
- 'url': 'myurl_5.com'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-network-auth-type', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_roaming_consortium.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_roaming_consortium.py
deleted file mode 100644
index 903a60a3fa..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_roaming_consortium.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_anqp_roaming_consortium
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_anqp_roaming_consortium.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_anqp_roaming_consortium_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_roaming_consortium': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_roaming_consortium.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-roaming-consortium', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_roaming_consortium_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_roaming_consortium': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_roaming_consortium.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-roaming-consortium', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_roaming_consortium_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_roaming_consortium': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_roaming_consortium.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-roaming-consortium', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_roaming_consortium_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_roaming_consortium': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_roaming_consortium.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-roaming-consortium', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_roaming_consortium_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_roaming_consortium': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_roaming_consortium.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-roaming-consortium', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_anqp_roaming_consortium_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_roaming_consortium': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_roaming_consortium.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-roaming-consortium', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_venue_name.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_venue_name.py
deleted file mode 100644
index dcd794e853..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_anqp_venue_name.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_anqp_venue_name
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_anqp_venue_name.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_anqp_venue_name_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_venue_name': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_venue_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-venue-name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_venue_name_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_venue_name': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_venue_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-venue-name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_venue_name_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_venue_name': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_venue_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-venue-name', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_anqp_venue_name_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_anqp_venue_name': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_venue_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-venue-name', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_anqp_venue_name_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_venue_name': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_venue_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-venue-name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_anqp_venue_name_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_anqp_venue_name': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_anqp_venue_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'anqp-venue-name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_conn_capability.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_conn_capability.py
deleted file mode 100644
index 11adad6091..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_conn_capability.py
+++ /dev/null
@@ -1,309 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_h2qp_conn_capability
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_h2qp_conn_capability.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_h2qp_conn_capability_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_conn_capability': {
- 'esp_port': 'closed',
- 'ftp_port': 'closed',
- 'http_port': 'closed',
- 'icmp_port': 'closed',
- 'ikev2_port': 'closed',
- 'ikev2_xx_port': 'closed',
- 'name': 'default_name_9',
- 'pptp_vpn_port': 'closed',
- 'ssh_port': 'closed',
- 'tls_port': 'closed',
- 'voip_tcp_port': 'closed',
- 'voip_udp_port': 'closed'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_conn_capability.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'esp-port': 'closed',
- 'ftp-port': 'closed',
- 'http-port': 'closed',
- 'icmp-port': 'closed',
- 'ikev2-port': 'closed',
- 'ikev2-xx-port': 'closed',
- 'name': 'default_name_9',
- 'pptp-vpn-port': 'closed',
- 'ssh-port': 'closed',
- 'tls-port': 'closed',
- 'voip-tcp-port': 'closed',
- 'voip-udp-port': 'closed'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-conn-capability', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_h2qp_conn_capability_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_conn_capability': {
- 'esp_port': 'closed',
- 'ftp_port': 'closed',
- 'http_port': 'closed',
- 'icmp_port': 'closed',
- 'ikev2_port': 'closed',
- 'ikev2_xx_port': 'closed',
- 'name': 'default_name_9',
- 'pptp_vpn_port': 'closed',
- 'ssh_port': 'closed',
- 'tls_port': 'closed',
- 'voip_tcp_port': 'closed',
- 'voip_udp_port': 'closed'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_conn_capability.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'esp-port': 'closed',
- 'ftp-port': 'closed',
- 'http-port': 'closed',
- 'icmp-port': 'closed',
- 'ikev2-port': 'closed',
- 'ikev2-xx-port': 'closed',
- 'name': 'default_name_9',
- 'pptp-vpn-port': 'closed',
- 'ssh-port': 'closed',
- 'tls-port': 'closed',
- 'voip-tcp-port': 'closed',
- 'voip-udp-port': 'closed'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-conn-capability', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_h2qp_conn_capability_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_h2qp_conn_capability': {
- 'esp_port': 'closed',
- 'ftp_port': 'closed',
- 'http_port': 'closed',
- 'icmp_port': 'closed',
- 'ikev2_port': 'closed',
- 'ikev2_xx_port': 'closed',
- 'name': 'default_name_9',
- 'pptp_vpn_port': 'closed',
- 'ssh_port': 'closed',
- 'tls_port': 'closed',
- 'voip_tcp_port': 'closed',
- 'voip_udp_port': 'closed'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_conn_capability.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-conn-capability', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_h2qp_conn_capability_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_h2qp_conn_capability': {
- 'esp_port': 'closed',
- 'ftp_port': 'closed',
- 'http_port': 'closed',
- 'icmp_port': 'closed',
- 'ikev2_port': 'closed',
- 'ikev2_xx_port': 'closed',
- 'name': 'default_name_9',
- 'pptp_vpn_port': 'closed',
- 'ssh_port': 'closed',
- 'tls_port': 'closed',
- 'voip_tcp_port': 'closed',
- 'voip_udp_port': 'closed'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_conn_capability.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-conn-capability', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_h2qp_conn_capability_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_conn_capability': {
- 'esp_port': 'closed',
- 'ftp_port': 'closed',
- 'http_port': 'closed',
- 'icmp_port': 'closed',
- 'ikev2_port': 'closed',
- 'ikev2_xx_port': 'closed',
- 'name': 'default_name_9',
- 'pptp_vpn_port': 'closed',
- 'ssh_port': 'closed',
- 'tls_port': 'closed',
- 'voip_tcp_port': 'closed',
- 'voip_udp_port': 'closed'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_conn_capability.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'esp-port': 'closed',
- 'ftp-port': 'closed',
- 'http-port': 'closed',
- 'icmp-port': 'closed',
- 'ikev2-port': 'closed',
- 'ikev2-xx-port': 'closed',
- 'name': 'default_name_9',
- 'pptp-vpn-port': 'closed',
- 'ssh-port': 'closed',
- 'tls-port': 'closed',
- 'voip-tcp-port': 'closed',
- 'voip-udp-port': 'closed'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-conn-capability', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_h2qp_conn_capability_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_conn_capability': {
- 'random_attribute_not_valid': 'tag',
- 'esp_port': 'closed',
- 'ftp_port': 'closed',
- 'http_port': 'closed',
- 'icmp_port': 'closed',
- 'ikev2_port': 'closed',
- 'ikev2_xx_port': 'closed',
- 'name': 'default_name_9',
- 'pptp_vpn_port': 'closed',
- 'ssh_port': 'closed',
- 'tls_port': 'closed',
- 'voip_tcp_port': 'closed',
- 'voip_udp_port': 'closed'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_conn_capability.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'esp-port': 'closed',
- 'ftp-port': 'closed',
- 'http-port': 'closed',
- 'icmp-port': 'closed',
- 'ikev2-port': 'closed',
- 'ikev2-xx-port': 'closed',
- 'name': 'default_name_9',
- 'pptp-vpn-port': 'closed',
- 'ssh-port': 'closed',
- 'tls-port': 'closed',
- 'voip-tcp-port': 'closed',
- 'voip-udp-port': 'closed'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-conn-capability', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_operator_name.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_operator_name.py
deleted file mode 100644
index 2783ec48b1..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_operator_name.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_h2qp_operator_name
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_h2qp_operator_name.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_h2qp_operator_name_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_operator_name': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_operator_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-operator-name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_h2qp_operator_name_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_operator_name': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_operator_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-operator-name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_h2qp_operator_name_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_h2qp_operator_name': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_operator_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-operator-name', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_h2qp_operator_name_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_h2qp_operator_name': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_operator_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-operator-name', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_h2qp_operator_name_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_operator_name': {
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_operator_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-operator-name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_h2qp_operator_name_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_operator_name': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_operator_name.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-operator-name', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_osu_provider.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_osu_provider.py
deleted file mode 100644
index 3b9af5f164..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_osu_provider.py
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_h2qp_osu_provider
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_h2qp_osu_provider.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_h2qp_osu_provider_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_osu_provider': {'icon': 'test_value_3',
- 'name': 'default_name_4',
- 'osu_method': 'oma-dm',
- 'osu_nai': 'test_value_6',
- 'server_uri': 'test_value_7',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_osu_provider.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'icon': 'test_value_3',
- 'name': 'default_name_4',
- 'osu-method': 'oma-dm',
- 'osu-nai': 'test_value_6',
- 'server-uri': 'test_value_7',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-osu-provider', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_h2qp_osu_provider_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_osu_provider': {'icon': 'test_value_3',
- 'name': 'default_name_4',
- 'osu_method': 'oma-dm',
- 'osu_nai': 'test_value_6',
- 'server_uri': 'test_value_7',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_osu_provider.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'icon': 'test_value_3',
- 'name': 'default_name_4',
- 'osu-method': 'oma-dm',
- 'osu-nai': 'test_value_6',
- 'server-uri': 'test_value_7',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-osu-provider', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_h2qp_osu_provider_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_h2qp_osu_provider': {'icon': 'test_value_3',
- 'name': 'default_name_4',
- 'osu_method': 'oma-dm',
- 'osu_nai': 'test_value_6',
- 'server_uri': 'test_value_7',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_osu_provider.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-osu-provider', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_h2qp_osu_provider_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_h2qp_osu_provider': {'icon': 'test_value_3',
- 'name': 'default_name_4',
- 'osu_method': 'oma-dm',
- 'osu_nai': 'test_value_6',
- 'server_uri': 'test_value_7',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_osu_provider.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-osu-provider', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_h2qp_osu_provider_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_osu_provider': {'icon': 'test_value_3',
- 'name': 'default_name_4',
- 'osu_method': 'oma-dm',
- 'osu_nai': 'test_value_6',
- 'server_uri': 'test_value_7',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_osu_provider.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'icon': 'test_value_3',
- 'name': 'default_name_4',
- 'osu-method': 'oma-dm',
- 'osu-nai': 'test_value_6',
- 'server-uri': 'test_value_7',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-osu-provider', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_h2qp_osu_provider_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_osu_provider': {
- 'random_attribute_not_valid': 'tag', 'icon': 'test_value_3',
- 'name': 'default_name_4',
- 'osu_method': 'oma-dm',
- 'osu_nai': 'test_value_6',
- 'server_uri': 'test_value_7',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_osu_provider.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'icon': 'test_value_3',
- 'name': 'default_name_4',
- 'osu-method': 'oma-dm',
- 'osu-nai': 'test_value_6',
- 'server-uri': 'test_value_7',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-osu-provider', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_wan_metric.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_wan_metric.py
deleted file mode 100644
index 9218c09280..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_h2qp_wan_metric.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_h2qp_wan_metric
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_h2qp_wan_metric.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_h2qp_wan_metric_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_wan_metric': {
- 'downlink_load': '3',
- 'downlink_speed': '4',
- 'link_at_capacity': 'enable',
- 'link_status': 'up',
- 'load_measurement_duration': '7',
- 'name': 'default_name_8',
- 'symmetric_wan_link': 'symmetric',
- 'uplink_load': '10',
- 'uplink_speed': '11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_wan_metric.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'downlink-load': '3',
- 'downlink-speed': '4',
- 'link-at-capacity': 'enable',
- 'link-status': 'up',
- 'load-measurement-duration': '7',
- 'name': 'default_name_8',
- 'symmetric-wan-link': 'symmetric',
- 'uplink-load': '10',
- 'uplink-speed': '11'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-wan-metric', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_h2qp_wan_metric_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_wan_metric': {
- 'downlink_load': '3',
- 'downlink_speed': '4',
- 'link_at_capacity': 'enable',
- 'link_status': 'up',
- 'load_measurement_duration': '7',
- 'name': 'default_name_8',
- 'symmetric_wan_link': 'symmetric',
- 'uplink_load': '10',
- 'uplink_speed': '11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_wan_metric.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'downlink-load': '3',
- 'downlink-speed': '4',
- 'link-at-capacity': 'enable',
- 'link-status': 'up',
- 'load-measurement-duration': '7',
- 'name': 'default_name_8',
- 'symmetric-wan-link': 'symmetric',
- 'uplink-load': '10',
- 'uplink-speed': '11'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-wan-metric', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_h2qp_wan_metric_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_h2qp_wan_metric': {
- 'downlink_load': '3',
- 'downlink_speed': '4',
- 'link_at_capacity': 'enable',
- 'link_status': 'up',
- 'load_measurement_duration': '7',
- 'name': 'default_name_8',
- 'symmetric_wan_link': 'symmetric',
- 'uplink_load': '10',
- 'uplink_speed': '11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_wan_metric.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-wan-metric', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_h2qp_wan_metric_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_h2qp_wan_metric': {
- 'downlink_load': '3',
- 'downlink_speed': '4',
- 'link_at_capacity': 'enable',
- 'link_status': 'up',
- 'load_measurement_duration': '7',
- 'name': 'default_name_8',
- 'symmetric_wan_link': 'symmetric',
- 'uplink_load': '10',
- 'uplink_speed': '11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_wan_metric.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-wan-metric', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_h2qp_wan_metric_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_wan_metric': {
- 'downlink_load': '3',
- 'downlink_speed': '4',
- 'link_at_capacity': 'enable',
- 'link_status': 'up',
- 'load_measurement_duration': '7',
- 'name': 'default_name_8',
- 'symmetric_wan_link': 'symmetric',
- 'uplink_load': '10',
- 'uplink_speed': '11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_wan_metric.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'downlink-load': '3',
- 'downlink-speed': '4',
- 'link-at-capacity': 'enable',
- 'link-status': 'up',
- 'load-measurement-duration': '7',
- 'name': 'default_name_8',
- 'symmetric-wan-link': 'symmetric',
- 'uplink-load': '10',
- 'uplink-speed': '11'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-wan-metric', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_h2qp_wan_metric_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_h2qp_wan_metric': {
- 'random_attribute_not_valid': 'tag',
- 'downlink_load': '3',
- 'downlink_speed': '4',
- 'link_at_capacity': 'enable',
- 'link_status': 'up',
- 'load_measurement_duration': '7',
- 'name': 'default_name_8',
- 'symmetric_wan_link': 'symmetric',
- 'uplink_load': '10',
- 'uplink_speed': '11'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_h2qp_wan_metric.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'downlink-load': '3',
- 'downlink-speed': '4',
- 'link-at-capacity': 'enable',
- 'link-status': 'up',
- 'load-measurement-duration': '7',
- 'name': 'default_name_8',
- 'symmetric-wan-link': 'symmetric',
- 'uplink-load': '10',
- 'uplink-speed': '11'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'h2qp-wan-metric', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_hs_profile.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_hs_profile.py
deleted file mode 100644
index 1257e1180f..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_hs_profile.py
+++ /dev/null
@@ -1,489 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_hs_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_hs_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_hs_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_hs_profile': {
- 'access_network_asra': 'enable',
- 'access_network_esr': 'enable',
- 'access_network_internet': 'enable',
- 'access_network_type': 'private-network',
- 'access_network_uesa': 'enable',
- 'anqp_domain_id': '9',
- 'bss_transition': 'enable',
- 'conn_cap': 'test_value_11',
- 'deauth_request_timeout': '12',
- 'dgaf': 'enable',
- 'domain_name': 'test_value_14',
- 'gas_comeback_delay': '15',
- 'gas_fragmentation_limit': '16',
- 'hessid': 'test_value_17',
- 'ip_addr_type': 'test_value_18',
- 'l2tif': 'enable',
- 'nai_realm': 'test_value_20',
- 'name': 'default_name_21',
- 'network_auth': 'test_value_22',
- 'oper_friendly_name': 'test_value_23',
- 'osu_ssid': 'test_value_24',
- 'pame_bi': 'disable',
- 'proxy_arp': 'enable',
- 'qos_map': 'test_value_27',
- 'roaming_consortium': 'test_value_28',
- 'venue_group': 'unspecified',
- 'venue_name': 'test_value_30',
- 'venue_type': 'unspecified',
- 'wan_metrics': 'test_value_32',
- 'wnm_sleep_mode': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_hs_profile.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'access-network-asra': 'enable',
- 'access-network-esr': 'enable',
- 'access-network-internet': 'enable',
- 'access-network-type': 'private-network',
- 'access-network-uesa': 'enable',
- 'anqp-domain-id': '9',
- 'bss-transition': 'enable',
- 'conn-cap': 'test_value_11',
- 'deauth-request-timeout': '12',
- 'dgaf': 'enable',
- 'domain-name': 'test_value_14',
- 'gas-comeback-delay': '15',
- 'gas-fragmentation-limit': '16',
- 'hessid': 'test_value_17',
- 'ip-addr-type': 'test_value_18',
- 'l2tif': 'enable',
- 'nai-realm': 'test_value_20',
- 'name': 'default_name_21',
- 'network-auth': 'test_value_22',
- 'oper-friendly-name': 'test_value_23',
- 'osu-ssid': 'test_value_24',
- 'pame-bi': 'disable',
- 'proxy-arp': 'enable',
- 'qos-map': 'test_value_27',
- 'roaming-consortium': 'test_value_28',
- 'venue-group': 'unspecified',
- 'venue-name': 'test_value_30',
- 'venue-type': 'unspecified',
- 'wan-metrics': 'test_value_32',
- 'wnm-sleep-mode': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'hs-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_hs_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_hs_profile': {
- 'access_network_asra': 'enable',
- 'access_network_esr': 'enable',
- 'access_network_internet': 'enable',
- 'access_network_type': 'private-network',
- 'access_network_uesa': 'enable',
- 'anqp_domain_id': '9',
- 'bss_transition': 'enable',
- 'conn_cap': 'test_value_11',
- 'deauth_request_timeout': '12',
- 'dgaf': 'enable',
- 'domain_name': 'test_value_14',
- 'gas_comeback_delay': '15',
- 'gas_fragmentation_limit': '16',
- 'hessid': 'test_value_17',
- 'ip_addr_type': 'test_value_18',
- 'l2tif': 'enable',
- 'nai_realm': 'test_value_20',
- 'name': 'default_name_21',
- 'network_auth': 'test_value_22',
- 'oper_friendly_name': 'test_value_23',
- 'osu_ssid': 'test_value_24',
- 'pame_bi': 'disable',
- 'proxy_arp': 'enable',
- 'qos_map': 'test_value_27',
- 'roaming_consortium': 'test_value_28',
- 'venue_group': 'unspecified',
- 'venue_name': 'test_value_30',
- 'venue_type': 'unspecified',
- 'wan_metrics': 'test_value_32',
- 'wnm_sleep_mode': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_hs_profile.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'access-network-asra': 'enable',
- 'access-network-esr': 'enable',
- 'access-network-internet': 'enable',
- 'access-network-type': 'private-network',
- 'access-network-uesa': 'enable',
- 'anqp-domain-id': '9',
- 'bss-transition': 'enable',
- 'conn-cap': 'test_value_11',
- 'deauth-request-timeout': '12',
- 'dgaf': 'enable',
- 'domain-name': 'test_value_14',
- 'gas-comeback-delay': '15',
- 'gas-fragmentation-limit': '16',
- 'hessid': 'test_value_17',
- 'ip-addr-type': 'test_value_18',
- 'l2tif': 'enable',
- 'nai-realm': 'test_value_20',
- 'name': 'default_name_21',
- 'network-auth': 'test_value_22',
- 'oper-friendly-name': 'test_value_23',
- 'osu-ssid': 'test_value_24',
- 'pame-bi': 'disable',
- 'proxy-arp': 'enable',
- 'qos-map': 'test_value_27',
- 'roaming-consortium': 'test_value_28',
- 'venue-group': 'unspecified',
- 'venue-name': 'test_value_30',
- 'venue-type': 'unspecified',
- 'wan-metrics': 'test_value_32',
- 'wnm-sleep-mode': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'hs-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_hs_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_hs_profile': {
- 'access_network_asra': 'enable',
- 'access_network_esr': 'enable',
- 'access_network_internet': 'enable',
- 'access_network_type': 'private-network',
- 'access_network_uesa': 'enable',
- 'anqp_domain_id': '9',
- 'bss_transition': 'enable',
- 'conn_cap': 'test_value_11',
- 'deauth_request_timeout': '12',
- 'dgaf': 'enable',
- 'domain_name': 'test_value_14',
- 'gas_comeback_delay': '15',
- 'gas_fragmentation_limit': '16',
- 'hessid': 'test_value_17',
- 'ip_addr_type': 'test_value_18',
- 'l2tif': 'enable',
- 'nai_realm': 'test_value_20',
- 'name': 'default_name_21',
- 'network_auth': 'test_value_22',
- 'oper_friendly_name': 'test_value_23',
- 'osu_ssid': 'test_value_24',
- 'pame_bi': 'disable',
- 'proxy_arp': 'enable',
- 'qos_map': 'test_value_27',
- 'roaming_consortium': 'test_value_28',
- 'venue_group': 'unspecified',
- 'venue_name': 'test_value_30',
- 'venue_type': 'unspecified',
- 'wan_metrics': 'test_value_32',
- 'wnm_sleep_mode': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_hs_profile.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'hs-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_hs_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_hs_profile': {
- 'access_network_asra': 'enable',
- 'access_network_esr': 'enable',
- 'access_network_internet': 'enable',
- 'access_network_type': 'private-network',
- 'access_network_uesa': 'enable',
- 'anqp_domain_id': '9',
- 'bss_transition': 'enable',
- 'conn_cap': 'test_value_11',
- 'deauth_request_timeout': '12',
- 'dgaf': 'enable',
- 'domain_name': 'test_value_14',
- 'gas_comeback_delay': '15',
- 'gas_fragmentation_limit': '16',
- 'hessid': 'test_value_17',
- 'ip_addr_type': 'test_value_18',
- 'l2tif': 'enable',
- 'nai_realm': 'test_value_20',
- 'name': 'default_name_21',
- 'network_auth': 'test_value_22',
- 'oper_friendly_name': 'test_value_23',
- 'osu_ssid': 'test_value_24',
- 'pame_bi': 'disable',
- 'proxy_arp': 'enable',
- 'qos_map': 'test_value_27',
- 'roaming_consortium': 'test_value_28',
- 'venue_group': 'unspecified',
- 'venue_name': 'test_value_30',
- 'venue_type': 'unspecified',
- 'wan_metrics': 'test_value_32',
- 'wnm_sleep_mode': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_hs_profile.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'hs-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_hs_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_hs_profile': {
- 'access_network_asra': 'enable',
- 'access_network_esr': 'enable',
- 'access_network_internet': 'enable',
- 'access_network_type': 'private-network',
- 'access_network_uesa': 'enable',
- 'anqp_domain_id': '9',
- 'bss_transition': 'enable',
- 'conn_cap': 'test_value_11',
- 'deauth_request_timeout': '12',
- 'dgaf': 'enable',
- 'domain_name': 'test_value_14',
- 'gas_comeback_delay': '15',
- 'gas_fragmentation_limit': '16',
- 'hessid': 'test_value_17',
- 'ip_addr_type': 'test_value_18',
- 'l2tif': 'enable',
- 'nai_realm': 'test_value_20',
- 'name': 'default_name_21',
- 'network_auth': 'test_value_22',
- 'oper_friendly_name': 'test_value_23',
- 'osu_ssid': 'test_value_24',
- 'pame_bi': 'disable',
- 'proxy_arp': 'enable',
- 'qos_map': 'test_value_27',
- 'roaming_consortium': 'test_value_28',
- 'venue_group': 'unspecified',
- 'venue_name': 'test_value_30',
- 'venue_type': 'unspecified',
- 'wan_metrics': 'test_value_32',
- 'wnm_sleep_mode': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_hs_profile.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'access-network-asra': 'enable',
- 'access-network-esr': 'enable',
- 'access-network-internet': 'enable',
- 'access-network-type': 'private-network',
- 'access-network-uesa': 'enable',
- 'anqp-domain-id': '9',
- 'bss-transition': 'enable',
- 'conn-cap': 'test_value_11',
- 'deauth-request-timeout': '12',
- 'dgaf': 'enable',
- 'domain-name': 'test_value_14',
- 'gas-comeback-delay': '15',
- 'gas-fragmentation-limit': '16',
- 'hessid': 'test_value_17',
- 'ip-addr-type': 'test_value_18',
- 'l2tif': 'enable',
- 'nai-realm': 'test_value_20',
- 'name': 'default_name_21',
- 'network-auth': 'test_value_22',
- 'oper-friendly-name': 'test_value_23',
- 'osu-ssid': 'test_value_24',
- 'pame-bi': 'disable',
- 'proxy-arp': 'enable',
- 'qos-map': 'test_value_27',
- 'roaming-consortium': 'test_value_28',
- 'venue-group': 'unspecified',
- 'venue-name': 'test_value_30',
- 'venue-type': 'unspecified',
- 'wan-metrics': 'test_value_32',
- 'wnm-sleep-mode': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'hs-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_hs_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_hs_profile': {
- 'random_attribute_not_valid': 'tag',
- 'access_network_asra': 'enable',
- 'access_network_esr': 'enable',
- 'access_network_internet': 'enable',
- 'access_network_type': 'private-network',
- 'access_network_uesa': 'enable',
- 'anqp_domain_id': '9',
- 'bss_transition': 'enable',
- 'conn_cap': 'test_value_11',
- 'deauth_request_timeout': '12',
- 'dgaf': 'enable',
- 'domain_name': 'test_value_14',
- 'gas_comeback_delay': '15',
- 'gas_fragmentation_limit': '16',
- 'hessid': 'test_value_17',
- 'ip_addr_type': 'test_value_18',
- 'l2tif': 'enable',
- 'nai_realm': 'test_value_20',
- 'name': 'default_name_21',
- 'network_auth': 'test_value_22',
- 'oper_friendly_name': 'test_value_23',
- 'osu_ssid': 'test_value_24',
- 'pame_bi': 'disable',
- 'proxy_arp': 'enable',
- 'qos_map': 'test_value_27',
- 'roaming_consortium': 'test_value_28',
- 'venue_group': 'unspecified',
- 'venue_name': 'test_value_30',
- 'venue_type': 'unspecified',
- 'wan_metrics': 'test_value_32',
- 'wnm_sleep_mode': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_hs_profile.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {
- 'access-network-asra': 'enable',
- 'access-network-esr': 'enable',
- 'access-network-internet': 'enable',
- 'access-network-type': 'private-network',
- 'access-network-uesa': 'enable',
- 'anqp-domain-id': '9',
- 'bss-transition': 'enable',
- 'conn-cap': 'test_value_11',
- 'deauth-request-timeout': '12',
- 'dgaf': 'enable',
- 'domain-name': 'test_value_14',
- 'gas-comeback-delay': '15',
- 'gas-fragmentation-limit': '16',
- 'hessid': 'test_value_17',
- 'ip-addr-type': 'test_value_18',
- 'l2tif': 'enable',
- 'nai-realm': 'test_value_20',
- 'name': 'default_name_21',
- 'network-auth': 'test_value_22',
- 'oper-friendly-name': 'test_value_23',
- 'osu-ssid': 'test_value_24',
- 'pame-bi': 'disable',
- 'proxy-arp': 'enable',
- 'qos-map': 'test_value_27',
- 'roaming-consortium': 'test_value_28',
- 'venue-group': 'unspecified',
- 'venue-name': 'test_value_30',
- 'venue-type': 'unspecified',
- 'wan-metrics': 'test_value_32',
- 'wnm-sleep-mode': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'hs-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_icon.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_icon.py
deleted file mode 100644
index c4aac05c80..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_icon.py
+++ /dev/null
@@ -1,189 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_icon
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_icon.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_icon_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_icon': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_icon.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'icon', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_icon_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_icon': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_icon.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'icon', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_icon_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_icon': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_icon.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'icon', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_icon_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_icon': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_icon.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'icon', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_icon_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_icon': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_icon.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'icon', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_icon_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_icon': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_icon.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'icon', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_qos_map.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_qos_map.py
deleted file mode 100644
index 9114faedf3..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_hotspot20_qos_map.py
+++ /dev/null
@@ -1,189 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_hotspot20_qos_map
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_hotspot20_qos_map.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_hotspot20_qos_map_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_qos_map': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_qos_map.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'qos-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_qos_map_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_qos_map': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_qos_map.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'qos-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_qos_map_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_qos_map': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_qos_map.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'qos-map', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_hotspot20_qos_map_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_hotspot20_qos_map': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_qos_map.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller.hotspot20', 'qos-map', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_hotspot20_qos_map_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_qos_map': {'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_qos_map.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'qos-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_hotspot20_qos_map_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_hotspot20_qos_map': {
- 'random_attribute_not_valid': 'tag', 'name': 'default_name_3'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_hotspot20_qos_map.fortios_wireless_controller_hotspot20(input_data, fos_instance)
-
- expected_data = {'name': 'default_name_3'
- }
-
- set_method_mock.assert_called_with('wireless-controller.hotspot20', 'qos-map', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_inter_controller.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_inter_controller.py
deleted file mode 100644
index 4e4476930e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_inter_controller.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_inter_controller
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_inter_controller.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_inter_controller_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_inter_controller': {
- 'fast_failover_max': '3',
- 'fast_failover_wait': '4',
- 'inter_controller_key': 'test_value_5',
- 'inter_controller_mode': 'disable',
- 'inter_controller_pri': 'primary'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_inter_controller.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'fast-failover-max': '3',
- 'fast-failover-wait': '4',
- 'inter-controller-key': 'test_value_5',
- 'inter-controller-mode': 'disable',
- 'inter-controller-pri': 'primary'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'inter-controller', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_inter_controller_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_inter_controller': {
- 'fast_failover_max': '3',
- 'fast_failover_wait': '4',
- 'inter_controller_key': 'test_value_5',
- 'inter_controller_mode': 'disable',
- 'inter_controller_pri': 'primary'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_inter_controller.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'fast-failover-max': '3',
- 'fast-failover-wait': '4',
- 'inter-controller-key': 'test_value_5',
- 'inter-controller-mode': 'disable',
- 'inter-controller-pri': 'primary'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'inter-controller', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_inter_controller_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_inter_controller': {
- 'fast_failover_max': '3',
- 'fast_failover_wait': '4',
- 'inter_controller_key': 'test_value_5',
- 'inter_controller_mode': 'disable',
- 'inter_controller_pri': 'primary'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_inter_controller.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'fast-failover-max': '3',
- 'fast-failover-wait': '4',
- 'inter-controller-key': 'test_value_5',
- 'inter-controller-mode': 'disable',
- 'inter-controller-pri': 'primary'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'inter-controller', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_inter_controller_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_inter_controller': {
- 'random_attribute_not_valid': 'tag',
- 'fast_failover_max': '3',
- 'fast_failover_wait': '4',
- 'inter_controller_key': 'test_value_5',
- 'inter_controller_mode': 'disable',
- 'inter_controller_pri': 'primary'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_inter_controller.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'fast-failover-max': '3',
- 'fast-failover-wait': '4',
- 'inter-controller-key': 'test_value_5',
- 'inter-controller-mode': 'disable',
- 'inter-controller-pri': 'primary'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'inter-controller', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_qos_profile.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_qos_profile.py
deleted file mode 100644
index cbb3d1aff0..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_qos_profile.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_qos_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_qos_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_qos_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_qos_profile': {
- 'bandwidth_admission_control': 'enable',
- 'bandwidth_capacity': '4',
- 'burst': 'enable',
- 'call_admission_control': 'enable',
- 'call_capacity': '7',
- 'comment': 'Comment.',
- 'downlink': '9',
- 'downlink_sta': '10',
- 'dscp_wmm_mapping': 'enable',
- 'name': 'default_name_12',
- 'uplink': '13',
- 'uplink_sta': '14',
- 'wmm': 'enable',
- 'wmm_uapsd': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_qos_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-admission-control': 'enable',
- 'bandwidth-capacity': '4',
- 'burst': 'enable',
- 'call-admission-control': 'enable',
- 'call-capacity': '7',
- 'comment': 'Comment.',
- 'downlink': '9',
- 'downlink-sta': '10',
- 'dscp-wmm-mapping': 'enable',
- 'name': 'default_name_12',
- 'uplink': '13',
- 'uplink-sta': '14',
- 'wmm': 'enable',
- 'wmm-uapsd': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'qos-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_qos_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_qos_profile': {
- 'bandwidth_admission_control': 'enable',
- 'bandwidth_capacity': '4',
- 'burst': 'enable',
- 'call_admission_control': 'enable',
- 'call_capacity': '7',
- 'comment': 'Comment.',
- 'downlink': '9',
- 'downlink_sta': '10',
- 'dscp_wmm_mapping': 'enable',
- 'name': 'default_name_12',
- 'uplink': '13',
- 'uplink_sta': '14',
- 'wmm': 'enable',
- 'wmm_uapsd': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_qos_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-admission-control': 'enable',
- 'bandwidth-capacity': '4',
- 'burst': 'enable',
- 'call-admission-control': 'enable',
- 'call-capacity': '7',
- 'comment': 'Comment.',
- 'downlink': '9',
- 'downlink-sta': '10',
- 'dscp-wmm-mapping': 'enable',
- 'name': 'default_name_12',
- 'uplink': '13',
- 'uplink-sta': '14',
- 'wmm': 'enable',
- 'wmm-uapsd': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'qos-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_qos_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_qos_profile': {
- 'bandwidth_admission_control': 'enable',
- 'bandwidth_capacity': '4',
- 'burst': 'enable',
- 'call_admission_control': 'enable',
- 'call_capacity': '7',
- 'comment': 'Comment.',
- 'downlink': '9',
- 'downlink_sta': '10',
- 'dscp_wmm_mapping': 'enable',
- 'name': 'default_name_12',
- 'uplink': '13',
- 'uplink_sta': '14',
- 'wmm': 'enable',
- 'wmm_uapsd': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_qos_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'qos-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_qos_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_qos_profile': {
- 'bandwidth_admission_control': 'enable',
- 'bandwidth_capacity': '4',
- 'burst': 'enable',
- 'call_admission_control': 'enable',
- 'call_capacity': '7',
- 'comment': 'Comment.',
- 'downlink': '9',
- 'downlink_sta': '10',
- 'dscp_wmm_mapping': 'enable',
- 'name': 'default_name_12',
- 'uplink': '13',
- 'uplink_sta': '14',
- 'wmm': 'enable',
- 'wmm_uapsd': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_qos_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'qos-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_qos_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_qos_profile': {
- 'bandwidth_admission_control': 'enable',
- 'bandwidth_capacity': '4',
- 'burst': 'enable',
- 'call_admission_control': 'enable',
- 'call_capacity': '7',
- 'comment': 'Comment.',
- 'downlink': '9',
- 'downlink_sta': '10',
- 'dscp_wmm_mapping': 'enable',
- 'name': 'default_name_12',
- 'uplink': '13',
- 'uplink_sta': '14',
- 'wmm': 'enable',
- 'wmm_uapsd': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_qos_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-admission-control': 'enable',
- 'bandwidth-capacity': '4',
- 'burst': 'enable',
- 'call-admission-control': 'enable',
- 'call-capacity': '7',
- 'comment': 'Comment.',
- 'downlink': '9',
- 'downlink-sta': '10',
- 'dscp-wmm-mapping': 'enable',
- 'name': 'default_name_12',
- 'uplink': '13',
- 'uplink-sta': '14',
- 'wmm': 'enable',
- 'wmm-uapsd': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'qos-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_qos_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_qos_profile': {
- 'random_attribute_not_valid': 'tag',
- 'bandwidth_admission_control': 'enable',
- 'bandwidth_capacity': '4',
- 'burst': 'enable',
- 'call_admission_control': 'enable',
- 'call_capacity': '7',
- 'comment': 'Comment.',
- 'downlink': '9',
- 'downlink_sta': '10',
- 'dscp_wmm_mapping': 'enable',
- 'name': 'default_name_12',
- 'uplink': '13',
- 'uplink_sta': '14',
- 'wmm': 'enable',
- 'wmm_uapsd': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_qos_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'bandwidth-admission-control': 'enable',
- 'bandwidth-capacity': '4',
- 'burst': 'enable',
- 'call-admission-control': 'enable',
- 'call-capacity': '7',
- 'comment': 'Comment.',
- 'downlink': '9',
- 'downlink-sta': '10',
- 'dscp-wmm-mapping': 'enable',
- 'name': 'default_name_12',
- 'uplink': '13',
- 'uplink-sta': '14',
- 'wmm': 'enable',
- 'wmm-uapsd': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'qos-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_setting.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_setting.py
deleted file mode 100644
index 5be01593a2..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_setting.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_setting
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_setting.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_setting_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_setting': {
- 'account_id': 'test_value_3',
- 'country': 'NA',
- 'duplicate_ssid': 'enable',
- 'fapc_compatibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_setting.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'account-id': 'test_value_3',
- 'country': 'NA',
- 'duplicate-ssid': 'enable',
- 'fapc-compatibility': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_setting_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_setting': {
- 'account_id': 'test_value_3',
- 'country': 'NA',
- 'duplicate_ssid': 'enable',
- 'fapc_compatibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_setting.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'account-id': 'test_value_3',
- 'country': 'NA',
- 'duplicate-ssid': 'enable',
- 'fapc-compatibility': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_setting_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_setting': {
- 'account_id': 'test_value_3',
- 'country': 'NA',
- 'duplicate_ssid': 'enable',
- 'fapc_compatibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_setting.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'account-id': 'test_value_3',
- 'country': 'NA',
- 'duplicate-ssid': 'enable',
- 'fapc-compatibility': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_setting_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_setting': {
- 'random_attribute_not_valid': 'tag',
- 'account_id': 'test_value_3',
- 'country': 'NA',
- 'duplicate_ssid': 'enable',
- 'fapc_compatibility': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_setting.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'account-id': 'test_value_3',
- 'country': 'NA',
- 'duplicate-ssid': 'enable',
- 'fapc-compatibility': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'setting', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_timers.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_timers.py
deleted file mode 100644
index 8f5a418119..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_timers.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_timers
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_timers.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_timers_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_timers': {
- 'ble_scan_report_intv': '3',
- 'client_idle_timeout': '4',
- 'darrp_day': 'sunday',
- 'darrp_optimize': '6',
- 'discovery_interval': '7',
- 'echo_interval': '8',
- 'fake_ap_log': '9',
- 'ipsec_intf_cleanup': '10',
- 'radio_stats_interval': '11',
- 'rogue_ap_log': '12',
- 'sta_capability_interval': '13',
- 'sta_locate_timer': '14',
- 'sta_stats_interval': '15',
- 'vap_stats_interval': '16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_timers.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ble-scan-report-intv': '3',
- 'client-idle-timeout': '4',
- 'darrp-day': 'sunday',
- 'darrp-optimize': '6',
- 'discovery-interval': '7',
- 'echo-interval': '8',
- 'fake-ap-log': '9',
- 'ipsec-intf-cleanup': '10',
- 'radio-stats-interval': '11',
- 'rogue-ap-log': '12',
- 'sta-capability-interval': '13',
- 'sta-locate-timer': '14',
- 'sta-stats-interval': '15',
- 'vap-stats-interval': '16'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'timers', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_timers_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_timers': {
- 'ble_scan_report_intv': '3',
- 'client_idle_timeout': '4',
- 'darrp_day': 'sunday',
- 'darrp_optimize': '6',
- 'discovery_interval': '7',
- 'echo_interval': '8',
- 'fake_ap_log': '9',
- 'ipsec_intf_cleanup': '10',
- 'radio_stats_interval': '11',
- 'rogue_ap_log': '12',
- 'sta_capability_interval': '13',
- 'sta_locate_timer': '14',
- 'sta_stats_interval': '15',
- 'vap_stats_interval': '16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_timers.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ble-scan-report-intv': '3',
- 'client-idle-timeout': '4',
- 'darrp-day': 'sunday',
- 'darrp-optimize': '6',
- 'discovery-interval': '7',
- 'echo-interval': '8',
- 'fake-ap-log': '9',
- 'ipsec-intf-cleanup': '10',
- 'radio-stats-interval': '11',
- 'rogue-ap-log': '12',
- 'sta-capability-interval': '13',
- 'sta-locate-timer': '14',
- 'sta-stats-interval': '15',
- 'vap-stats-interval': '16'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'timers', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_timers_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_timers': {
- 'ble_scan_report_intv': '3',
- 'client_idle_timeout': '4',
- 'darrp_day': 'sunday',
- 'darrp_optimize': '6',
- 'discovery_interval': '7',
- 'echo_interval': '8',
- 'fake_ap_log': '9',
- 'ipsec_intf_cleanup': '10',
- 'radio_stats_interval': '11',
- 'rogue_ap_log': '12',
- 'sta_capability_interval': '13',
- 'sta_locate_timer': '14',
- 'sta_stats_interval': '15',
- 'vap_stats_interval': '16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_timers.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ble-scan-report-intv': '3',
- 'client-idle-timeout': '4',
- 'darrp-day': 'sunday',
- 'darrp-optimize': '6',
- 'discovery-interval': '7',
- 'echo-interval': '8',
- 'fake-ap-log': '9',
- 'ipsec-intf-cleanup': '10',
- 'radio-stats-interval': '11',
- 'rogue-ap-log': '12',
- 'sta-capability-interval': '13',
- 'sta-locate-timer': '14',
- 'sta-stats-interval': '15',
- 'vap-stats-interval': '16'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'timers', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_timers_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_timers': {
- 'random_attribute_not_valid': 'tag',
- 'ble_scan_report_intv': '3',
- 'client_idle_timeout': '4',
- 'darrp_day': 'sunday',
- 'darrp_optimize': '6',
- 'discovery_interval': '7',
- 'echo_interval': '8',
- 'fake_ap_log': '9',
- 'ipsec_intf_cleanup': '10',
- 'radio_stats_interval': '11',
- 'rogue_ap_log': '12',
- 'sta_capability_interval': '13',
- 'sta_locate_timer': '14',
- 'sta_stats_interval': '15',
- 'vap_stats_interval': '16'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_timers.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ble-scan-report-intv': '3',
- 'client-idle-timeout': '4',
- 'darrp-day': 'sunday',
- 'darrp-optimize': '6',
- 'discovery-interval': '7',
- 'echo-interval': '8',
- 'fake-ap-log': '9',
- 'ipsec-intf-cleanup': '10',
- 'radio-stats-interval': '11',
- 'rogue-ap-log': '12',
- 'sta-capability-interval': '13',
- 'sta-locate-timer': '14',
- 'sta-stats-interval': '15',
- 'vap-stats-interval': '16'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'timers', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_utm_profile.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_utm_profile.py
deleted file mode 100644
index 6af88cad6a..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_utm_profile.py
+++ /dev/null
@@ -1,269 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_utm_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_utm_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_utm_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_utm_profile': {
- 'antivirus_profile': 'test_value_3',
- 'application_list': 'test_value_4',
- 'comment': 'Comment.',
- 'ips_sensor': 'test_value_6',
- 'name': 'default_name_7',
- 'scan_botnet_connections': 'disable',
- 'utm_log': 'enable',
- 'webfilter_profile': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_utm_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'antivirus-profile': 'test_value_3',
- 'application-list': 'test_value_4',
- 'comment': 'Comment.',
- 'ips-sensor': 'test_value_6',
- 'name': 'default_name_7',
- 'scan-botnet-connections': 'disable',
- 'utm-log': 'enable',
- 'webfilter-profile': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'utm-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_utm_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_utm_profile': {
- 'antivirus_profile': 'test_value_3',
- 'application_list': 'test_value_4',
- 'comment': 'Comment.',
- 'ips_sensor': 'test_value_6',
- 'name': 'default_name_7',
- 'scan_botnet_connections': 'disable',
- 'utm_log': 'enable',
- 'webfilter_profile': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_utm_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'antivirus-profile': 'test_value_3',
- 'application-list': 'test_value_4',
- 'comment': 'Comment.',
- 'ips-sensor': 'test_value_6',
- 'name': 'default_name_7',
- 'scan-botnet-connections': 'disable',
- 'utm-log': 'enable',
- 'webfilter-profile': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'utm-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_utm_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_utm_profile': {
- 'antivirus_profile': 'test_value_3',
- 'application_list': 'test_value_4',
- 'comment': 'Comment.',
- 'ips_sensor': 'test_value_6',
- 'name': 'default_name_7',
- 'scan_botnet_connections': 'disable',
- 'utm_log': 'enable',
- 'webfilter_profile': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_utm_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'utm-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_utm_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_utm_profile': {
- 'antivirus_profile': 'test_value_3',
- 'application_list': 'test_value_4',
- 'comment': 'Comment.',
- 'ips_sensor': 'test_value_6',
- 'name': 'default_name_7',
- 'scan_botnet_connections': 'disable',
- 'utm_log': 'enable',
- 'webfilter_profile': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_utm_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'utm-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_utm_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_utm_profile': {
- 'antivirus_profile': 'test_value_3',
- 'application_list': 'test_value_4',
- 'comment': 'Comment.',
- 'ips_sensor': 'test_value_6',
- 'name': 'default_name_7',
- 'scan_botnet_connections': 'disable',
- 'utm_log': 'enable',
- 'webfilter_profile': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_utm_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'antivirus-profile': 'test_value_3',
- 'application-list': 'test_value_4',
- 'comment': 'Comment.',
- 'ips-sensor': 'test_value_6',
- 'name': 'default_name_7',
- 'scan-botnet-connections': 'disable',
- 'utm-log': 'enable',
- 'webfilter-profile': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'utm-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_utm_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_utm_profile': {
- 'random_attribute_not_valid': 'tag',
- 'antivirus_profile': 'test_value_3',
- 'application_list': 'test_value_4',
- 'comment': 'Comment.',
- 'ips_sensor': 'test_value_6',
- 'name': 'default_name_7',
- 'scan_botnet_connections': 'disable',
- 'utm_log': 'enable',
- 'webfilter_profile': 'test_value_10'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_utm_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'antivirus-profile': 'test_value_3',
- 'application-list': 'test_value_4',
- 'comment': 'Comment.',
- 'ips-sensor': 'test_value_6',
- 'name': 'default_name_7',
- 'scan-botnet-connections': 'disable',
- 'utm-log': 'enable',
- 'webfilter-profile': 'test_value_10'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'utm-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_vap.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_vap.py
deleted file mode 100644
index fcfc7ce094..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_vap.py
+++ /dev/null
@@ -1,1109 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_vap
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_vap.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_vap_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_vap': {
- 'acct_interim_interval': '3',
- 'alias': 'test_value_4',
- 'auth': 'psk',
- 'broadcast_ssid': 'enable',
- 'broadcast_suppression': 'dhcp-up',
- 'captive_portal_ac_name': 'test_value_8',
- 'captive_portal_macauth_radius_secret': 'test_value_9',
- 'captive_portal_macauth_radius_server': 'test_value_10',
- 'captive_portal_radius_secret': 'test_value_11',
- 'captive_portal_radius_server': 'test_value_12',
- 'captive_portal_session_timeout_interval': '13',
- 'dhcp_lease_time': '14',
- 'dhcp_option82_circuit_id_insertion': 'style-1',
- 'dhcp_option82_insertion': 'enable',
- 'dhcp_option82_remote_id_insertion': 'style-1',
- 'dynamic_vlan': 'enable',
- 'eap_reauth': 'enable',
- 'eap_reauth_intv': '20',
- 'eapol_key_retries': 'disable',
- 'encrypt': 'TKIP',
- 'external_fast_roaming': 'enable',
- 'external_logout': 'test_value_24',
- 'external_web': 'test_value_25',
- 'fast_bss_transition': 'disable',
- 'fast_roaming': 'enable',
- 'ft_mobility_domain': '28',
- 'ft_over_ds': 'disable',
- 'ft_r0_key_lifetime': '30',
- 'gtk_rekey': 'enable',
- 'gtk_rekey_intv': '32',
- 'hotspot20_profile': 'test_value_33',
- 'intra_vap_privacy': 'enable',
- 'ip': 'test_value_35',
- 'key': 'test_value_36',
- 'keyindex': '37',
- 'ldpc': 'disable',
- 'local_authentication': 'enable',
- 'local_bridging': 'enable',
- 'local_lan': 'allow',
- 'local_standalone': 'enable',
- 'local_standalone_nat': 'enable',
- 'mac_auth_bypass': 'enable',
- 'mac_filter': 'enable',
- 'mac_filter_policy_other': 'allow',
- 'max_clients': '47',
- 'max_clients_ap': '48',
- 'me_disable_thresh': '49',
- 'mesh_backhaul': 'enable',
- 'mpsk': 'enable',
- 'mpsk_concurrent_clients': '52',
- 'multicast_enhance': 'enable',
- 'multicast_rate': '0',
- 'name': 'default_name_55',
- 'okc': 'disable',
- 'passphrase': 'test_value_57',
- 'pmf': 'disable',
- 'pmf_assoc_comeback_timeout': '59',
- 'pmf_sa_query_retry_timeout': '60',
- 'portal_message_override_group': 'test_value_61',
- 'portal_type': 'auth',
- 'probe_resp_suppression': 'enable',
- 'probe_resp_threshold': 'test_value_64',
- 'ptk_rekey': 'enable',
- 'ptk_rekey_intv': '66',
- 'qos_profile': 'test_value_67',
- 'quarantine': 'enable',
- 'radio_2g_threshold': 'test_value_69',
- 'radio_5g_threshold': 'test_value_70',
- 'radio_sensitivity': 'enable',
- 'radius_mac_auth': 'enable',
- 'radius_mac_auth_server': 'test_value_73',
- 'radius_server': 'test_value_74',
- 'rates_11a': '1',
- 'rates_11ac_ss12': 'mcs0/1',
- 'rates_11ac_ss34': 'mcs0/3',
- 'rates_11bg': '1',
- 'rates_11n_ss12': 'mcs0/1',
- 'rates_11n_ss34': 'mcs16/3',
- 'schedule': 'test_value_81',
- 'security': 'open',
- 'security_exempt_list': 'test_value_83',
- 'security_obsolete_option': 'enable',
- 'security_redirect_url': 'test_value_85',
- 'split_tunneling': 'enable',
- 'ssid': 'test_value_87',
- 'tkip_counter_measure': 'enable',
- 'utm_profile': 'test_value_89',
- 'vdom': 'test_value_90',
- 'vlan_auto': 'enable',
- 'vlan_pooling': 'wtp-group',
- 'vlanid': '93',
- 'voice_enterprise': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'acct-interim-interval': '3',
- 'alias': 'test_value_4',
- 'auth': 'psk',
- 'broadcast-ssid': 'enable',
- 'broadcast-suppression': 'dhcp-up',
- 'captive-portal-ac-name': 'test_value_8',
- 'captive-portal-macauth-radius-secret': 'test_value_9',
- 'captive-portal-macauth-radius-server': 'test_value_10',
- 'captive-portal-radius-secret': 'test_value_11',
- 'captive-portal-radius-server': 'test_value_12',
- 'captive-portal-session-timeout-interval': '13',
- 'dhcp-lease-time': '14',
- 'dhcp-option82-circuit-id-insertion': 'style-1',
- 'dhcp-option82-insertion': 'enable',
- 'dhcp-option82-remote-id-insertion': 'style-1',
- 'dynamic-vlan': 'enable',
- 'eap-reauth': 'enable',
- 'eap-reauth-intv': '20',
- 'eapol-key-retries': 'disable',
- 'encrypt': 'TKIP',
- 'external-fast-roaming': 'enable',
- 'external-logout': 'test_value_24',
- 'external-web': 'test_value_25',
- 'fast-bss-transition': 'disable',
- 'fast-roaming': 'enable',
- 'ft-mobility-domain': '28',
- 'ft-over-ds': 'disable',
- 'ft-r0-key-lifetime': '30',
- 'gtk-rekey': 'enable',
- 'gtk-rekey-intv': '32',
- 'hotspot20-profile': 'test_value_33',
- 'intra-vap-privacy': 'enable',
- 'ip': 'test_value_35',
- 'key': 'test_value_36',
- 'keyindex': '37',
- 'ldpc': 'disable',
- 'local-authentication': 'enable',
- 'local-bridging': 'enable',
- 'local-lan': 'allow',
- 'local-standalone': 'enable',
- 'local-standalone-nat': 'enable',
- 'mac-auth-bypass': 'enable',
- 'mac-filter': 'enable',
- 'mac-filter-policy-other': 'allow',
- 'max-clients': '47',
- 'max-clients-ap': '48',
- 'me-disable-thresh': '49',
- 'mesh-backhaul': 'enable',
- 'mpsk': 'enable',
- 'mpsk-concurrent-clients': '52',
- 'multicast-enhance': 'enable',
- 'multicast-rate': '0',
- 'name': 'default_name_55',
- 'okc': 'disable',
- 'passphrase': 'test_value_57',
- 'pmf': 'disable',
- 'pmf-assoc-comeback-timeout': '59',
- 'pmf-sa-query-retry-timeout': '60',
- 'portal-message-override-group': 'test_value_61',
- 'portal-type': 'auth',
- 'probe-resp-suppression': 'enable',
- 'probe-resp-threshold': 'test_value_64',
- 'ptk-rekey': 'enable',
- 'ptk-rekey-intv': '66',
- 'qos-profile': 'test_value_67',
- 'quarantine': 'enable',
- 'radio-2g-threshold': 'test_value_69',
- 'radio-5g-threshold': 'test_value_70',
- 'radio-sensitivity': 'enable',
- 'radius-mac-auth': 'enable',
- 'radius-mac-auth-server': 'test_value_73',
- 'radius-server': 'test_value_74',
- 'rates-11a': '1',
- 'rates-11ac-ss12': 'mcs0/1',
- 'rates-11ac-ss34': 'mcs0/3',
- 'rates-11bg': '1',
- 'rates-11n-ss12': 'mcs0/1',
- 'rates-11n-ss34': 'mcs16/3',
- 'schedule': 'test_value_81',
- 'security': 'open',
- 'security-exempt-list': 'test_value_83',
- 'security-obsolete-option': 'enable',
- 'security-redirect-url': 'test_value_85',
- 'split-tunneling': 'enable',
- 'ssid': 'test_value_87',
- 'tkip-counter-measure': 'enable',
- 'utm-profile': 'test_value_89',
- 'vdom': 'test_value_90',
- 'vlan-auto': 'enable',
- 'vlan-pooling': 'wtp-group',
- 'vlanid': '93',
- 'voice-enterprise': 'disable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'vap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_vap_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_vap': {
- 'acct_interim_interval': '3',
- 'alias': 'test_value_4',
- 'auth': 'psk',
- 'broadcast_ssid': 'enable',
- 'broadcast_suppression': 'dhcp-up',
- 'captive_portal_ac_name': 'test_value_8',
- 'captive_portal_macauth_radius_secret': 'test_value_9',
- 'captive_portal_macauth_radius_server': 'test_value_10',
- 'captive_portal_radius_secret': 'test_value_11',
- 'captive_portal_radius_server': 'test_value_12',
- 'captive_portal_session_timeout_interval': '13',
- 'dhcp_lease_time': '14',
- 'dhcp_option82_circuit_id_insertion': 'style-1',
- 'dhcp_option82_insertion': 'enable',
- 'dhcp_option82_remote_id_insertion': 'style-1',
- 'dynamic_vlan': 'enable',
- 'eap_reauth': 'enable',
- 'eap_reauth_intv': '20',
- 'eapol_key_retries': 'disable',
- 'encrypt': 'TKIP',
- 'external_fast_roaming': 'enable',
- 'external_logout': 'test_value_24',
- 'external_web': 'test_value_25',
- 'fast_bss_transition': 'disable',
- 'fast_roaming': 'enable',
- 'ft_mobility_domain': '28',
- 'ft_over_ds': 'disable',
- 'ft_r0_key_lifetime': '30',
- 'gtk_rekey': 'enable',
- 'gtk_rekey_intv': '32',
- 'hotspot20_profile': 'test_value_33',
- 'intra_vap_privacy': 'enable',
- 'ip': 'test_value_35',
- 'key': 'test_value_36',
- 'keyindex': '37',
- 'ldpc': 'disable',
- 'local_authentication': 'enable',
- 'local_bridging': 'enable',
- 'local_lan': 'allow',
- 'local_standalone': 'enable',
- 'local_standalone_nat': 'enable',
- 'mac_auth_bypass': 'enable',
- 'mac_filter': 'enable',
- 'mac_filter_policy_other': 'allow',
- 'max_clients': '47',
- 'max_clients_ap': '48',
- 'me_disable_thresh': '49',
- 'mesh_backhaul': 'enable',
- 'mpsk': 'enable',
- 'mpsk_concurrent_clients': '52',
- 'multicast_enhance': 'enable',
- 'multicast_rate': '0',
- 'name': 'default_name_55',
- 'okc': 'disable',
- 'passphrase': 'test_value_57',
- 'pmf': 'disable',
- 'pmf_assoc_comeback_timeout': '59',
- 'pmf_sa_query_retry_timeout': '60',
- 'portal_message_override_group': 'test_value_61',
- 'portal_type': 'auth',
- 'probe_resp_suppression': 'enable',
- 'probe_resp_threshold': 'test_value_64',
- 'ptk_rekey': 'enable',
- 'ptk_rekey_intv': '66',
- 'qos_profile': 'test_value_67',
- 'quarantine': 'enable',
- 'radio_2g_threshold': 'test_value_69',
- 'radio_5g_threshold': 'test_value_70',
- 'radio_sensitivity': 'enable',
- 'radius_mac_auth': 'enable',
- 'radius_mac_auth_server': 'test_value_73',
- 'radius_server': 'test_value_74',
- 'rates_11a': '1',
- 'rates_11ac_ss12': 'mcs0/1',
- 'rates_11ac_ss34': 'mcs0/3',
- 'rates_11bg': '1',
- 'rates_11n_ss12': 'mcs0/1',
- 'rates_11n_ss34': 'mcs16/3',
- 'schedule': 'test_value_81',
- 'security': 'open',
- 'security_exempt_list': 'test_value_83',
- 'security_obsolete_option': 'enable',
- 'security_redirect_url': 'test_value_85',
- 'split_tunneling': 'enable',
- 'ssid': 'test_value_87',
- 'tkip_counter_measure': 'enable',
- 'utm_profile': 'test_value_89',
- 'vdom': 'test_value_90',
- 'vlan_auto': 'enable',
- 'vlan_pooling': 'wtp-group',
- 'vlanid': '93',
- 'voice_enterprise': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'acct-interim-interval': '3',
- 'alias': 'test_value_4',
- 'auth': 'psk',
- 'broadcast-ssid': 'enable',
- 'broadcast-suppression': 'dhcp-up',
- 'captive-portal-ac-name': 'test_value_8',
- 'captive-portal-macauth-radius-secret': 'test_value_9',
- 'captive-portal-macauth-radius-server': 'test_value_10',
- 'captive-portal-radius-secret': 'test_value_11',
- 'captive-portal-radius-server': 'test_value_12',
- 'captive-portal-session-timeout-interval': '13',
- 'dhcp-lease-time': '14',
- 'dhcp-option82-circuit-id-insertion': 'style-1',
- 'dhcp-option82-insertion': 'enable',
- 'dhcp-option82-remote-id-insertion': 'style-1',
- 'dynamic-vlan': 'enable',
- 'eap-reauth': 'enable',
- 'eap-reauth-intv': '20',
- 'eapol-key-retries': 'disable',
- 'encrypt': 'TKIP',
- 'external-fast-roaming': 'enable',
- 'external-logout': 'test_value_24',
- 'external-web': 'test_value_25',
- 'fast-bss-transition': 'disable',
- 'fast-roaming': 'enable',
- 'ft-mobility-domain': '28',
- 'ft-over-ds': 'disable',
- 'ft-r0-key-lifetime': '30',
- 'gtk-rekey': 'enable',
- 'gtk-rekey-intv': '32',
- 'hotspot20-profile': 'test_value_33',
- 'intra-vap-privacy': 'enable',
- 'ip': 'test_value_35',
- 'key': 'test_value_36',
- 'keyindex': '37',
- 'ldpc': 'disable',
- 'local-authentication': 'enable',
- 'local-bridging': 'enable',
- 'local-lan': 'allow',
- 'local-standalone': 'enable',
- 'local-standalone-nat': 'enable',
- 'mac-auth-bypass': 'enable',
- 'mac-filter': 'enable',
- 'mac-filter-policy-other': 'allow',
- 'max-clients': '47',
- 'max-clients-ap': '48',
- 'me-disable-thresh': '49',
- 'mesh-backhaul': 'enable',
- 'mpsk': 'enable',
- 'mpsk-concurrent-clients': '52',
- 'multicast-enhance': 'enable',
- 'multicast-rate': '0',
- 'name': 'default_name_55',
- 'okc': 'disable',
- 'passphrase': 'test_value_57',
- 'pmf': 'disable',
- 'pmf-assoc-comeback-timeout': '59',
- 'pmf-sa-query-retry-timeout': '60',
- 'portal-message-override-group': 'test_value_61',
- 'portal-type': 'auth',
- 'probe-resp-suppression': 'enable',
- 'probe-resp-threshold': 'test_value_64',
- 'ptk-rekey': 'enable',
- 'ptk-rekey-intv': '66',
- 'qos-profile': 'test_value_67',
- 'quarantine': 'enable',
- 'radio-2g-threshold': 'test_value_69',
- 'radio-5g-threshold': 'test_value_70',
- 'radio-sensitivity': 'enable',
- 'radius-mac-auth': 'enable',
- 'radius-mac-auth-server': 'test_value_73',
- 'radius-server': 'test_value_74',
- 'rates-11a': '1',
- 'rates-11ac-ss12': 'mcs0/1',
- 'rates-11ac-ss34': 'mcs0/3',
- 'rates-11bg': '1',
- 'rates-11n-ss12': 'mcs0/1',
- 'rates-11n-ss34': 'mcs16/3',
- 'schedule': 'test_value_81',
- 'security': 'open',
- 'security-exempt-list': 'test_value_83',
- 'security-obsolete-option': 'enable',
- 'security-redirect-url': 'test_value_85',
- 'split-tunneling': 'enable',
- 'ssid': 'test_value_87',
- 'tkip-counter-measure': 'enable',
- 'utm-profile': 'test_value_89',
- 'vdom': 'test_value_90',
- 'vlan-auto': 'enable',
- 'vlan-pooling': 'wtp-group',
- 'vlanid': '93',
- 'voice-enterprise': 'disable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'vap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_vap_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_vap': {
- 'acct_interim_interval': '3',
- 'alias': 'test_value_4',
- 'auth': 'psk',
- 'broadcast_ssid': 'enable',
- 'broadcast_suppression': 'dhcp-up',
- 'captive_portal_ac_name': 'test_value_8',
- 'captive_portal_macauth_radius_secret': 'test_value_9',
- 'captive_portal_macauth_radius_server': 'test_value_10',
- 'captive_portal_radius_secret': 'test_value_11',
- 'captive_portal_radius_server': 'test_value_12',
- 'captive_portal_session_timeout_interval': '13',
- 'dhcp_lease_time': '14',
- 'dhcp_option82_circuit_id_insertion': 'style-1',
- 'dhcp_option82_insertion': 'enable',
- 'dhcp_option82_remote_id_insertion': 'style-1',
- 'dynamic_vlan': 'enable',
- 'eap_reauth': 'enable',
- 'eap_reauth_intv': '20',
- 'eapol_key_retries': 'disable',
- 'encrypt': 'TKIP',
- 'external_fast_roaming': 'enable',
- 'external_logout': 'test_value_24',
- 'external_web': 'test_value_25',
- 'fast_bss_transition': 'disable',
- 'fast_roaming': 'enable',
- 'ft_mobility_domain': '28',
- 'ft_over_ds': 'disable',
- 'ft_r0_key_lifetime': '30',
- 'gtk_rekey': 'enable',
- 'gtk_rekey_intv': '32',
- 'hotspot20_profile': 'test_value_33',
- 'intra_vap_privacy': 'enable',
- 'ip': 'test_value_35',
- 'key': 'test_value_36',
- 'keyindex': '37',
- 'ldpc': 'disable',
- 'local_authentication': 'enable',
- 'local_bridging': 'enable',
- 'local_lan': 'allow',
- 'local_standalone': 'enable',
- 'local_standalone_nat': 'enable',
- 'mac_auth_bypass': 'enable',
- 'mac_filter': 'enable',
- 'mac_filter_policy_other': 'allow',
- 'max_clients': '47',
- 'max_clients_ap': '48',
- 'me_disable_thresh': '49',
- 'mesh_backhaul': 'enable',
- 'mpsk': 'enable',
- 'mpsk_concurrent_clients': '52',
- 'multicast_enhance': 'enable',
- 'multicast_rate': '0',
- 'name': 'default_name_55',
- 'okc': 'disable',
- 'passphrase': 'test_value_57',
- 'pmf': 'disable',
- 'pmf_assoc_comeback_timeout': '59',
- 'pmf_sa_query_retry_timeout': '60',
- 'portal_message_override_group': 'test_value_61',
- 'portal_type': 'auth',
- 'probe_resp_suppression': 'enable',
- 'probe_resp_threshold': 'test_value_64',
- 'ptk_rekey': 'enable',
- 'ptk_rekey_intv': '66',
- 'qos_profile': 'test_value_67',
- 'quarantine': 'enable',
- 'radio_2g_threshold': 'test_value_69',
- 'radio_5g_threshold': 'test_value_70',
- 'radio_sensitivity': 'enable',
- 'radius_mac_auth': 'enable',
- 'radius_mac_auth_server': 'test_value_73',
- 'radius_server': 'test_value_74',
- 'rates_11a': '1',
- 'rates_11ac_ss12': 'mcs0/1',
- 'rates_11ac_ss34': 'mcs0/3',
- 'rates_11bg': '1',
- 'rates_11n_ss12': 'mcs0/1',
- 'rates_11n_ss34': 'mcs16/3',
- 'schedule': 'test_value_81',
- 'security': 'open',
- 'security_exempt_list': 'test_value_83',
- 'security_obsolete_option': 'enable',
- 'security_redirect_url': 'test_value_85',
- 'split_tunneling': 'enable',
- 'ssid': 'test_value_87',
- 'tkip_counter_measure': 'enable',
- 'utm_profile': 'test_value_89',
- 'vdom': 'test_value_90',
- 'vlan_auto': 'enable',
- 'vlan_pooling': 'wtp-group',
- 'vlanid': '93',
- 'voice_enterprise': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'vap', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_vap_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_vap': {
- 'acct_interim_interval': '3',
- 'alias': 'test_value_4',
- 'auth': 'psk',
- 'broadcast_ssid': 'enable',
- 'broadcast_suppression': 'dhcp-up',
- 'captive_portal_ac_name': 'test_value_8',
- 'captive_portal_macauth_radius_secret': 'test_value_9',
- 'captive_portal_macauth_radius_server': 'test_value_10',
- 'captive_portal_radius_secret': 'test_value_11',
- 'captive_portal_radius_server': 'test_value_12',
- 'captive_portal_session_timeout_interval': '13',
- 'dhcp_lease_time': '14',
- 'dhcp_option82_circuit_id_insertion': 'style-1',
- 'dhcp_option82_insertion': 'enable',
- 'dhcp_option82_remote_id_insertion': 'style-1',
- 'dynamic_vlan': 'enable',
- 'eap_reauth': 'enable',
- 'eap_reauth_intv': '20',
- 'eapol_key_retries': 'disable',
- 'encrypt': 'TKIP',
- 'external_fast_roaming': 'enable',
- 'external_logout': 'test_value_24',
- 'external_web': 'test_value_25',
- 'fast_bss_transition': 'disable',
- 'fast_roaming': 'enable',
- 'ft_mobility_domain': '28',
- 'ft_over_ds': 'disable',
- 'ft_r0_key_lifetime': '30',
- 'gtk_rekey': 'enable',
- 'gtk_rekey_intv': '32',
- 'hotspot20_profile': 'test_value_33',
- 'intra_vap_privacy': 'enable',
- 'ip': 'test_value_35',
- 'key': 'test_value_36',
- 'keyindex': '37',
- 'ldpc': 'disable',
- 'local_authentication': 'enable',
- 'local_bridging': 'enable',
- 'local_lan': 'allow',
- 'local_standalone': 'enable',
- 'local_standalone_nat': 'enable',
- 'mac_auth_bypass': 'enable',
- 'mac_filter': 'enable',
- 'mac_filter_policy_other': 'allow',
- 'max_clients': '47',
- 'max_clients_ap': '48',
- 'me_disable_thresh': '49',
- 'mesh_backhaul': 'enable',
- 'mpsk': 'enable',
- 'mpsk_concurrent_clients': '52',
- 'multicast_enhance': 'enable',
- 'multicast_rate': '0',
- 'name': 'default_name_55',
- 'okc': 'disable',
- 'passphrase': 'test_value_57',
- 'pmf': 'disable',
- 'pmf_assoc_comeback_timeout': '59',
- 'pmf_sa_query_retry_timeout': '60',
- 'portal_message_override_group': 'test_value_61',
- 'portal_type': 'auth',
- 'probe_resp_suppression': 'enable',
- 'probe_resp_threshold': 'test_value_64',
- 'ptk_rekey': 'enable',
- 'ptk_rekey_intv': '66',
- 'qos_profile': 'test_value_67',
- 'quarantine': 'enable',
- 'radio_2g_threshold': 'test_value_69',
- 'radio_5g_threshold': 'test_value_70',
- 'radio_sensitivity': 'enable',
- 'radius_mac_auth': 'enable',
- 'radius_mac_auth_server': 'test_value_73',
- 'radius_server': 'test_value_74',
- 'rates_11a': '1',
- 'rates_11ac_ss12': 'mcs0/1',
- 'rates_11ac_ss34': 'mcs0/3',
- 'rates_11bg': '1',
- 'rates_11n_ss12': 'mcs0/1',
- 'rates_11n_ss34': 'mcs16/3',
- 'schedule': 'test_value_81',
- 'security': 'open',
- 'security_exempt_list': 'test_value_83',
- 'security_obsolete_option': 'enable',
- 'security_redirect_url': 'test_value_85',
- 'split_tunneling': 'enable',
- 'ssid': 'test_value_87',
- 'tkip_counter_measure': 'enable',
- 'utm_profile': 'test_value_89',
- 'vdom': 'test_value_90',
- 'vlan_auto': 'enable',
- 'vlan_pooling': 'wtp-group',
- 'vlanid': '93',
- 'voice_enterprise': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'vap', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_vap_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_vap': {
- 'acct_interim_interval': '3',
- 'alias': 'test_value_4',
- 'auth': 'psk',
- 'broadcast_ssid': 'enable',
- 'broadcast_suppression': 'dhcp-up',
- 'captive_portal_ac_name': 'test_value_8',
- 'captive_portal_macauth_radius_secret': 'test_value_9',
- 'captive_portal_macauth_radius_server': 'test_value_10',
- 'captive_portal_radius_secret': 'test_value_11',
- 'captive_portal_radius_server': 'test_value_12',
- 'captive_portal_session_timeout_interval': '13',
- 'dhcp_lease_time': '14',
- 'dhcp_option82_circuit_id_insertion': 'style-1',
- 'dhcp_option82_insertion': 'enable',
- 'dhcp_option82_remote_id_insertion': 'style-1',
- 'dynamic_vlan': 'enable',
- 'eap_reauth': 'enable',
- 'eap_reauth_intv': '20',
- 'eapol_key_retries': 'disable',
- 'encrypt': 'TKIP',
- 'external_fast_roaming': 'enable',
- 'external_logout': 'test_value_24',
- 'external_web': 'test_value_25',
- 'fast_bss_transition': 'disable',
- 'fast_roaming': 'enable',
- 'ft_mobility_domain': '28',
- 'ft_over_ds': 'disable',
- 'ft_r0_key_lifetime': '30',
- 'gtk_rekey': 'enable',
- 'gtk_rekey_intv': '32',
- 'hotspot20_profile': 'test_value_33',
- 'intra_vap_privacy': 'enable',
- 'ip': 'test_value_35',
- 'key': 'test_value_36',
- 'keyindex': '37',
- 'ldpc': 'disable',
- 'local_authentication': 'enable',
- 'local_bridging': 'enable',
- 'local_lan': 'allow',
- 'local_standalone': 'enable',
- 'local_standalone_nat': 'enable',
- 'mac_auth_bypass': 'enable',
- 'mac_filter': 'enable',
- 'mac_filter_policy_other': 'allow',
- 'max_clients': '47',
- 'max_clients_ap': '48',
- 'me_disable_thresh': '49',
- 'mesh_backhaul': 'enable',
- 'mpsk': 'enable',
- 'mpsk_concurrent_clients': '52',
- 'multicast_enhance': 'enable',
- 'multicast_rate': '0',
- 'name': 'default_name_55',
- 'okc': 'disable',
- 'passphrase': 'test_value_57',
- 'pmf': 'disable',
- 'pmf_assoc_comeback_timeout': '59',
- 'pmf_sa_query_retry_timeout': '60',
- 'portal_message_override_group': 'test_value_61',
- 'portal_type': 'auth',
- 'probe_resp_suppression': 'enable',
- 'probe_resp_threshold': 'test_value_64',
- 'ptk_rekey': 'enable',
- 'ptk_rekey_intv': '66',
- 'qos_profile': 'test_value_67',
- 'quarantine': 'enable',
- 'radio_2g_threshold': 'test_value_69',
- 'radio_5g_threshold': 'test_value_70',
- 'radio_sensitivity': 'enable',
- 'radius_mac_auth': 'enable',
- 'radius_mac_auth_server': 'test_value_73',
- 'radius_server': 'test_value_74',
- 'rates_11a': '1',
- 'rates_11ac_ss12': 'mcs0/1',
- 'rates_11ac_ss34': 'mcs0/3',
- 'rates_11bg': '1',
- 'rates_11n_ss12': 'mcs0/1',
- 'rates_11n_ss34': 'mcs16/3',
- 'schedule': 'test_value_81',
- 'security': 'open',
- 'security_exempt_list': 'test_value_83',
- 'security_obsolete_option': 'enable',
- 'security_redirect_url': 'test_value_85',
- 'split_tunneling': 'enable',
- 'ssid': 'test_value_87',
- 'tkip_counter_measure': 'enable',
- 'utm_profile': 'test_value_89',
- 'vdom': 'test_value_90',
- 'vlan_auto': 'enable',
- 'vlan_pooling': 'wtp-group',
- 'vlanid': '93',
- 'voice_enterprise': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'acct-interim-interval': '3',
- 'alias': 'test_value_4',
- 'auth': 'psk',
- 'broadcast-ssid': 'enable',
- 'broadcast-suppression': 'dhcp-up',
- 'captive-portal-ac-name': 'test_value_8',
- 'captive-portal-macauth-radius-secret': 'test_value_9',
- 'captive-portal-macauth-radius-server': 'test_value_10',
- 'captive-portal-radius-secret': 'test_value_11',
- 'captive-portal-radius-server': 'test_value_12',
- 'captive-portal-session-timeout-interval': '13',
- 'dhcp-lease-time': '14',
- 'dhcp-option82-circuit-id-insertion': 'style-1',
- 'dhcp-option82-insertion': 'enable',
- 'dhcp-option82-remote-id-insertion': 'style-1',
- 'dynamic-vlan': 'enable',
- 'eap-reauth': 'enable',
- 'eap-reauth-intv': '20',
- 'eapol-key-retries': 'disable',
- 'encrypt': 'TKIP',
- 'external-fast-roaming': 'enable',
- 'external-logout': 'test_value_24',
- 'external-web': 'test_value_25',
- 'fast-bss-transition': 'disable',
- 'fast-roaming': 'enable',
- 'ft-mobility-domain': '28',
- 'ft-over-ds': 'disable',
- 'ft-r0-key-lifetime': '30',
- 'gtk-rekey': 'enable',
- 'gtk-rekey-intv': '32',
- 'hotspot20-profile': 'test_value_33',
- 'intra-vap-privacy': 'enable',
- 'ip': 'test_value_35',
- 'key': 'test_value_36',
- 'keyindex': '37',
- 'ldpc': 'disable',
- 'local-authentication': 'enable',
- 'local-bridging': 'enable',
- 'local-lan': 'allow',
- 'local-standalone': 'enable',
- 'local-standalone-nat': 'enable',
- 'mac-auth-bypass': 'enable',
- 'mac-filter': 'enable',
- 'mac-filter-policy-other': 'allow',
- 'max-clients': '47',
- 'max-clients-ap': '48',
- 'me-disable-thresh': '49',
- 'mesh-backhaul': 'enable',
- 'mpsk': 'enable',
- 'mpsk-concurrent-clients': '52',
- 'multicast-enhance': 'enable',
- 'multicast-rate': '0',
- 'name': 'default_name_55',
- 'okc': 'disable',
- 'passphrase': 'test_value_57',
- 'pmf': 'disable',
- 'pmf-assoc-comeback-timeout': '59',
- 'pmf-sa-query-retry-timeout': '60',
- 'portal-message-override-group': 'test_value_61',
- 'portal-type': 'auth',
- 'probe-resp-suppression': 'enable',
- 'probe-resp-threshold': 'test_value_64',
- 'ptk-rekey': 'enable',
- 'ptk-rekey-intv': '66',
- 'qos-profile': 'test_value_67',
- 'quarantine': 'enable',
- 'radio-2g-threshold': 'test_value_69',
- 'radio-5g-threshold': 'test_value_70',
- 'radio-sensitivity': 'enable',
- 'radius-mac-auth': 'enable',
- 'radius-mac-auth-server': 'test_value_73',
- 'radius-server': 'test_value_74',
- 'rates-11a': '1',
- 'rates-11ac-ss12': 'mcs0/1',
- 'rates-11ac-ss34': 'mcs0/3',
- 'rates-11bg': '1',
- 'rates-11n-ss12': 'mcs0/1',
- 'rates-11n-ss34': 'mcs16/3',
- 'schedule': 'test_value_81',
- 'security': 'open',
- 'security-exempt-list': 'test_value_83',
- 'security-obsolete-option': 'enable',
- 'security-redirect-url': 'test_value_85',
- 'split-tunneling': 'enable',
- 'ssid': 'test_value_87',
- 'tkip-counter-measure': 'enable',
- 'utm-profile': 'test_value_89',
- 'vdom': 'test_value_90',
- 'vlan-auto': 'enable',
- 'vlan-pooling': 'wtp-group',
- 'vlanid': '93',
- 'voice-enterprise': 'disable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'vap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_vap_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_vap': {
- 'random_attribute_not_valid': 'tag',
- 'acct_interim_interval': '3',
- 'alias': 'test_value_4',
- 'auth': 'psk',
- 'broadcast_ssid': 'enable',
- 'broadcast_suppression': 'dhcp-up',
- 'captive_portal_ac_name': 'test_value_8',
- 'captive_portal_macauth_radius_secret': 'test_value_9',
- 'captive_portal_macauth_radius_server': 'test_value_10',
- 'captive_portal_radius_secret': 'test_value_11',
- 'captive_portal_radius_server': 'test_value_12',
- 'captive_portal_session_timeout_interval': '13',
- 'dhcp_lease_time': '14',
- 'dhcp_option82_circuit_id_insertion': 'style-1',
- 'dhcp_option82_insertion': 'enable',
- 'dhcp_option82_remote_id_insertion': 'style-1',
- 'dynamic_vlan': 'enable',
- 'eap_reauth': 'enable',
- 'eap_reauth_intv': '20',
- 'eapol_key_retries': 'disable',
- 'encrypt': 'TKIP',
- 'external_fast_roaming': 'enable',
- 'external_logout': 'test_value_24',
- 'external_web': 'test_value_25',
- 'fast_bss_transition': 'disable',
- 'fast_roaming': 'enable',
- 'ft_mobility_domain': '28',
- 'ft_over_ds': 'disable',
- 'ft_r0_key_lifetime': '30',
- 'gtk_rekey': 'enable',
- 'gtk_rekey_intv': '32',
- 'hotspot20_profile': 'test_value_33',
- 'intra_vap_privacy': 'enable',
- 'ip': 'test_value_35',
- 'key': 'test_value_36',
- 'keyindex': '37',
- 'ldpc': 'disable',
- 'local_authentication': 'enable',
- 'local_bridging': 'enable',
- 'local_lan': 'allow',
- 'local_standalone': 'enable',
- 'local_standalone_nat': 'enable',
- 'mac_auth_bypass': 'enable',
- 'mac_filter': 'enable',
- 'mac_filter_policy_other': 'allow',
- 'max_clients': '47',
- 'max_clients_ap': '48',
- 'me_disable_thresh': '49',
- 'mesh_backhaul': 'enable',
- 'mpsk': 'enable',
- 'mpsk_concurrent_clients': '52',
- 'multicast_enhance': 'enable',
- 'multicast_rate': '0',
- 'name': 'default_name_55',
- 'okc': 'disable',
- 'passphrase': 'test_value_57',
- 'pmf': 'disable',
- 'pmf_assoc_comeback_timeout': '59',
- 'pmf_sa_query_retry_timeout': '60',
- 'portal_message_override_group': 'test_value_61',
- 'portal_type': 'auth',
- 'probe_resp_suppression': 'enable',
- 'probe_resp_threshold': 'test_value_64',
- 'ptk_rekey': 'enable',
- 'ptk_rekey_intv': '66',
- 'qos_profile': 'test_value_67',
- 'quarantine': 'enable',
- 'radio_2g_threshold': 'test_value_69',
- 'radio_5g_threshold': 'test_value_70',
- 'radio_sensitivity': 'enable',
- 'radius_mac_auth': 'enable',
- 'radius_mac_auth_server': 'test_value_73',
- 'radius_server': 'test_value_74',
- 'rates_11a': '1',
- 'rates_11ac_ss12': 'mcs0/1',
- 'rates_11ac_ss34': 'mcs0/3',
- 'rates_11bg': '1',
- 'rates_11n_ss12': 'mcs0/1',
- 'rates_11n_ss34': 'mcs16/3',
- 'schedule': 'test_value_81',
- 'security': 'open',
- 'security_exempt_list': 'test_value_83',
- 'security_obsolete_option': 'enable',
- 'security_redirect_url': 'test_value_85',
- 'split_tunneling': 'enable',
- 'ssid': 'test_value_87',
- 'tkip_counter_measure': 'enable',
- 'utm_profile': 'test_value_89',
- 'vdom': 'test_value_90',
- 'vlan_auto': 'enable',
- 'vlan_pooling': 'wtp-group',
- 'vlanid': '93',
- 'voice_enterprise': 'disable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'acct-interim-interval': '3',
- 'alias': 'test_value_4',
- 'auth': 'psk',
- 'broadcast-ssid': 'enable',
- 'broadcast-suppression': 'dhcp-up',
- 'captive-portal-ac-name': 'test_value_8',
- 'captive-portal-macauth-radius-secret': 'test_value_9',
- 'captive-portal-macauth-radius-server': 'test_value_10',
- 'captive-portal-radius-secret': 'test_value_11',
- 'captive-portal-radius-server': 'test_value_12',
- 'captive-portal-session-timeout-interval': '13',
- 'dhcp-lease-time': '14',
- 'dhcp-option82-circuit-id-insertion': 'style-1',
- 'dhcp-option82-insertion': 'enable',
- 'dhcp-option82-remote-id-insertion': 'style-1',
- 'dynamic-vlan': 'enable',
- 'eap-reauth': 'enable',
- 'eap-reauth-intv': '20',
- 'eapol-key-retries': 'disable',
- 'encrypt': 'TKIP',
- 'external-fast-roaming': 'enable',
- 'external-logout': 'test_value_24',
- 'external-web': 'test_value_25',
- 'fast-bss-transition': 'disable',
- 'fast-roaming': 'enable',
- 'ft-mobility-domain': '28',
- 'ft-over-ds': 'disable',
- 'ft-r0-key-lifetime': '30',
- 'gtk-rekey': 'enable',
- 'gtk-rekey-intv': '32',
- 'hotspot20-profile': 'test_value_33',
- 'intra-vap-privacy': 'enable',
- 'ip': 'test_value_35',
- 'key': 'test_value_36',
- 'keyindex': '37',
- 'ldpc': 'disable',
- 'local-authentication': 'enable',
- 'local-bridging': 'enable',
- 'local-lan': 'allow',
- 'local-standalone': 'enable',
- 'local-standalone-nat': 'enable',
- 'mac-auth-bypass': 'enable',
- 'mac-filter': 'enable',
- 'mac-filter-policy-other': 'allow',
- 'max-clients': '47',
- 'max-clients-ap': '48',
- 'me-disable-thresh': '49',
- 'mesh-backhaul': 'enable',
- 'mpsk': 'enable',
- 'mpsk-concurrent-clients': '52',
- 'multicast-enhance': 'enable',
- 'multicast-rate': '0',
- 'name': 'default_name_55',
- 'okc': 'disable',
- 'passphrase': 'test_value_57',
- 'pmf': 'disable',
- 'pmf-assoc-comeback-timeout': '59',
- 'pmf-sa-query-retry-timeout': '60',
- 'portal-message-override-group': 'test_value_61',
- 'portal-type': 'auth',
- 'probe-resp-suppression': 'enable',
- 'probe-resp-threshold': 'test_value_64',
- 'ptk-rekey': 'enable',
- 'ptk-rekey-intv': '66',
- 'qos-profile': 'test_value_67',
- 'quarantine': 'enable',
- 'radio-2g-threshold': 'test_value_69',
- 'radio-5g-threshold': 'test_value_70',
- 'radio-sensitivity': 'enable',
- 'radius-mac-auth': 'enable',
- 'radius-mac-auth-server': 'test_value_73',
- 'radius-server': 'test_value_74',
- 'rates-11a': '1',
- 'rates-11ac-ss12': 'mcs0/1',
- 'rates-11ac-ss34': 'mcs0/3',
- 'rates-11bg': '1',
- 'rates-11n-ss12': 'mcs0/1',
- 'rates-11n-ss34': 'mcs16/3',
- 'schedule': 'test_value_81',
- 'security': 'open',
- 'security-exempt-list': 'test_value_83',
- 'security-obsolete-option': 'enable',
- 'security-redirect-url': 'test_value_85',
- 'split-tunneling': 'enable',
- 'ssid': 'test_value_87',
- 'tkip-counter-measure': 'enable',
- 'utm-profile': 'test_value_89',
- 'vdom': 'test_value_90',
- 'vlan-auto': 'enable',
- 'vlan-pooling': 'wtp-group',
- 'vlanid': '93',
- 'voice-enterprise': 'disable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'vap', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_vap_group.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_vap_group.py
deleted file mode 100644
index 14c101737e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_vap_group.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_vap_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_vap_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_vap_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_vap_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap_group.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'vap-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_vap_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_vap_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap_group.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'vap-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_vap_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_vap_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap_group.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'vap-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_vap_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_vap_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap_group.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'vap-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_vap_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_vap_group': {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap_group.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'vap-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_vap_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_vap_group': {
- 'random_attribute_not_valid': 'tag',
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_vap_group.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'comment': 'Comment.',
- 'name': 'default_name_4',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'vap-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_wids_profile.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_wids_profile.py
deleted file mode 100644
index 622dbef72e..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_wids_profile.py
+++ /dev/null
@@ -1,679 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_wids_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_wids_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_wids_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wids_profile': {
- 'ap_auto_suppress': 'enable',
- 'ap_bgscan_disable_day': 'sunday',
- 'ap_bgscan_disable_end': 'test_value_5',
- 'ap_bgscan_disable_start': 'test_value_6',
- 'ap_bgscan_duration': '7',
- 'ap_bgscan_idle': '8',
- 'ap_bgscan_intv': '9',
- 'ap_bgscan_period': '10',
- 'ap_bgscan_report_intv': '11',
- 'ap_fgscan_report_intv': '12',
- 'ap_scan': 'disable',
- 'ap_scan_passive': 'enable',
- 'asleap_attack': 'enable',
- 'assoc_flood_thresh': '16',
- 'assoc_flood_time': '17',
- 'assoc_frame_flood': 'enable',
- 'auth_flood_thresh': '19',
- 'auth_flood_time': '20',
- 'auth_frame_flood': 'enable',
- 'comment': 'Comment.',
- 'deauth_broadcast': 'enable',
- 'deauth_unknown_src_thresh': '24',
- 'eapol_fail_flood': 'enable',
- 'eapol_fail_intv': '26',
- 'eapol_fail_thresh': '27',
- 'eapol_logoff_flood': 'enable',
- 'eapol_logoff_intv': '29',
- 'eapol_logoff_thresh': '30',
- 'eapol_pre_fail_flood': 'enable',
- 'eapol_pre_fail_intv': '32',
- 'eapol_pre_fail_thresh': '33',
- 'eapol_pre_succ_flood': 'enable',
- 'eapol_pre_succ_intv': '35',
- 'eapol_pre_succ_thresh': '36',
- 'eapol_start_flood': 'enable',
- 'eapol_start_intv': '38',
- 'eapol_start_thresh': '39',
- 'eapol_succ_flood': 'enable',
- 'eapol_succ_intv': '41',
- 'eapol_succ_thresh': '42',
- 'invalid_mac_oui': 'enable',
- 'long_duration_attack': 'enable',
- 'long_duration_thresh': '45',
- 'name': 'default_name_46',
- 'null_ssid_probe_resp': 'enable',
- 'sensor_mode': 'disable',
- 'spoofed_deauth': 'enable',
- 'weak_wep_iv': 'enable',
- 'wireless_bridge': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wids_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ap-auto-suppress': 'enable',
- 'ap-bgscan-disable-day': 'sunday',
- 'ap-bgscan-disable-end': 'test_value_5',
- 'ap-bgscan-disable-start': 'test_value_6',
- 'ap-bgscan-duration': '7',
- 'ap-bgscan-idle': '8',
- 'ap-bgscan-intv': '9',
- 'ap-bgscan-period': '10',
- 'ap-bgscan-report-intv': '11',
- 'ap-fgscan-report-intv': '12',
- 'ap-scan': 'disable',
- 'ap-scan-passive': 'enable',
- 'asleap-attack': 'enable',
- 'assoc-flood-thresh': '16',
- 'assoc-flood-time': '17',
- 'assoc-frame-flood': 'enable',
- 'auth-flood-thresh': '19',
- 'auth-flood-time': '20',
- 'auth-frame-flood': 'enable',
- 'comment': 'Comment.',
- 'deauth-broadcast': 'enable',
- 'deauth-unknown-src-thresh': '24',
- 'eapol-fail-flood': 'enable',
- 'eapol-fail-intv': '26',
- 'eapol-fail-thresh': '27',
- 'eapol-logoff-flood': 'enable',
- 'eapol-logoff-intv': '29',
- 'eapol-logoff-thresh': '30',
- 'eapol-pre-fail-flood': 'enable',
- 'eapol-pre-fail-intv': '32',
- 'eapol-pre-fail-thresh': '33',
- 'eapol-pre-succ-flood': 'enable',
- 'eapol-pre-succ-intv': '35',
- 'eapol-pre-succ-thresh': '36',
- 'eapol-start-flood': 'enable',
- 'eapol-start-intv': '38',
- 'eapol-start-thresh': '39',
- 'eapol-succ-flood': 'enable',
- 'eapol-succ-intv': '41',
- 'eapol-succ-thresh': '42',
- 'invalid-mac-oui': 'enable',
- 'long-duration-attack': 'enable',
- 'long-duration-thresh': '45',
- 'name': 'default_name_46',
- 'null-ssid-probe-resp': 'enable',
- 'sensor-mode': 'disable',
- 'spoofed-deauth': 'enable',
- 'weak-wep-iv': 'enable',
- 'wireless-bridge': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wids-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_wids_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wids_profile': {
- 'ap_auto_suppress': 'enable',
- 'ap_bgscan_disable_day': 'sunday',
- 'ap_bgscan_disable_end': 'test_value_5',
- 'ap_bgscan_disable_start': 'test_value_6',
- 'ap_bgscan_duration': '7',
- 'ap_bgscan_idle': '8',
- 'ap_bgscan_intv': '9',
- 'ap_bgscan_period': '10',
- 'ap_bgscan_report_intv': '11',
- 'ap_fgscan_report_intv': '12',
- 'ap_scan': 'disable',
- 'ap_scan_passive': 'enable',
- 'asleap_attack': 'enable',
- 'assoc_flood_thresh': '16',
- 'assoc_flood_time': '17',
- 'assoc_frame_flood': 'enable',
- 'auth_flood_thresh': '19',
- 'auth_flood_time': '20',
- 'auth_frame_flood': 'enable',
- 'comment': 'Comment.',
- 'deauth_broadcast': 'enable',
- 'deauth_unknown_src_thresh': '24',
- 'eapol_fail_flood': 'enable',
- 'eapol_fail_intv': '26',
- 'eapol_fail_thresh': '27',
- 'eapol_logoff_flood': 'enable',
- 'eapol_logoff_intv': '29',
- 'eapol_logoff_thresh': '30',
- 'eapol_pre_fail_flood': 'enable',
- 'eapol_pre_fail_intv': '32',
- 'eapol_pre_fail_thresh': '33',
- 'eapol_pre_succ_flood': 'enable',
- 'eapol_pre_succ_intv': '35',
- 'eapol_pre_succ_thresh': '36',
- 'eapol_start_flood': 'enable',
- 'eapol_start_intv': '38',
- 'eapol_start_thresh': '39',
- 'eapol_succ_flood': 'enable',
- 'eapol_succ_intv': '41',
- 'eapol_succ_thresh': '42',
- 'invalid_mac_oui': 'enable',
- 'long_duration_attack': 'enable',
- 'long_duration_thresh': '45',
- 'name': 'default_name_46',
- 'null_ssid_probe_resp': 'enable',
- 'sensor_mode': 'disable',
- 'spoofed_deauth': 'enable',
- 'weak_wep_iv': 'enable',
- 'wireless_bridge': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wids_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ap-auto-suppress': 'enable',
- 'ap-bgscan-disable-day': 'sunday',
- 'ap-bgscan-disable-end': 'test_value_5',
- 'ap-bgscan-disable-start': 'test_value_6',
- 'ap-bgscan-duration': '7',
- 'ap-bgscan-idle': '8',
- 'ap-bgscan-intv': '9',
- 'ap-bgscan-period': '10',
- 'ap-bgscan-report-intv': '11',
- 'ap-fgscan-report-intv': '12',
- 'ap-scan': 'disable',
- 'ap-scan-passive': 'enable',
- 'asleap-attack': 'enable',
- 'assoc-flood-thresh': '16',
- 'assoc-flood-time': '17',
- 'assoc-frame-flood': 'enable',
- 'auth-flood-thresh': '19',
- 'auth-flood-time': '20',
- 'auth-frame-flood': 'enable',
- 'comment': 'Comment.',
- 'deauth-broadcast': 'enable',
- 'deauth-unknown-src-thresh': '24',
- 'eapol-fail-flood': 'enable',
- 'eapol-fail-intv': '26',
- 'eapol-fail-thresh': '27',
- 'eapol-logoff-flood': 'enable',
- 'eapol-logoff-intv': '29',
- 'eapol-logoff-thresh': '30',
- 'eapol-pre-fail-flood': 'enable',
- 'eapol-pre-fail-intv': '32',
- 'eapol-pre-fail-thresh': '33',
- 'eapol-pre-succ-flood': 'enable',
- 'eapol-pre-succ-intv': '35',
- 'eapol-pre-succ-thresh': '36',
- 'eapol-start-flood': 'enable',
- 'eapol-start-intv': '38',
- 'eapol-start-thresh': '39',
- 'eapol-succ-flood': 'enable',
- 'eapol-succ-intv': '41',
- 'eapol-succ-thresh': '42',
- 'invalid-mac-oui': 'enable',
- 'long-duration-attack': 'enable',
- 'long-duration-thresh': '45',
- 'name': 'default_name_46',
- 'null-ssid-probe-resp': 'enable',
- 'sensor-mode': 'disable',
- 'spoofed-deauth': 'enable',
- 'weak-wep-iv': 'enable',
- 'wireless-bridge': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wids-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_wids_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_wids_profile': {
- 'ap_auto_suppress': 'enable',
- 'ap_bgscan_disable_day': 'sunday',
- 'ap_bgscan_disable_end': 'test_value_5',
- 'ap_bgscan_disable_start': 'test_value_6',
- 'ap_bgscan_duration': '7',
- 'ap_bgscan_idle': '8',
- 'ap_bgscan_intv': '9',
- 'ap_bgscan_period': '10',
- 'ap_bgscan_report_intv': '11',
- 'ap_fgscan_report_intv': '12',
- 'ap_scan': 'disable',
- 'ap_scan_passive': 'enable',
- 'asleap_attack': 'enable',
- 'assoc_flood_thresh': '16',
- 'assoc_flood_time': '17',
- 'assoc_frame_flood': 'enable',
- 'auth_flood_thresh': '19',
- 'auth_flood_time': '20',
- 'auth_frame_flood': 'enable',
- 'comment': 'Comment.',
- 'deauth_broadcast': 'enable',
- 'deauth_unknown_src_thresh': '24',
- 'eapol_fail_flood': 'enable',
- 'eapol_fail_intv': '26',
- 'eapol_fail_thresh': '27',
- 'eapol_logoff_flood': 'enable',
- 'eapol_logoff_intv': '29',
- 'eapol_logoff_thresh': '30',
- 'eapol_pre_fail_flood': 'enable',
- 'eapol_pre_fail_intv': '32',
- 'eapol_pre_fail_thresh': '33',
- 'eapol_pre_succ_flood': 'enable',
- 'eapol_pre_succ_intv': '35',
- 'eapol_pre_succ_thresh': '36',
- 'eapol_start_flood': 'enable',
- 'eapol_start_intv': '38',
- 'eapol_start_thresh': '39',
- 'eapol_succ_flood': 'enable',
- 'eapol_succ_intv': '41',
- 'eapol_succ_thresh': '42',
- 'invalid_mac_oui': 'enable',
- 'long_duration_attack': 'enable',
- 'long_duration_thresh': '45',
- 'name': 'default_name_46',
- 'null_ssid_probe_resp': 'enable',
- 'sensor_mode': 'disable',
- 'spoofed_deauth': 'enable',
- 'weak_wep_iv': 'enable',
- 'wireless_bridge': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wids_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'wids-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_wids_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_wids_profile': {
- 'ap_auto_suppress': 'enable',
- 'ap_bgscan_disable_day': 'sunday',
- 'ap_bgscan_disable_end': 'test_value_5',
- 'ap_bgscan_disable_start': 'test_value_6',
- 'ap_bgscan_duration': '7',
- 'ap_bgscan_idle': '8',
- 'ap_bgscan_intv': '9',
- 'ap_bgscan_period': '10',
- 'ap_bgscan_report_intv': '11',
- 'ap_fgscan_report_intv': '12',
- 'ap_scan': 'disable',
- 'ap_scan_passive': 'enable',
- 'asleap_attack': 'enable',
- 'assoc_flood_thresh': '16',
- 'assoc_flood_time': '17',
- 'assoc_frame_flood': 'enable',
- 'auth_flood_thresh': '19',
- 'auth_flood_time': '20',
- 'auth_frame_flood': 'enable',
- 'comment': 'Comment.',
- 'deauth_broadcast': 'enable',
- 'deauth_unknown_src_thresh': '24',
- 'eapol_fail_flood': 'enable',
- 'eapol_fail_intv': '26',
- 'eapol_fail_thresh': '27',
- 'eapol_logoff_flood': 'enable',
- 'eapol_logoff_intv': '29',
- 'eapol_logoff_thresh': '30',
- 'eapol_pre_fail_flood': 'enable',
- 'eapol_pre_fail_intv': '32',
- 'eapol_pre_fail_thresh': '33',
- 'eapol_pre_succ_flood': 'enable',
- 'eapol_pre_succ_intv': '35',
- 'eapol_pre_succ_thresh': '36',
- 'eapol_start_flood': 'enable',
- 'eapol_start_intv': '38',
- 'eapol_start_thresh': '39',
- 'eapol_succ_flood': 'enable',
- 'eapol_succ_intv': '41',
- 'eapol_succ_thresh': '42',
- 'invalid_mac_oui': 'enable',
- 'long_duration_attack': 'enable',
- 'long_duration_thresh': '45',
- 'name': 'default_name_46',
- 'null_ssid_probe_resp': 'enable',
- 'sensor_mode': 'disable',
- 'spoofed_deauth': 'enable',
- 'weak_wep_iv': 'enable',
- 'wireless_bridge': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wids_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'wids-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_wids_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wids_profile': {
- 'ap_auto_suppress': 'enable',
- 'ap_bgscan_disable_day': 'sunday',
- 'ap_bgscan_disable_end': 'test_value_5',
- 'ap_bgscan_disable_start': 'test_value_6',
- 'ap_bgscan_duration': '7',
- 'ap_bgscan_idle': '8',
- 'ap_bgscan_intv': '9',
- 'ap_bgscan_period': '10',
- 'ap_bgscan_report_intv': '11',
- 'ap_fgscan_report_intv': '12',
- 'ap_scan': 'disable',
- 'ap_scan_passive': 'enable',
- 'asleap_attack': 'enable',
- 'assoc_flood_thresh': '16',
- 'assoc_flood_time': '17',
- 'assoc_frame_flood': 'enable',
- 'auth_flood_thresh': '19',
- 'auth_flood_time': '20',
- 'auth_frame_flood': 'enable',
- 'comment': 'Comment.',
- 'deauth_broadcast': 'enable',
- 'deauth_unknown_src_thresh': '24',
- 'eapol_fail_flood': 'enable',
- 'eapol_fail_intv': '26',
- 'eapol_fail_thresh': '27',
- 'eapol_logoff_flood': 'enable',
- 'eapol_logoff_intv': '29',
- 'eapol_logoff_thresh': '30',
- 'eapol_pre_fail_flood': 'enable',
- 'eapol_pre_fail_intv': '32',
- 'eapol_pre_fail_thresh': '33',
- 'eapol_pre_succ_flood': 'enable',
- 'eapol_pre_succ_intv': '35',
- 'eapol_pre_succ_thresh': '36',
- 'eapol_start_flood': 'enable',
- 'eapol_start_intv': '38',
- 'eapol_start_thresh': '39',
- 'eapol_succ_flood': 'enable',
- 'eapol_succ_intv': '41',
- 'eapol_succ_thresh': '42',
- 'invalid_mac_oui': 'enable',
- 'long_duration_attack': 'enable',
- 'long_duration_thresh': '45',
- 'name': 'default_name_46',
- 'null_ssid_probe_resp': 'enable',
- 'sensor_mode': 'disable',
- 'spoofed_deauth': 'enable',
- 'weak_wep_iv': 'enable',
- 'wireless_bridge': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wids_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ap-auto-suppress': 'enable',
- 'ap-bgscan-disable-day': 'sunday',
- 'ap-bgscan-disable-end': 'test_value_5',
- 'ap-bgscan-disable-start': 'test_value_6',
- 'ap-bgscan-duration': '7',
- 'ap-bgscan-idle': '8',
- 'ap-bgscan-intv': '9',
- 'ap-bgscan-period': '10',
- 'ap-bgscan-report-intv': '11',
- 'ap-fgscan-report-intv': '12',
- 'ap-scan': 'disable',
- 'ap-scan-passive': 'enable',
- 'asleap-attack': 'enable',
- 'assoc-flood-thresh': '16',
- 'assoc-flood-time': '17',
- 'assoc-frame-flood': 'enable',
- 'auth-flood-thresh': '19',
- 'auth-flood-time': '20',
- 'auth-frame-flood': 'enable',
- 'comment': 'Comment.',
- 'deauth-broadcast': 'enable',
- 'deauth-unknown-src-thresh': '24',
- 'eapol-fail-flood': 'enable',
- 'eapol-fail-intv': '26',
- 'eapol-fail-thresh': '27',
- 'eapol-logoff-flood': 'enable',
- 'eapol-logoff-intv': '29',
- 'eapol-logoff-thresh': '30',
- 'eapol-pre-fail-flood': 'enable',
- 'eapol-pre-fail-intv': '32',
- 'eapol-pre-fail-thresh': '33',
- 'eapol-pre-succ-flood': 'enable',
- 'eapol-pre-succ-intv': '35',
- 'eapol-pre-succ-thresh': '36',
- 'eapol-start-flood': 'enable',
- 'eapol-start-intv': '38',
- 'eapol-start-thresh': '39',
- 'eapol-succ-flood': 'enable',
- 'eapol-succ-intv': '41',
- 'eapol-succ-thresh': '42',
- 'invalid-mac-oui': 'enable',
- 'long-duration-attack': 'enable',
- 'long-duration-thresh': '45',
- 'name': 'default_name_46',
- 'null-ssid-probe-resp': 'enable',
- 'sensor-mode': 'disable',
- 'spoofed-deauth': 'enable',
- 'weak-wep-iv': 'enable',
- 'wireless-bridge': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wids-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_wids_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wids_profile': {
- 'random_attribute_not_valid': 'tag',
- 'ap_auto_suppress': 'enable',
- 'ap_bgscan_disable_day': 'sunday',
- 'ap_bgscan_disable_end': 'test_value_5',
- 'ap_bgscan_disable_start': 'test_value_6',
- 'ap_bgscan_duration': '7',
- 'ap_bgscan_idle': '8',
- 'ap_bgscan_intv': '9',
- 'ap_bgscan_period': '10',
- 'ap_bgscan_report_intv': '11',
- 'ap_fgscan_report_intv': '12',
- 'ap_scan': 'disable',
- 'ap_scan_passive': 'enable',
- 'asleap_attack': 'enable',
- 'assoc_flood_thresh': '16',
- 'assoc_flood_time': '17',
- 'assoc_frame_flood': 'enable',
- 'auth_flood_thresh': '19',
- 'auth_flood_time': '20',
- 'auth_frame_flood': 'enable',
- 'comment': 'Comment.',
- 'deauth_broadcast': 'enable',
- 'deauth_unknown_src_thresh': '24',
- 'eapol_fail_flood': 'enable',
- 'eapol_fail_intv': '26',
- 'eapol_fail_thresh': '27',
- 'eapol_logoff_flood': 'enable',
- 'eapol_logoff_intv': '29',
- 'eapol_logoff_thresh': '30',
- 'eapol_pre_fail_flood': 'enable',
- 'eapol_pre_fail_intv': '32',
- 'eapol_pre_fail_thresh': '33',
- 'eapol_pre_succ_flood': 'enable',
- 'eapol_pre_succ_intv': '35',
- 'eapol_pre_succ_thresh': '36',
- 'eapol_start_flood': 'enable',
- 'eapol_start_intv': '38',
- 'eapol_start_thresh': '39',
- 'eapol_succ_flood': 'enable',
- 'eapol_succ_intv': '41',
- 'eapol_succ_thresh': '42',
- 'invalid_mac_oui': 'enable',
- 'long_duration_attack': 'enable',
- 'long_duration_thresh': '45',
- 'name': 'default_name_46',
- 'null_ssid_probe_resp': 'enable',
- 'sensor_mode': 'disable',
- 'spoofed_deauth': 'enable',
- 'weak_wep_iv': 'enable',
- 'wireless_bridge': 'enable'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wids_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'ap-auto-suppress': 'enable',
- 'ap-bgscan-disable-day': 'sunday',
- 'ap-bgscan-disable-end': 'test_value_5',
- 'ap-bgscan-disable-start': 'test_value_6',
- 'ap-bgscan-duration': '7',
- 'ap-bgscan-idle': '8',
- 'ap-bgscan-intv': '9',
- 'ap-bgscan-period': '10',
- 'ap-bgscan-report-intv': '11',
- 'ap-fgscan-report-intv': '12',
- 'ap-scan': 'disable',
- 'ap-scan-passive': 'enable',
- 'asleap-attack': 'enable',
- 'assoc-flood-thresh': '16',
- 'assoc-flood-time': '17',
- 'assoc-frame-flood': 'enable',
- 'auth-flood-thresh': '19',
- 'auth-flood-time': '20',
- 'auth-frame-flood': 'enable',
- 'comment': 'Comment.',
- 'deauth-broadcast': 'enable',
- 'deauth-unknown-src-thresh': '24',
- 'eapol-fail-flood': 'enable',
- 'eapol-fail-intv': '26',
- 'eapol-fail-thresh': '27',
- 'eapol-logoff-flood': 'enable',
- 'eapol-logoff-intv': '29',
- 'eapol-logoff-thresh': '30',
- 'eapol-pre-fail-flood': 'enable',
- 'eapol-pre-fail-intv': '32',
- 'eapol-pre-fail-thresh': '33',
- 'eapol-pre-succ-flood': 'enable',
- 'eapol-pre-succ-intv': '35',
- 'eapol-pre-succ-thresh': '36',
- 'eapol-start-flood': 'enable',
- 'eapol-start-intv': '38',
- 'eapol-start-thresh': '39',
- 'eapol-succ-flood': 'enable',
- 'eapol-succ-intv': '41',
- 'eapol-succ-thresh': '42',
- 'invalid-mac-oui': 'enable',
- 'long-duration-attack': 'enable',
- 'long-duration-thresh': '45',
- 'name': 'default_name_46',
- 'null-ssid-probe-resp': 'enable',
- 'sensor-mode': 'disable',
- 'spoofed-deauth': 'enable',
- 'weak-wep-iv': 'enable',
- 'wireless-bridge': 'enable'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wids-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_wtp.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_wtp.py
deleted file mode 100644
index aea02faba5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_wtp.py
+++ /dev/null
@@ -1,509 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_wtp
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_wtp.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_wtp_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp': {
- 'admin': 'discovered',
- 'allowaccess': 'telnet',
- 'bonjour_profile': 'test_value_5',
- 'coordinate_enable': 'enable',
- 'coordinate_latitude': 'test_value_7',
- 'coordinate_longitude': 'test_value_8',
- 'coordinate_x': 'test_value_9',
- 'coordinate_y': 'test_value_10',
- 'image_download': 'enable',
- 'index': '12',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'location': 'test_value_15',
- 'login_passwd': 'test_value_16',
- 'login_passwd_change': 'yes',
- 'mesh_bridge_enable': 'default',
- 'name': 'default_name_19',
- 'override_allowaccess': 'enable',
- 'override_ip_fragment': 'enable',
- 'override_lan': 'enable',
- 'override_led_state': 'enable',
- 'override_login_passwd_change': 'enable',
- 'override_split_tunnel': 'enable',
- 'override_wan_port_mode': 'enable',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '29',
- 'tun_mtu_uplink': '30',
- 'wan_port_mode': 'wan-lan',
- 'wtp_id': 'test_value_32',
- 'wtp_mode': 'normal',
- 'wtp_profile': 'test_value_34'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'discovered',
- 'allowaccess': 'telnet',
- 'bonjour-profile': 'test_value_5',
- 'coordinate-enable': 'enable',
- 'coordinate-latitude': 'test_value_7',
- 'coordinate-longitude': 'test_value_8',
- 'coordinate-x': 'test_value_9',
- 'coordinate-y': 'test_value_10',
- 'image-download': 'enable',
- 'index': '12',
- 'ip-fragment-preventing': 'tcp-mss-adjust',
- 'led-state': 'enable',
- 'location': 'test_value_15',
- 'login-passwd': 'test_value_16',
- 'login-passwd-change': 'yes',
- 'mesh-bridge-enable': 'default',
- 'name': 'default_name_19',
- 'override-allowaccess': 'enable',
- 'override-ip-fragment': 'enable',
- 'override-lan': 'enable',
- 'override-led-state': 'enable',
- 'override-login-passwd-change': 'enable',
- 'override-split-tunnel': 'enable',
- 'override-wan-port-mode': 'enable',
- 'split-tunneling-acl-local-ap-subnet': 'enable',
- 'split-tunneling-acl-path': 'tunnel',
- 'tun-mtu-downlink': '29',
- 'tun-mtu-uplink': '30',
- 'wan-port-mode': 'wan-lan',
- 'wtp-id': 'test_value_32',
- 'wtp-mode': 'normal',
- 'wtp-profile': 'test_value_34'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_wtp_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp': {
- 'admin': 'discovered',
- 'allowaccess': 'telnet',
- 'bonjour_profile': 'test_value_5',
- 'coordinate_enable': 'enable',
- 'coordinate_latitude': 'test_value_7',
- 'coordinate_longitude': 'test_value_8',
- 'coordinate_x': 'test_value_9',
- 'coordinate_y': 'test_value_10',
- 'image_download': 'enable',
- 'index': '12',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'location': 'test_value_15',
- 'login_passwd': 'test_value_16',
- 'login_passwd_change': 'yes',
- 'mesh_bridge_enable': 'default',
- 'name': 'default_name_19',
- 'override_allowaccess': 'enable',
- 'override_ip_fragment': 'enable',
- 'override_lan': 'enable',
- 'override_led_state': 'enable',
- 'override_login_passwd_change': 'enable',
- 'override_split_tunnel': 'enable',
- 'override_wan_port_mode': 'enable',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '29',
- 'tun_mtu_uplink': '30',
- 'wan_port_mode': 'wan-lan',
- 'wtp_id': 'test_value_32',
- 'wtp_mode': 'normal',
- 'wtp_profile': 'test_value_34'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'discovered',
- 'allowaccess': 'telnet',
- 'bonjour-profile': 'test_value_5',
- 'coordinate-enable': 'enable',
- 'coordinate-latitude': 'test_value_7',
- 'coordinate-longitude': 'test_value_8',
- 'coordinate-x': 'test_value_9',
- 'coordinate-y': 'test_value_10',
- 'image-download': 'enable',
- 'index': '12',
- 'ip-fragment-preventing': 'tcp-mss-adjust',
- 'led-state': 'enable',
- 'location': 'test_value_15',
- 'login-passwd': 'test_value_16',
- 'login-passwd-change': 'yes',
- 'mesh-bridge-enable': 'default',
- 'name': 'default_name_19',
- 'override-allowaccess': 'enable',
- 'override-ip-fragment': 'enable',
- 'override-lan': 'enable',
- 'override-led-state': 'enable',
- 'override-login-passwd-change': 'enable',
- 'override-split-tunnel': 'enable',
- 'override-wan-port-mode': 'enable',
- 'split-tunneling-acl-local-ap-subnet': 'enable',
- 'split-tunneling-acl-path': 'tunnel',
- 'tun-mtu-downlink': '29',
- 'tun-mtu-uplink': '30',
- 'wan-port-mode': 'wan-lan',
- 'wtp-id': 'test_value_32',
- 'wtp-mode': 'normal',
- 'wtp-profile': 'test_value_34'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_wtp_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_wtp': {
- 'admin': 'discovered',
- 'allowaccess': 'telnet',
- 'bonjour_profile': 'test_value_5',
- 'coordinate_enable': 'enable',
- 'coordinate_latitude': 'test_value_7',
- 'coordinate_longitude': 'test_value_8',
- 'coordinate_x': 'test_value_9',
- 'coordinate_y': 'test_value_10',
- 'image_download': 'enable',
- 'index': '12',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'location': 'test_value_15',
- 'login_passwd': 'test_value_16',
- 'login_passwd_change': 'yes',
- 'mesh_bridge_enable': 'default',
- 'name': 'default_name_19',
- 'override_allowaccess': 'enable',
- 'override_ip_fragment': 'enable',
- 'override_lan': 'enable',
- 'override_led_state': 'enable',
- 'override_login_passwd_change': 'enable',
- 'override_split_tunnel': 'enable',
- 'override_wan_port_mode': 'enable',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '29',
- 'tun_mtu_uplink': '30',
- 'wan_port_mode': 'wan-lan',
- 'wtp_id': 'test_value_32',
- 'wtp_mode': 'normal',
- 'wtp_profile': 'test_value_34'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'wtp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_wtp_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_wtp': {
- 'admin': 'discovered',
- 'allowaccess': 'telnet',
- 'bonjour_profile': 'test_value_5',
- 'coordinate_enable': 'enable',
- 'coordinate_latitude': 'test_value_7',
- 'coordinate_longitude': 'test_value_8',
- 'coordinate_x': 'test_value_9',
- 'coordinate_y': 'test_value_10',
- 'image_download': 'enable',
- 'index': '12',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'location': 'test_value_15',
- 'login_passwd': 'test_value_16',
- 'login_passwd_change': 'yes',
- 'mesh_bridge_enable': 'default',
- 'name': 'default_name_19',
- 'override_allowaccess': 'enable',
- 'override_ip_fragment': 'enable',
- 'override_lan': 'enable',
- 'override_led_state': 'enable',
- 'override_login_passwd_change': 'enable',
- 'override_split_tunnel': 'enable',
- 'override_wan_port_mode': 'enable',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '29',
- 'tun_mtu_uplink': '30',
- 'wan_port_mode': 'wan-lan',
- 'wtp_id': 'test_value_32',
- 'wtp_mode': 'normal',
- 'wtp_profile': 'test_value_34'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'wtp', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_wtp_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp': {
- 'admin': 'discovered',
- 'allowaccess': 'telnet',
- 'bonjour_profile': 'test_value_5',
- 'coordinate_enable': 'enable',
- 'coordinate_latitude': 'test_value_7',
- 'coordinate_longitude': 'test_value_8',
- 'coordinate_x': 'test_value_9',
- 'coordinate_y': 'test_value_10',
- 'image_download': 'enable',
- 'index': '12',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'location': 'test_value_15',
- 'login_passwd': 'test_value_16',
- 'login_passwd_change': 'yes',
- 'mesh_bridge_enable': 'default',
- 'name': 'default_name_19',
- 'override_allowaccess': 'enable',
- 'override_ip_fragment': 'enable',
- 'override_lan': 'enable',
- 'override_led_state': 'enable',
- 'override_login_passwd_change': 'enable',
- 'override_split_tunnel': 'enable',
- 'override_wan_port_mode': 'enable',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '29',
- 'tun_mtu_uplink': '30',
- 'wan_port_mode': 'wan-lan',
- 'wtp_id': 'test_value_32',
- 'wtp_mode': 'normal',
- 'wtp_profile': 'test_value_34'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'discovered',
- 'allowaccess': 'telnet',
- 'bonjour-profile': 'test_value_5',
- 'coordinate-enable': 'enable',
- 'coordinate-latitude': 'test_value_7',
- 'coordinate-longitude': 'test_value_8',
- 'coordinate-x': 'test_value_9',
- 'coordinate-y': 'test_value_10',
- 'image-download': 'enable',
- 'index': '12',
- 'ip-fragment-preventing': 'tcp-mss-adjust',
- 'led-state': 'enable',
- 'location': 'test_value_15',
- 'login-passwd': 'test_value_16',
- 'login-passwd-change': 'yes',
- 'mesh-bridge-enable': 'default',
- 'name': 'default_name_19',
- 'override-allowaccess': 'enable',
- 'override-ip-fragment': 'enable',
- 'override-lan': 'enable',
- 'override-led-state': 'enable',
- 'override-login-passwd-change': 'enable',
- 'override-split-tunnel': 'enable',
- 'override-wan-port-mode': 'enable',
- 'split-tunneling-acl-local-ap-subnet': 'enable',
- 'split-tunneling-acl-path': 'tunnel',
- 'tun-mtu-downlink': '29',
- 'tun-mtu-uplink': '30',
- 'wan-port-mode': 'wan-lan',
- 'wtp-id': 'test_value_32',
- 'wtp-mode': 'normal',
- 'wtp-profile': 'test_value_34'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_wtp_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp': {
- 'random_attribute_not_valid': 'tag',
- 'admin': 'discovered',
- 'allowaccess': 'telnet',
- 'bonjour_profile': 'test_value_5',
- 'coordinate_enable': 'enable',
- 'coordinate_latitude': 'test_value_7',
- 'coordinate_longitude': 'test_value_8',
- 'coordinate_x': 'test_value_9',
- 'coordinate_y': 'test_value_10',
- 'image_download': 'enable',
- 'index': '12',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'location': 'test_value_15',
- 'login_passwd': 'test_value_16',
- 'login_passwd_change': 'yes',
- 'mesh_bridge_enable': 'default',
- 'name': 'default_name_19',
- 'override_allowaccess': 'enable',
- 'override_ip_fragment': 'enable',
- 'override_lan': 'enable',
- 'override_led_state': 'enable',
- 'override_login_passwd_change': 'enable',
- 'override_split_tunnel': 'enable',
- 'override_wan_port_mode': 'enable',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '29',
- 'tun_mtu_uplink': '30',
- 'wan_port_mode': 'wan-lan',
- 'wtp_id': 'test_value_32',
- 'wtp_mode': 'normal',
- 'wtp_profile': 'test_value_34'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'admin': 'discovered',
- 'allowaccess': 'telnet',
- 'bonjour-profile': 'test_value_5',
- 'coordinate-enable': 'enable',
- 'coordinate-latitude': 'test_value_7',
- 'coordinate-longitude': 'test_value_8',
- 'coordinate-x': 'test_value_9',
- 'coordinate-y': 'test_value_10',
- 'image-download': 'enable',
- 'index': '12',
- 'ip-fragment-preventing': 'tcp-mss-adjust',
- 'led-state': 'enable',
- 'location': 'test_value_15',
- 'login-passwd': 'test_value_16',
- 'login-passwd-change': 'yes',
- 'mesh-bridge-enable': 'default',
- 'name': 'default_name_19',
- 'override-allowaccess': 'enable',
- 'override-ip-fragment': 'enable',
- 'override-lan': 'enable',
- 'override-led-state': 'enable',
- 'override-login-passwd-change': 'enable',
- 'override-split-tunnel': 'enable',
- 'override-wan-port-mode': 'enable',
- 'split-tunneling-acl-local-ap-subnet': 'enable',
- 'split-tunneling-acl-path': 'tunnel',
- 'tun-mtu-downlink': '29',
- 'tun-mtu-uplink': '30',
- 'wan-port-mode': 'wan-lan',
- 'wtp-id': 'test_value_32',
- 'wtp-mode': 'normal',
- 'wtp-profile': 'test_value_34'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_wtp_group.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_wtp_group.py
deleted file mode 100644
index 3490f945b5..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_wtp_group.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_wtp_group
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_wtp_group.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_wtp_group_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp_group': {
- 'name': 'default_name_3',
- 'platform_type': 'AP-11N',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_group.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'platform-type': 'AP-11N',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_wtp_group_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp_group': {
- 'name': 'default_name_3',
- 'platform_type': 'AP-11N',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_group.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'platform-type': 'AP-11N',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_wtp_group_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_wtp_group': {
- 'name': 'default_name_3',
- 'platform_type': 'AP-11N',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_group.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'wtp-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_wtp_group_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_wtp_group': {
- 'name': 'default_name_3',
- 'platform_type': 'AP-11N',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_group.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'wtp-group', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_wtp_group_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp_group': {
- 'name': 'default_name_3',
- 'platform_type': 'AP-11N',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_group.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'platform-type': 'AP-11N',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_wtp_group_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp_group': {
- 'random_attribute_not_valid': 'tag',
- 'name': 'default_name_3',
- 'platform_type': 'AP-11N',
-
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_group.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'name': 'default_name_3',
- 'platform-type': 'AP-11N',
-
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp-group', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
diff --git a/test/units/modules/network/fortios/test_fortios_wireless_controller_wtp_profile.py b/test/units/modules/network/fortios/test_fortios_wireless_controller_wtp_profile.py
deleted file mode 100644
index d578db5802..0000000000
--- a/test/units/modules/network/fortios/test_fortios_wireless_controller_wtp_profile.py
+++ /dev/null
@@ -1,439 +0,0 @@
-# Copyright 2019 Fortinet, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <https://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-import pytest
-from mock import ANY
-from ansible.module_utils.network.fortios.fortios import FortiOSHandler
-
-try:
- from ansible.modules.network.fortios import fortios_wireless_controller_wtp_profile
-except ImportError:
- pytest.skip("Could not load required modules for testing", allow_module_level=True)
-
-
-@pytest.fixture(autouse=True)
-def connection_mock(mocker):
- connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_wireless_controller_wtp_profile.Connection')
- return connection_class_mock
-
-
-fos_instance = FortiOSHandler(connection_mock)
-
-
-def test_wireless_controller_wtp_profile_creation(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp_profile': {
- 'allowaccess': 'telnet',
- 'ap_country': 'NA',
- 'ble_profile': 'test_value_5',
- 'comment': 'Comment.',
- 'control_message_offload': 'ebp-frame',
- 'dtls_in_kernel': 'enable',
- 'dtls_policy': 'clear-text',
- 'energy_efficient_ethernet': 'enable',
- 'ext_info_enable': 'enable',
- 'handoff_roaming': 'enable',
- 'handoff_rssi': '13',
- 'handoff_sta_thresh': '14',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'lldp': 'enable',
- 'login_passwd': 'test_value_18',
- 'login_passwd_change': 'yes',
- 'max_clients': '20',
- 'name': 'default_name_21',
- 'poe_mode': 'auto',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '25',
- 'tun_mtu_uplink': '26',
- 'wan_port_mode': 'wan-lan'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'allowaccess': 'telnet',
- 'ap-country': 'NA',
- 'ble-profile': 'test_value_5',
- 'comment': 'Comment.',
- 'control-message-offload': 'ebp-frame',
- 'dtls-in-kernel': 'enable',
- 'dtls-policy': 'clear-text',
- 'energy-efficient-ethernet': 'enable',
- 'ext-info-enable': 'enable',
- 'handoff-roaming': 'enable',
- 'handoff-rssi': '13',
- 'handoff-sta-thresh': '14',
- 'ip-fragment-preventing': 'tcp-mss-adjust',
- 'led-state': 'enable',
- 'lldp': 'enable',
- 'login-passwd': 'test_value_18',
- 'login-passwd-change': 'yes',
- 'max-clients': '20',
- 'name': 'default_name_21',
- 'poe-mode': 'auto',
- 'split-tunneling-acl-local-ap-subnet': 'enable',
- 'split-tunneling-acl-path': 'tunnel',
- 'tun-mtu-downlink': '25',
- 'tun-mtu-uplink': '26',
- 'wan-port-mode': 'wan-lan'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_wtp_profile_creation_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp_profile': {
- 'allowaccess': 'telnet',
- 'ap_country': 'NA',
- 'ble_profile': 'test_value_5',
- 'comment': 'Comment.',
- 'control_message_offload': 'ebp-frame',
- 'dtls_in_kernel': 'enable',
- 'dtls_policy': 'clear-text',
- 'energy_efficient_ethernet': 'enable',
- 'ext_info_enable': 'enable',
- 'handoff_roaming': 'enable',
- 'handoff_rssi': '13',
- 'handoff_sta_thresh': '14',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'lldp': 'enable',
- 'login_passwd': 'test_value_18',
- 'login_passwd_change': 'yes',
- 'max_clients': '20',
- 'name': 'default_name_21',
- 'poe_mode': 'auto',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '25',
- 'tun_mtu_uplink': '26',
- 'wan_port_mode': 'wan-lan'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'allowaccess': 'telnet',
- 'ap-country': 'NA',
- 'ble-profile': 'test_value_5',
- 'comment': 'Comment.',
- 'control-message-offload': 'ebp-frame',
- 'dtls-in-kernel': 'enable',
- 'dtls-policy': 'clear-text',
- 'energy-efficient-ethernet': 'enable',
- 'ext-info-enable': 'enable',
- 'handoff-roaming': 'enable',
- 'handoff-rssi': '13',
- 'handoff-sta-thresh': '14',
- 'ip-fragment-preventing': 'tcp-mss-adjust',
- 'led-state': 'enable',
- 'lldp': 'enable',
- 'login-passwd': 'test_value_18',
- 'login-passwd-change': 'yes',
- 'max-clients': '20',
- 'name': 'default_name_21',
- 'poe-mode': 'auto',
- 'split-tunneling-acl-local-ap-subnet': 'enable',
- 'split-tunneling-acl-path': 'tunnel',
- 'tun-mtu-downlink': '25',
- 'tun-mtu-uplink': '26',
- 'wan-port-mode': 'wan-lan'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_wtp_profile_removal(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_wtp_profile': {
- 'allowaccess': 'telnet',
- 'ap_country': 'NA',
- 'ble_profile': 'test_value_5',
- 'comment': 'Comment.',
- 'control_message_offload': 'ebp-frame',
- 'dtls_in_kernel': 'enable',
- 'dtls_policy': 'clear-text',
- 'energy_efficient_ethernet': 'enable',
- 'ext_info_enable': 'enable',
- 'handoff_roaming': 'enable',
- 'handoff_rssi': '13',
- 'handoff_sta_thresh': '14',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'lldp': 'enable',
- 'login_passwd': 'test_value_18',
- 'login_passwd_change': 'yes',
- 'max_clients': '20',
- 'name': 'default_name_21',
- 'poe_mode': 'auto',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '25',
- 'tun_mtu_uplink': '26',
- 'wan_port_mode': 'wan-lan'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'wtp-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200
-
-
-def test_wireless_controller_wtp_profile_deletion_fails(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
- delete_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'absent',
- 'wireless_controller_wtp_profile': {
- 'allowaccess': 'telnet',
- 'ap_country': 'NA',
- 'ble_profile': 'test_value_5',
- 'comment': 'Comment.',
- 'control_message_offload': 'ebp-frame',
- 'dtls_in_kernel': 'enable',
- 'dtls_policy': 'clear-text',
- 'energy_efficient_ethernet': 'enable',
- 'ext_info_enable': 'enable',
- 'handoff_roaming': 'enable',
- 'handoff_rssi': '13',
- 'handoff_sta_thresh': '14',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'lldp': 'enable',
- 'login_passwd': 'test_value_18',
- 'login_passwd_change': 'yes',
- 'max_clients': '20',
- 'name': 'default_name_21',
- 'poe_mode': 'auto',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '25',
- 'tun_mtu_uplink': '26',
- 'wan_port_mode': 'wan-lan'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_profile.fortios_wireless_controller(input_data, fos_instance)
-
- delete_method_mock.assert_called_with('wireless-controller', 'wtp-profile', mkey=ANY, vdom='root')
- schema_method_mock.assert_not_called()
- assert is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 500
-
-
-def test_wireless_controller_wtp_profile_idempotent(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp_profile': {
- 'allowaccess': 'telnet',
- 'ap_country': 'NA',
- 'ble_profile': 'test_value_5',
- 'comment': 'Comment.',
- 'control_message_offload': 'ebp-frame',
- 'dtls_in_kernel': 'enable',
- 'dtls_policy': 'clear-text',
- 'energy_efficient_ethernet': 'enable',
- 'ext_info_enable': 'enable',
- 'handoff_roaming': 'enable',
- 'handoff_rssi': '13',
- 'handoff_sta_thresh': '14',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'lldp': 'enable',
- 'login_passwd': 'test_value_18',
- 'login_passwd_change': 'yes',
- 'max_clients': '20',
- 'name': 'default_name_21',
- 'poe_mode': 'auto',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '25',
- 'tun_mtu_uplink': '26',
- 'wan_port_mode': 'wan-lan'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'allowaccess': 'telnet',
- 'ap-country': 'NA',
- 'ble-profile': 'test_value_5',
- 'comment': 'Comment.',
- 'control-message-offload': 'ebp-frame',
- 'dtls-in-kernel': 'enable',
- 'dtls-policy': 'clear-text',
- 'energy-efficient-ethernet': 'enable',
- 'ext-info-enable': 'enable',
- 'handoff-roaming': 'enable',
- 'handoff-rssi': '13',
- 'handoff-sta-thresh': '14',
- 'ip-fragment-preventing': 'tcp-mss-adjust',
- 'led-state': 'enable',
- 'lldp': 'enable',
- 'login-passwd': 'test_value_18',
- 'login-passwd-change': 'yes',
- 'max-clients': '20',
- 'name': 'default_name_21',
- 'poe-mode': 'auto',
- 'split-tunneling-acl-local-ap-subnet': 'enable',
- 'split-tunneling-acl-path': 'tunnel',
- 'tun-mtu-downlink': '25',
- 'tun-mtu-uplink': '26',
- 'wan-port-mode': 'wan-lan'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert not changed
- assert response['status'] == 'error'
- assert response['http_status'] == 404
-
-
-def test_wireless_controller_wtp_profile_filter_foreign_attributes(mocker):
- schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')
-
- set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
- set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)
-
- input_data = {
- 'username': 'admin',
- 'state': 'present',
- 'wireless_controller_wtp_profile': {
- 'random_attribute_not_valid': 'tag',
- 'allowaccess': 'telnet',
- 'ap_country': 'NA',
- 'ble_profile': 'test_value_5',
- 'comment': 'Comment.',
- 'control_message_offload': 'ebp-frame',
- 'dtls_in_kernel': 'enable',
- 'dtls_policy': 'clear-text',
- 'energy_efficient_ethernet': 'enable',
- 'ext_info_enable': 'enable',
- 'handoff_roaming': 'enable',
- 'handoff_rssi': '13',
- 'handoff_sta_thresh': '14',
- 'ip_fragment_preventing': 'tcp-mss-adjust',
- 'led_state': 'enable',
- 'lldp': 'enable',
- 'login_passwd': 'test_value_18',
- 'login_passwd_change': 'yes',
- 'max_clients': '20',
- 'name': 'default_name_21',
- 'poe_mode': 'auto',
- 'split_tunneling_acl_local_ap_subnet': 'enable',
- 'split_tunneling_acl_path': 'tunnel',
- 'tun_mtu_downlink': '25',
- 'tun_mtu_uplink': '26',
- 'wan_port_mode': 'wan-lan'
- },
- 'vdom': 'root'}
-
- is_error, changed, response = fortios_wireless_controller_wtp_profile.fortios_wireless_controller(input_data, fos_instance)
-
- expected_data = {
- 'allowaccess': 'telnet',
- 'ap-country': 'NA',
- 'ble-profile': 'test_value_5',
- 'comment': 'Comment.',
- 'control-message-offload': 'ebp-frame',
- 'dtls-in-kernel': 'enable',
- 'dtls-policy': 'clear-text',
- 'energy-efficient-ethernet': 'enable',
- 'ext-info-enable': 'enable',
- 'handoff-roaming': 'enable',
- 'handoff-rssi': '13',
- 'handoff-sta-thresh': '14',
- 'ip-fragment-preventing': 'tcp-mss-adjust',
- 'led-state': 'enable',
- 'lldp': 'enable',
- 'login-passwd': 'test_value_18',
- 'login-passwd-change': 'yes',
- 'max-clients': '20',
- 'name': 'default_name_21',
- 'poe-mode': 'auto',
- 'split-tunneling-acl-local-ap-subnet': 'enable',
- 'split-tunneling-acl-path': 'tunnel',
- 'tun-mtu-downlink': '25',
- 'tun-mtu-uplink': '26',
- 'wan-port-mode': 'wan-lan'
- }
-
- set_method_mock.assert_called_with('wireless-controller', 'wtp-profile', data=expected_data, vdom='root')
- schema_method_mock.assert_not_called()
- assert not is_error
- assert changed
- assert response['status'] == 'success'
- assert response['http_status'] == 200