diff options
Diffstat (limited to 'ansible_collections/netapp/ontap/tests')
10 files changed, 171 insertions, 39 deletions
diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/.gitignore b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/.gitignore deleted file mode 100644 index bc1a1f616..000000000 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Created by pytest automatically. -* diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/CACHEDIR.TAG b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/CACHEDIR.TAG deleted file mode 100644 index fce15ad7e..000000000 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/CACHEDIR.TAG +++ /dev/null @@ -1,4 +0,0 @@ -Signature: 8a477f597d28d172789f06886806bc55 -# This file is a cache directory tag created by pytest. -# For information about cache directory tags, see: -# https://bford.info/cachedir/spec.html diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/README.md b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/README.md deleted file mode 100644 index b89018ced..000000000 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# pytest cache directory # - -This directory contains data from the pytest's cache plugin, -which provides the `--lf` and `--ff` options, as well as the `cache` fixture. - -**Do not** commit this to version control. - -See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information. diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/v/cache/lastfailed b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/v/cache/lastfailed deleted file mode 100644 index ba7b58d20..000000000 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/v/cache/lastfailed +++ /dev/null @@ -1,3 +0,0 @@ -{ - "test_na_ontap_lun_rest.py": true -}
\ No newline at end of file diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/v/cache/nodeids b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/v/cache/nodeids deleted file mode 100644 index ca22cf9ee..000000000 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/v/cache/nodeids +++ /dev/null @@ -1,6 +0,0 @@ -[ - "test_na_ontap_lun.py::TestMyModule::test_create_error_missing_param", - "test_na_ontap_lun.py::TestMyModule::test_module_fail_when_required_args_missing", - "test_na_ontap_lun_rest.py::TestMyModule::test_create_error_missing_param", - "test_na_ontap_lun_rest.py::TestMyModule::test_successful_create_appli" -]
\ No newline at end of file diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/v/cache/stepwise b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/v/cache/stepwise deleted file mode 100644 index 0637a088a..000000000 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/.pytest_cache/v/cache/stepwise +++ /dev/null @@ -1 +0,0 @@ -[]
\ No newline at end of file diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_cifs.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_cifs.py index 99aa0d140..f57aa8d68 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_cifs.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_cifs.py @@ -47,6 +47,7 @@ SRR = rest_responses({ "home_directory": True, "oplocks": False, "continuously_available": True, + "offline_files": "manual", "show_snapshot": True, "namespace_caching": True, "allow_unencrypted_access": True, @@ -407,6 +408,31 @@ def test_modify_cifs_share_properties_2(): assert create_and_apply(my_module, ARGS_REST, module_args) +def test_modify_cifs_offline_files(): + ''' test modify CIFS offline_files ''' + register_responses([ + ('GET', 'cluster', SRR['is_rest_9_13_1']), + ('GET', 'protocols/cifs/shares', SRR['cifs_record']), + ('PATCH', 'protocols/cifs/shares/671aa46e-11ad-11ec-a267-005056b30cfa/cifs_share_name', SRR['empty_good']), + ]) + module_args = { + "offline_files": "none" + } + assert create_and_apply(my_module, ARGS_REST, module_args) + + +def test_version_error_offline_files(): + ''' test version error for offline_files ''' + register_responses([ + ('GET', 'cluster', SRR['is_rest']) + ]) + module_args = { + "offline_files": "none" + } + error = create_module(my_module, ARGS_REST, module_args, fail=True)['msg'] + assert 'Minimum version of ONTAP for offline_files is (9, 10, 1)' in error + + def test_error_modify_cifs_share_path(): ''' test modify CIFS share path error''' register_responses([ diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_quotas.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_quotas.py index cd03989c6..843aa13fc 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_quotas.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_quotas.py @@ -55,12 +55,38 @@ SRR = rest_responses({ "target": { "name": "20:05:00:50:56:b3:0c:fa" }, + }, + { + "svm": { + "uuid": "671aa46e-11ad-11ec-a267-005056b30cfa", + "name": "ansible" + }, + "files": { + "hard_limit": "100", + "soft_limit": "80" + }, + "qtree": { + "id": "1", + "name": "qt1" + }, + "space": { + "hard_limit": "1222800", + "soft_limit": "51200" + }, + "type": "user", + "user_mapping": False, + "users": [{"id": "757"}], + "uuid": "264a9e0b-2e03-11e9-a610-005056a7b72d", + "volume": {"name": "fv", "uuid": "264a9e0b-2e03-11e9-a610-005056a7b72da"}, + "target": { + "name": "20:05:00:50:56:b3:0c:fa" + }, } ], "num_records": 1 }, None ), - 'quota_record_0_empty_limtis': (200, {"records": [{ + 'quota_record_0_empty_limits': (200, {"records": [{ "svm": {"name": "ansible"}, "files": {"hard_limit": 0}, "qtree": {"id": "1", "name": "qt1"}, @@ -441,10 +467,26 @@ def test_rest_successful_create(): ('GET', 'storage/volumes', SRR['quota_status']), ('POST', 'storage/quota/rules', SRR['empty_good']), ]) + assert create_and_apply(my_module, ARGS_REST) + + +def test_rest_successful_create_userid(): + '''Test successful rest create with users.id with idempotency check''' + register_responses([ + ('GET', 'cluster', SRR['is_rest']), + ('GET', 'storage/quota/rules', SRR['empty_records']), + ('GET', 'storage/volumes', SRR['quota_status']), + ('POST', 'storage/quota/rules', SRR['empty_good']), + + ('GET', 'cluster', SRR['is_rest']), + ('GET', 'storage/quota/rules', SRR['quota_record']), + ('GET', 'storage/volumes', SRR['quota_status']), + ]) module_args = { - "users": [{"name": "quota_user"}], + "quota_target": "757", } - assert create_and_apply(my_module, ARGS_REST) + assert create_and_apply(my_module, ARGS_REST, module_args) + assert create_and_apply(my_module, ARGS_REST, module_args)['changed'] is False @patch('time.sleep') @@ -461,9 +503,6 @@ def test_rest_successful_create_job_error(sleep): ('GET', 'cluster/jobs/d78811c1-aebc-11ec-b4de-005056b30cfa', SRR['job_not_found']), ('GET', 'storage/volumes', SRR['volume_uuid']) ]) - module_args = { - "users": [{"name": "quota_user"}], - } assert create_and_apply(my_module, ARGS_REST) print_warnings() assert_warning_was_raised('Ignoring job status, assuming success.') @@ -595,10 +634,10 @@ def test_rest_successful_create_idempotency(): ('GET', 'storage/quota/rules', SRR['quota_record']), ('GET', 'storage/volumes', SRR['quota_status']), ('GET', 'cluster', SRR['is_rest']), - ('GET', 'storage/quota/rules', SRR['quota_record_0_empty_limtis']), + ('GET', 'storage/quota/rules', SRR['quota_record_0_empty_limits']), ('GET', 'storage/volumes', SRR['quota_status']), ('GET', 'cluster', SRR['is_rest']), - ('GET', 'storage/quota/rules', SRR['quota_record_0_empty_limtis']), + ('GET', 'storage/quota/rules', SRR['quota_record_0_empty_limits']), ('GET', 'storage/volumes', SRR['quota_status']) ]) assert create_and_apply(my_module, ARGS_REST)['changed'] is False diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_security_config.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_security_config.py index 1ffdfbc02..2a6009287 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_security_config.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_security_config.py @@ -25,9 +25,11 @@ SRR = rest_responses({ # module specific responses 'security_config_record': (200, { "records": [{ - "is_fips_enabled": False, - "supported_protocols": ['TLSv1.3', 'TLSv1.2', 'TLSv1.1'], - "supported_cipher_suites": 'TLS_RSA_WITH_AES_128_CCM_8' + "fips": {"enabled": False}, + "tls": { + "protocol_versions": ['TLSv1.3', 'TLSv1.2', 'TLSv1.1'], + "cipher_suites": ['TLS_RSA_WITH_AES_128_CCM_8'] + } }], "num_records": 1 }, None), "no_record": ( @@ -186,11 +188,12 @@ def test_rest_modify_security_config(): ('GET', 'cluster', SRR['is_rest_9_10_1']), ('GET', '/security', SRR['security_config_record']), ('PATCH', '/security', SRR['success']), + ('GET', '/security', SRR['security_config_record']), ]) module_args = { "is_fips_enabled": False, "supported_protocols": ['TLSv1.3', 'TLSv1.2', 'TLSv1.1'], - "supported_cipher_suites": 'TLS_RSA_WITH_AES_128_CCM' + "supported_cipher_suites": ['TLS_RSA_WITH_AES_128_CCM'] } assert call_main(my_main, ARGS_REST, module_args)['changed'] @@ -245,10 +248,11 @@ def test_rest_modify_security_config_fips(): ('GET', 'cluster', SRR['is_rest_9_10_1']), ('GET', '/security', SRR['security_config_record']), ('PATCH', '/security', SRR['success']), + ('GET', '/security', SRR['security_config_record']), ]) module_args = { "is_fips_enabled": True, "supported_protocols": ['TLSv1.3', 'TLSv1.2'], - "supported_cipher_suites": 'TLS_RSA_WITH_AES_128_CCM' + "supported_cipher_suites": ['TLS_RSA_WITH_AES_128_CCM'] } assert call_main(my_main, ARGS_REST, module_args)['changed'] diff --git a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_vserver_audit.py b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_vserver_audit.py index 9a4ec6f91..d12d075ff 100644 --- a/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_vserver_audit.py +++ b/ansible_collections/netapp/ontap/tests/unit/plugins/modules/test_na_ontap_vserver_audit.py @@ -90,7 +90,59 @@ SRR = rest_responses({ "no_record": ( 200, {"num_records": 0}, - None) + None), + 'audit_record_time_based_rotation': ( + 200, + { + "records": [ + { + "svm": { + "uuid": "671aa46e-11ad-11ec-a267-005056b30cfa", + "name": "vserver" + }, + "enabled": True, + "events": { + "authorization_policy": True, + "cap_staging": True, + "cifs_logon_logoff": False, + "file_operations": False, + "file_share": True, + "security_group": True, + "user_account": True + }, + "log_path": "/", + "log": { + "format": "xml", + "rotation": { + "schedule": { + "hours": [ + 6, + 12, + 18 + ], + "minutes": [ + 15, + 30, + 45 + ], + "months": [ + 1, + 3 + ], + "weekdays": [ + 0, + 2, + 4 + ] + } + } + }, + "guarantee": False + } + ], + "num_records": 1 + }, None + ), }) ARGS_REST = { @@ -189,7 +241,8 @@ def test_create_audit_config_rest(): assert msg in error -def test_modify_audit_config_rest(): +def test_modify_audit_config_sizebased_rotation_rest(): + ''' Rotates logs based on log size ''' register_responses([ ('GET', 'cluster', SRR['is_rest_9_10_1']), ('GET', 'protocols/audit', SRR['audit_record']), @@ -217,6 +270,40 @@ def test_modify_audit_config_rest(): assert call_main(my_main, ARGS_REST, module_args)['changed'] +def test_modify_audit_config_timebased_rotation_rest(): + ''' Rotates the audit logs based on a schedule ''' + register_responses([ + ('GET', 'cluster', SRR['is_rest_9_10_1']), + ('GET', 'protocols/audit', SRR['audit_record_time_based_rotation']), + ('PATCH', 'protocols/audit/671aa46e-11ad-11ec-a267-005056b30cfa', SRR['empty_good']), + ]) + module_args = { + "enabled": True, + "events": { + "authorization_policy": True, + "cap_staging": True, + "cifs_logon_logoff": False, + "file_operations": False, + "file_share": True, + "security_group": True, + "user_account": True + }, + "log_path": "/tmp", + "log": { + "format": "xml", + "rotation": { + "schedule": { + "hours": [12], + "minutes": [30], + "months": [-1], + "weekdays": [-1] + } + } + }, + } + assert call_main(my_main, ARGS_REST, module_args)['changed'] + + def test_enable_audit_config_rest(): register_responses([ ('GET', 'cluster', SRR['is_rest_9_10_1']), |