mirror of
https://github.com/ansible/awx.git
synced 2026-03-05 10:41:05 -03:30
[AAP-44277] License module now validates API responses for subscription IDs. (Moved from Tower) (#16096)
* resolve bug and add simple unit tests * Update awx_collection/plugins/modules/license.py Co-authored-by: Andrew Potozniak <tyraziel@gmail.com> --------- Co-authored-by: Andrew Potozniak <tyraziel@gmail.com>
This commit is contained in:
committed by
GitHub
parent
873f5c0ecc
commit
1f06d1bb9a
32
awx_collection/test/awx/test_license_subscription.py
Normal file
32
awx_collection/test/awx/test_license_subscription.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_license_invalid_subscription_id_should_fail(run_module, admin_user):
|
||||
"""Test invalid subscription ID returns failure."""
|
||||
result = run_module('license', {'subscription_id': 'invalid-test-12345', 'state': 'present'}, admin_user)
|
||||
|
||||
assert result.get('failed', False)
|
||||
assert 'msg' in result
|
||||
assert 'subscription' in result['msg'].lower()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_license_invalid_manifest_should_fail(run_module, admin_user):
|
||||
"""Test invalid manifest returns failure."""
|
||||
result = run_module('license', {'manifest': '/nonexistent/test.zip', 'state': 'present'}, admin_user)
|
||||
|
||||
assert result.get('failed', False)
|
||||
assert 'msg' in result
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_license_state_absent_works(run_module, admin_user):
|
||||
"""Test license removal works."""
|
||||
result = run_module('license', {'state': 'absent'}, admin_user)
|
||||
|
||||
assert not result.get('failed', False)
|
||||
Reference in New Issue
Block a user