3. PyTan Tests¶
3.1. Valid Server Functional Tests¶
This contains valid functional tests for pytan.
These functional tests require a connection to a Tanium server in order to run. The connection info is pulled from the SERVER_INFO dictionary in test/API_INFO.py.
These tests all use ddt
, a package that provides for data driven tests via JSON files.
-
class
test_pytan_valid_server_tests.
ValidServerTests
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
classmethod
setUpClass
()¶
-
setup_test
()¶
-
classmethod
tearDownClass
()¶
-
test_invalid_create_object_1_invalid_create_sensor
()¶
-
test_invalid_create_object_from_json_1_invalid_create_saved_action_from_json
()¶
-
test_invalid_create_object_from_json_2_invalid_create_client_from_json
()¶
-
test_invalid_create_object_from_json_3_invalid_create_userrole_from_json
()¶
-
test_invalid_create_object_from_json_4_invalid_create_setting_from_json
()¶
-
test_invalid_deploy_action_1_invalid_deploy_action_run_false
()¶
-
test_invalid_deploy_action_2_invalid_deploy_action_package_help
()¶
-
test_invalid_deploy_action_3_invalid_deploy_action_package
()¶
-
test_invalid_deploy_action_4_invalid_deploy_action_options_help
()¶
-
test_invalid_deploy_action_5_invalid_deploy_action_empty_package
()¶
-
test_invalid_deploy_action_6_invalid_deploy_action_filters_help
()¶
-
test_invalid_deploy_action_7_invalid_deploy_action_missing_parameters
()¶
-
test_invalid_export_basetype_1_invalid_export_basetype_csv_bad_explode_type
()¶
-
test_invalid_export_basetype_2_invalid_export_basetype_csv_bad_sort_sub_type
()¶
-
test_invalid_export_basetype_3_invalid_export_basetype_csv_bad_sort_type
()¶
-
test_invalid_export_basetype_4_invalid_export_basetype_xml_bad_minimal_type
()¶
-
test_invalid_export_basetype_5_invalid_export_basetype_json_bad_include_type
()¶
-
test_invalid_export_basetype_6_invalid_export_basetype_json_bad_explode_type
()¶
-
test_invalid_export_basetype_7_invalid_export_basetype_bad_format
()¶
-
test_invalid_export_resultset_1_invalid_export_resultset_csv_bad_sort_sub_type
()¶
-
test_invalid_export_resultset_2_invalid_export_resultset_csv_bad_sort_type
()¶
-
test_invalid_export_resultset_3_invalid_export_resultset_csv_bad_expand_type
()¶
-
test_invalid_export_resultset_4_invalid_export_resultset_csv_bad_sensors_sub_type
()¶
-
test_invalid_export_resultset_5_invalid_export_resultset_bad_format
()¶
-
test_invalid_get_object_1_invalid_get_action_single_by_name
()¶
-
test_invalid_get_object_2_invalid_get_question_by_name
()¶
-
test_invalid_question_1_invalid_ask_manual_question_sensor_help
()¶
-
test_invalid_question_2_invalid_ask_manual_question_bad_filter
()¶
-
test_invalid_question_3_invalid_ask_manual_question_filter_help
()¶
-
test_invalid_question_4_invalid_ask_manual_question_bad_option
()¶
-
test_invalid_question_5_invalid_ask_manual_question_missing_parameter_split
()¶
-
test_invalid_question_6_invalid_ask_manual_question_option_help
()¶
-
test_invalid_question_7_invalid_ask_parsed_question_no_picker
()¶
-
test_invalid_question_8_invalid_ask_manual_question_too_many_parameter_blocks
()¶
-
test_invalid_question_9_invalid_ask_manual_question_bad_sensorname
()¶
-
test_valid_create_object_1_create_user
()¶
-
test_valid_create_object_2_create_package
()¶
-
test_valid_create_object_3_create_group
()¶
-
test_valid_create_object_4_create_whitelisted_url
()¶
-
test_valid_create_object_from_json_1_create_package_from_json
()¶
-
test_valid_create_object_from_json_2_create_user_from_json
()¶
-
test_valid_create_object_from_json_3_create_saved_question_from_json
()¶
-
test_valid_create_object_from_json_4_create_action_from_json
()¶
-
test_valid_create_object_from_json_5_create_sensor_from_json
()¶
-
test_valid_create_object_from_json_6_create_question_from_json
()¶
-
test_valid_create_object_from_json_7_create_whitelisted_url_from_json
()¶
-
test_valid_create_object_from_json_8_create_group_from_json
()¶
-
test_valid_deploy_action_1_deploy_action_simple_against_windows_computers
()¶
-
test_valid_deploy_action_2_deploy_action_simple_without_results
()¶
-
test_valid_deploy_action_3_deploy_action_with_params_against_windows_computers
()¶
-
test_valid_deploy_action_4_deploy_action_simple
()¶
-
test_valid_export_basetype_10_export_basetype_xml_default_options
()¶
-
test_valid_export_basetype_11_export_basetype_csv_with_explode_true
()¶
-
test_valid_export_basetype_12_export_basetype_json_explode_false
()¶
-
test_valid_export_basetype_13_export_basetype_json_type_false
()¶
-
test_valid_export_basetype_14_export_basetype_json_default_options
()¶
-
test_valid_export_basetype_1_export_basetype_csv_with_sort_list
()¶
-
test_valid_export_basetype_2_export_basetype_csv_with_explode_false
()¶
-
test_valid_export_basetype_3_export_basetype_json_type_true
()¶
-
test_valid_export_basetype_4_export_basetype_xml_minimal_false
()¶
-
test_valid_export_basetype_5_export_basetype_xml_minimal_true
()¶
-
test_valid_export_basetype_6_export_basetype_csv_with_sort_empty_list
()¶
-
test_valid_export_basetype_7_export_basetype_csv_default_options
()¶
-
test_valid_export_basetype_8_export_basetype_json_explode_true
()¶
-
test_valid_export_basetype_9_export_basetype_csv_with_sort_true
()¶
-
test_valid_export_resultset_10_export_resultset_csv_default_options
()¶
-
test_valid_export_resultset_11_export_resultset_csv_type_true
()¶
-
test_valid_export_resultset_12_export_resultset_csv_all_options
()¶
-
test_valid_export_resultset_13_export_resultset_csv_sort_false
()¶
-
test_valid_export_resultset_1_export_resultset_json
()¶
-
test_valid_export_resultset_2_export_resultset_csv_sensor_true
()¶
-
test_valid_export_resultset_3_export_resultset_csv_type_false
()¶
-
test_valid_export_resultset_4_export_resultset_csv_expand_false
()¶
-
test_valid_export_resultset_5_export_resultset_csv_sort_empty
()¶
-
test_valid_export_resultset_6_export_resultset_csv_sort_true
()¶
-
test_valid_export_resultset_7_export_resultset_csv_sort_list
()¶
-
test_valid_export_resultset_8_export_resultset_csv_sensor_false
()¶
-
test_valid_export_resultset_9_export_resultset_csv_expand_true
()¶
-
test_valid_get_object_10_get_all_saved_questions
()¶
-
test_valid_get_object_11_get_user_by_name
()¶
-
test_valid_get_object_12_get_all_userroless
()¶
-
test_valid_get_object_13_get_all_questions
()¶
-
test_valid_get_object_14_get_sensor_by_id
()¶
-
test_valid_get_object_15_get_all_groups
()¶
-
test_valid_get_object_16_get_all_sensors
()¶
-
test_valid_get_object_17_get_sensor_by_mixed
()¶
-
test_valid_get_object_18_get_whitelisted_url_by_id
()¶
-
test_valid_get_object_19_get_group_by_name
()¶
-
test_valid_get_object_1_get_all_users
()¶
-
test_valid_get_object_20_get_all_whitelisted_urls
()¶
-
test_valid_get_object_21_get_sensor_by_hash
()¶
-
test_valid_get_object_22_get_package_by_name
()¶
-
test_valid_get_object_23_get_all_clients
()¶
-
test_valid_get_object_24_get_sensor_by_names
()¶
-
test_valid_get_object_25_get_all_packages
()¶
-
test_valid_get_object_26_get_saved_question_by_name
()¶
-
test_valid_get_object_27_get_all_actions
()¶
-
test_valid_get_object_28_get_user_by_id
()¶
-
test_valid_get_object_29_get_sensor_by_name
()¶
-
test_valid_get_object_2_get_action_by_id
()¶
-
test_valid_get_object_30_get_saved_action_by_name
()¶
-
test_valid_get_object_3_get_question_by_id
()¶
-
test_valid_get_object_4_get_saved_question_by_names
()¶
-
test_valid_get_object_5_get_userrole_by_id
()¶
-
test_valid_get_object_6_get_all_saved_actions
()¶
-
test_valid_get_object_7_get_leader_clients
()¶
-
test_valid_get_object_8_get_all_settings
()¶
-
test_valid_get_object_9_get_setting_by_name
()¶
-
test_valid_question_10_ask_manual_question_sensor_with_parameters_and_filter
()¶
-
test_valid_question_11_ask_parsed_question_pick_first
()¶
-
test_valid_question_12__ask_manual_question_sensor_complex
()¶
-
test_valid_question_13_ask_manual_question_simple_single_sensor
()¶
-
test_valid_question_14_ask_manual_question_sensor_with_filter
()¶
-
test_valid_question_15_ask_manual_question_multiple_sensors_identified_by_name
()¶
-
test_valid_question_16_ask_manual_question_sensor_with_parameters_and_filter_and_options
()¶
-
test_valid_question_17_ask_manual_question_sensor_with_filter_and_3_options
()¶
-
test_valid_question_18_ask_manual_question_complex_query2
()¶
-
test_valid_question_19_ask_manual_question_complex_query1
()¶
-
test_valid_question_1_ask_manual_question_sensor_with_parameters_and_some_supplied_parameters
()¶
-
test_valid_question_2_ask_manual_question_multiple_sensors_with_parameters_and_some_supplied_parameters
()¶
-
test_valid_question_3_ask_manual_question_simple_single_sensor_no_results
()¶
-
test_valid_question_4_ask_manual_question_simple_multiple_sensors
()¶
-
test_valid_question_5_ask_manual_question_simple_single_sensor_sse
()¶
-
test_valid_question_6_ask_manual_question_sensor_without_parameters_and_supplied_parameters
()¶
-
test_valid_question_7_ask_parsed_question_pick_first_no_results
()¶
-
test_valid_question_8_ask_manual_question_sensor_with_filter_and_2_options
()¶
-
test_valid_question_9_ask_parsed_question_pick_first_sse
()¶
-
test_valid_saved_question_1_ask_saved_question_refresh_data
()¶
-
test_valid_saved_question_2_ask_saved_question_by_name_sse
()¶
-
test_valid_saved_question_3_ask_saved_question_by_name
()¶
-
test_valid_saved_question_4_ask_saved_question_by_name_in_list
()¶
-
classmethod
3.2. Invalid Server Functional Tests¶
This contains invalid functional tests for pytan.
These functional tests require a connection to a Tanium server in order to run. The connection info is pulled from the SERVER_INFO dictionary in test/API_INFO.py.
These tests all use ddt
, a package that provides for data driven tests via JSON files.
-
class
test_pytan_invalid_server_tests.
InvalidServerTests
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
classmethod
setUpClass
()¶
-
test_invalid_connect_1_bad_username
()¶
-
test_invalid_connect_2_bad_host_and_non_ssl_port
()¶
-
test_invalid_connect_3_bad_password
()¶
-
test_invalid_connect_4_bad_host_and_bad_port
()¶
-
classmethod
3.3. Unit Tests¶
This contains unit tests for pytan.
These unit tests do not require a connection to a Tanium server in order to run.
-
class
test_pytan_unit.
TestDehumanizeExtractionUtils
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
class
test_pytan_unit.
TestDehumanizeQuestionFilterUtils
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
class
test_pytan_unit.
TestDehumanizeQuestionOptionUtils
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
class
test_pytan_unit.
TestDehumanizeSensorUtils
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
class
test_pytan_unit.
TestDeserializeBadXML
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
test_bad_chars_basetype_control
()[source]¶ This XML file has a number of control characters that are not valid in XML.
This test validates that pytan.xml_clean.xml_cleaner() will remove all the invalid and restricted characters, which should allow the body to be parsed properly.
-
test_bad_chars_resultset_latin1
()[source]¶ This XML file has some characters that are actually encoded as latin1 (as well as some restricted characters).
This test validates that pytan.xml_clean.xml_cleaner() will properly fall back to latin1 for decoding the docuemnt, as well as remove all the invalid and restricted characters, which should allow the body to be parsed properly.
-
test_bad_chars_resultset_surrogate
()[source]¶ This XML file has some characters that are unpaired surrogates in unicode. Surrogates (unpaired or otherwise) are not legal XML characters.
This test validates that pytan.xml_clean.xml_cleaner() will properly remove all the invalid and restricted characters, which should allow the body to be parsed properly.
-
-
class
test_pytan_unit.
TestManualBuildObjectUtils
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
classmethod
setUpClass
()¶
-
test_build_group_obj
()¶
-
test_build_manual_q
()¶
-
test_build_selectlist_obj_invalid_filter
()¶
-
test_build_selectlist_obj_missing_value
()¶
-
test_build_selectlist_obj_noparamssensorobj_noparams
()¶ builds a selectlist object using a sensor obj with no params
-
test_build_selectlist_obj_noparamssensorobj_withparams
()¶ builds a selectlist object using a sensor obj with no params, but passing in params (which should be added as of 1.0.4)
-
test_build_selectlist_obj_withparamssensorobj_noparams
()¶ builds a selectlist object using a sensor obj with 4 params but not supplying any values for any of the params
-
test_build_selectlist_obj_withparamssensorobj_withparams
()¶ builds a selectlist object using a sensor obj with 4 params but supplying a value for only one param
-
classmethod
-
class
test_pytan_unit.
TestManualPackageDefValidateUtils
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
class
test_pytan_unit.
TestManualQuestionFilterDefParseUtils
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
class
test_pytan_unit.
TestManualQuestionFilterDefValidateUtils
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
class
test_pytan_unit.
TestManualQuestionOptionDefParseUtils
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
class
test_pytan_unit.
TestManualSensorDefParseUtils
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase