mirror of
https://github.com/ansible/awx.git
synced 2026-09-16 00:40:11 -02:30
Fix an issue when creating scan job templates where we weren't obeying
the license flag, so folks could still create scan jobs even if they weren't enabled by the license. Plus Unit Tests
This commit is contained in:
@@ -173,14 +173,15 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
|
||||
rnd_str = '____' + str(random.randint(1, 9999999))
|
||||
return __name__ + '-generated-' + string + rnd_str
|
||||
|
||||
def create_test_license_file(self, instance_count=10000, license_date=int(time.time() + 3600)):
|
||||
def create_test_license_file(self, instance_count=10000, license_date=int(time.time() + 3600), features=None):
|
||||
writer = LicenseWriter(
|
||||
company_name='AWX',
|
||||
contact_name='AWX Admin',
|
||||
contact_email='awx@example.com',
|
||||
license_date=license_date,
|
||||
instance_count=instance_count,
|
||||
license_type='enterprise')
|
||||
license_type='enterprise',
|
||||
features=features)
|
||||
handle, license_path = tempfile.mkstemp(suffix='.json')
|
||||
os.close(handle)
|
||||
writer.write_file(license_path)
|
||||
|
||||
@@ -429,6 +429,11 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TestCase):
|
||||
job_type = PERM_INVENTORY_SCAN,
|
||||
inventory = self.inv_eng.pk,
|
||||
)
|
||||
# Without the system tracking license feature even super users can't create scan jobs
|
||||
with self.current_user(self.user_sue):
|
||||
data['credential'] = self.cred_sue.pk
|
||||
response = self.post(url, data, expect=402)
|
||||
self.create_test_license_file(features=dict(system_tracking=True))
|
||||
# Regular users, even those who have access to the inv and cred can't create scan jobs templates
|
||||
with self.current_user(self.user_doug):
|
||||
data['credential'] = self.cred_doug.pk
|
||||
|
||||
Reference in New Issue
Block a user