diff --git a/static/js/core-config-setup.js b/static/js/core-config-setup.js index 3cbafb175..04b963b6b 100644 --- a/static/js/core-config-setup.js +++ b/static/js/core-config-setup.js @@ -1274,7 +1274,7 @@ angular.module("core-config-setup", ['angularFileUpload']) $scope.requirementTitles = { 'software.quay': 'Quay Enterprise', - 'software.quay.regions': 'Distributed Storage Regions' + 'software.quay.deployments': 'Quay Enterprise Deployments' }; var handleLicenseSuccess = function(resp) { diff --git a/test/test_license.py b/test/test_license.py index c10f6a23e..0c5a72c1e 100644 --- a/test/test_license.py +++ b/test/test_license.py @@ -10,7 +10,8 @@ from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.serialization import load_der_public_key from util.license import (decode_license, LicenseDecodeError, ExpirationType, - MONTHLY_GRACE_PERIOD, YEARLY_GRACE_PERIOD, TRIAL_GRACE_PERIOD) + MONTHLY_GRACE_PERIOD, YEARLY_GRACE_PERIOD, TRIAL_GRACE_PERIOD, + QUAY_DEPLOYMENTS_ENTITLEMENT, QUAY_ENTITLEMENT) def get_date(delta): @@ -75,7 +76,7 @@ class TestLicense(unittest.TestCase): "expirationDate": get_date(timedelta(days=10)), }) - self.assertNotValid(license, requirement='software.quay') + self.assertNotValid(license, requirement=QUAY_ENTITLEMENT) def test_empty_subscriptions(self): license = self.create_license({ @@ -83,7 +84,7 @@ class TestLicense(unittest.TestCase): "subscriptions": {}, }) - self.assertNotValid(license, requirement='software.quay') + self.assertNotValid(license, requirement=QUAY_ENTITLEMENT) def test_missing_quay_entitlement(self): license = self.create_license({ @@ -92,13 +93,13 @@ class TestLicense(unittest.TestCase): "somesub": { "serviceEnd": get_date(timedelta(days=10)), "entitlements": { - "software.quay.regions": 0, + QUAY_DEPLOYMENTS_ENTITLEMENT: 0, }, }, }, }) - self.assertNotValid(license, requirement='software.quay') + self.assertNotValid(license, requirement=QUAY_ENTITLEMENT) def test_valid_quay_entitlement(self): license = self.create_license({ @@ -107,8 +108,8 @@ class TestLicense(unittest.TestCase): "somesub": { "serviceEnd": get_date(timedelta(days=10)), "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -122,8 +123,8 @@ class TestLicense(unittest.TestCase): "somesub": { "serviceEnd": get_date(timedelta(days=10)), "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -138,8 +139,8 @@ class TestLicense(unittest.TestCase): "somesub": { "serviceEnd": get_date(timedelta(days=10)), "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -154,8 +155,8 @@ class TestLicense(unittest.TestCase): "somesub": { "serviceEnd": get_date(MONTHLY_GRACE_PERIOD * -1 + timedelta(days=1)), "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -171,8 +172,8 @@ class TestLicense(unittest.TestCase): "serviceEnd": get_date(MONTHLY_GRACE_PERIOD * -1 + timedelta(days=1)), "durationPeriod": "monthly", "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -188,8 +189,8 @@ class TestLicense(unittest.TestCase): "serviceEnd": get_date(MONTHLY_GRACE_PERIOD * -1 + timedelta(days=-1)), "durationPeriod": "monthly", "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -205,8 +206,8 @@ class TestLicense(unittest.TestCase): "serviceEnd": get_date(YEARLY_GRACE_PERIOD * -1 + timedelta(days=1)), "durationPeriod": "yearly", "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -222,8 +223,8 @@ class TestLicense(unittest.TestCase): "serviceEnd": get_date(YEARLY_GRACE_PERIOD * -1 + timedelta(days=-1)), "durationPeriod": "yearly", "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -239,8 +240,8 @@ class TestLicense(unittest.TestCase): "serviceEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=1)), "inTrial": True, "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -256,8 +257,8 @@ class TestLicense(unittest.TestCase): "serviceEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)), "inTrial": True, "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -273,8 +274,8 @@ class TestLicense(unittest.TestCase): "trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=1)), "trialOnly": True, "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -290,8 +291,8 @@ class TestLicense(unittest.TestCase): "trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)), "trialOnly": True, "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -306,8 +307,8 @@ class TestLicense(unittest.TestCase): "somesub": { "serviceEnd": get_date(timedelta(days=10)), "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -328,8 +329,8 @@ class TestLicense(unittest.TestCase): "somesub": { "serviceEnd": get_date(timedelta(days=10)), "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, }, @@ -342,7 +343,7 @@ class TestLicense(unittest.TestCase): ], } - self.assertNotValid(license, config=config, requirement='software.quay.regions') + self.assertNotValid(license, config=config, requirement=QUAY_DEPLOYMENTS_ENTITLEMENT) def test_valid_regions_across_multiple_sub(self): license = self.create_license({ @@ -351,14 +352,14 @@ class TestLicense(unittest.TestCase): "somesub": { "serviceEnd": get_date(timedelta(days=10)), "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, "anothersub": { "serviceEnd": get_date(timedelta(days=20)), "entitlements": { - "software.quay.regions": 5, + QUAY_DEPLOYMENTS_ENTITLEMENT: 5, }, }, }, @@ -382,15 +383,15 @@ class TestLicense(unittest.TestCase): "somesub": { "serviceEnd": get_date(timedelta(days=10)), "entitlements": { - "software.quay": 1, - "software.quay.regions": 1, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 1, }, }, "anothersub": { "trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)), "trialOnly": True, "entitlements": { - "software.quay.regions": 5, + QUAY_DEPLOYMENTS_ENTITLEMENT: 5, }, }, }, @@ -403,7 +404,7 @@ class TestLicense(unittest.TestCase): ], } - self.assertNotValid(license, config=config, requirement='software.quay.regions', + self.assertNotValid(license, config=config, requirement=QUAY_DEPLOYMENTS_ENTITLEMENT, expired=ExpirationType.trial_only) def test_valid_regions_across_multiple_sub_one_expired(self): @@ -414,15 +415,15 @@ class TestLicense(unittest.TestCase): "trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)), "trialOnly": True, "entitlements": { - "software.quay": 1, - "software.quay.regions": 3, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 3, }, }, "anothersub": { "serviceEnd": get_date(timedelta(days=20)), "entitlements": { - "software.quay": 1, - "software.quay.regions": 5, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 5, }, }, }, @@ -445,14 +446,14 @@ class TestLicense(unittest.TestCase): "trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)), "trialOnly": True, "entitlements": { - "software.quay": 1, - "software.quay.regions": 3, + QUAY_ENTITLEMENT: 1, + QUAY_DEPLOYMENTS_ENTITLEMENT: 3, }, }, "anothersub": { "serviceEnd": get_date(timedelta(days=20)), "entitlements": { - "software.quay.regions": 5, + QUAY_DEPLOYMENTS_ENTITLEMENT: 5, }, }, }, @@ -466,7 +467,7 @@ class TestLicense(unittest.TestCase): } self.assertNotValid(license, config=config, expired=ExpirationType.trial_only, - requirement='software.quay') + requirement=QUAY_ENTITLEMENT) if __name__ == '__main__': unittest.main() diff --git a/util/license.py b/util/license.py index 663349a31..f9622cddd 100644 --- a/util/license.py +++ b/util/license.py @@ -26,6 +26,10 @@ MONTHLY_GRACE_PERIOD = timedelta(335, 0) # 11 months YEARLY_GRACE_PERIOD = timedelta(90, 0) # 3 months LICENSE_FILENAME = 'license' +QUAY_ENTITLEMENT = 'software.quay' +QUAY_DEPLOYMENTS_ENTITLEMENT = 'software.quay.deployments' + + class LicenseDecodeError(Exception): """ Exception raised if the license could not be read, decoded or has expired. """ @@ -314,8 +318,8 @@ EntitlementRequirement = namedtuple('EntitlementRequirements', ['name', 'count'] def _gen_entitlement_requirements(config_obj): config_regions = len(config_obj.get('DISTRIBUTED_STORAGE_CONFIG', [])) return [ - EntitlementRequirement('software.quay', 1), - EntitlementRequirement('software.quay.regions', config_regions), + EntitlementRequirement(QUAY_ENTITLEMENT, 1), + EntitlementRequirement(QUAY_DEPLOYMENTS_ENTITLEMENT, config_regions), ]