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:
Matthew Jones
2015-05-28 15:59:49 -04:00
parent 6709654e04
commit 5b3b4b48c0
4 changed files with 21 additions and 3 deletions
+3 -2
View File
@@ -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)
+5
View File
@@ -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