s/Regions/Deployments
This commit is contained in:
parent
845d1795a3
commit
45bacbabaa
3 changed files with 57 additions and 52 deletions
|
@ -1274,7 +1274,7 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
||||||
|
|
||||||
$scope.requirementTitles = {
|
$scope.requirementTitles = {
|
||||||
'software.quay': 'Quay Enterprise',
|
'software.quay': 'Quay Enterprise',
|
||||||
'software.quay.regions': 'Distributed Storage Regions'
|
'software.quay.deployments': 'Quay Enterprise Deployments'
|
||||||
};
|
};
|
||||||
|
|
||||||
var handleLicenseSuccess = function(resp) {
|
var handleLicenseSuccess = function(resp) {
|
||||||
|
|
|
@ -10,7 +10,8 @@ from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives.serialization import load_der_public_key
|
from cryptography.hazmat.primitives.serialization import load_der_public_key
|
||||||
|
|
||||||
from util.license import (decode_license, LicenseDecodeError, ExpirationType,
|
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):
|
def get_date(delta):
|
||||||
|
@ -75,7 +76,7 @@ class TestLicense(unittest.TestCase):
|
||||||
"expirationDate": get_date(timedelta(days=10)),
|
"expirationDate": get_date(timedelta(days=10)),
|
||||||
})
|
})
|
||||||
|
|
||||||
self.assertNotValid(license, requirement='software.quay')
|
self.assertNotValid(license, requirement=QUAY_ENTITLEMENT)
|
||||||
|
|
||||||
def test_empty_subscriptions(self):
|
def test_empty_subscriptions(self):
|
||||||
license = self.create_license({
|
license = self.create_license({
|
||||||
|
@ -83,7 +84,7 @@ class TestLicense(unittest.TestCase):
|
||||||
"subscriptions": {},
|
"subscriptions": {},
|
||||||
})
|
})
|
||||||
|
|
||||||
self.assertNotValid(license, requirement='software.quay')
|
self.assertNotValid(license, requirement=QUAY_ENTITLEMENT)
|
||||||
|
|
||||||
def test_missing_quay_entitlement(self):
|
def test_missing_quay_entitlement(self):
|
||||||
license = self.create_license({
|
license = self.create_license({
|
||||||
|
@ -92,13 +93,13 @@ class TestLicense(unittest.TestCase):
|
||||||
"somesub": {
|
"somesub": {
|
||||||
"serviceEnd": get_date(timedelta(days=10)),
|
"serviceEnd": get_date(timedelta(days=10)),
|
||||||
"entitlements": {
|
"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):
|
def test_valid_quay_entitlement(self):
|
||||||
license = self.create_license({
|
license = self.create_license({
|
||||||
|
@ -107,8 +108,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"somesub": {
|
"somesub": {
|
||||||
"serviceEnd": get_date(timedelta(days=10)),
|
"serviceEnd": get_date(timedelta(days=10)),
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -122,8 +123,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"somesub": {
|
"somesub": {
|
||||||
"serviceEnd": get_date(timedelta(days=10)),
|
"serviceEnd": get_date(timedelta(days=10)),
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -138,8 +139,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"somesub": {
|
"somesub": {
|
||||||
"serviceEnd": get_date(timedelta(days=10)),
|
"serviceEnd": get_date(timedelta(days=10)),
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -154,8 +155,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"somesub": {
|
"somesub": {
|
||||||
"serviceEnd": get_date(MONTHLY_GRACE_PERIOD * -1 + timedelta(days=1)),
|
"serviceEnd": get_date(MONTHLY_GRACE_PERIOD * -1 + timedelta(days=1)),
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -171,8 +172,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"serviceEnd": get_date(MONTHLY_GRACE_PERIOD * -1 + timedelta(days=1)),
|
"serviceEnd": get_date(MONTHLY_GRACE_PERIOD * -1 + timedelta(days=1)),
|
||||||
"durationPeriod": "monthly",
|
"durationPeriod": "monthly",
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -188,8 +189,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"serviceEnd": get_date(MONTHLY_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
"serviceEnd": get_date(MONTHLY_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
||||||
"durationPeriod": "monthly",
|
"durationPeriod": "monthly",
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -205,8 +206,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"serviceEnd": get_date(YEARLY_GRACE_PERIOD * -1 + timedelta(days=1)),
|
"serviceEnd": get_date(YEARLY_GRACE_PERIOD * -1 + timedelta(days=1)),
|
||||||
"durationPeriod": "yearly",
|
"durationPeriod": "yearly",
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -222,8 +223,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"serviceEnd": get_date(YEARLY_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
"serviceEnd": get_date(YEARLY_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
||||||
"durationPeriod": "yearly",
|
"durationPeriod": "yearly",
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -239,8 +240,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"serviceEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=1)),
|
"serviceEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=1)),
|
||||||
"inTrial": True,
|
"inTrial": True,
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -256,8 +257,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"serviceEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
"serviceEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
||||||
"inTrial": True,
|
"inTrial": True,
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -273,8 +274,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=1)),
|
"trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=1)),
|
||||||
"trialOnly": True,
|
"trialOnly": True,
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -290,8 +291,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
"trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
||||||
"trialOnly": True,
|
"trialOnly": True,
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -306,8 +307,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"somesub": {
|
"somesub": {
|
||||||
"serviceEnd": get_date(timedelta(days=10)),
|
"serviceEnd": get_date(timedelta(days=10)),
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -328,8 +329,8 @@ class TestLicense(unittest.TestCase):
|
||||||
"somesub": {
|
"somesub": {
|
||||||
"serviceEnd": get_date(timedelta(days=10)),
|
"serviceEnd": get_date(timedelta(days=10)),
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 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):
|
def test_valid_regions_across_multiple_sub(self):
|
||||||
license = self.create_license({
|
license = self.create_license({
|
||||||
|
@ -351,14 +352,14 @@ class TestLicense(unittest.TestCase):
|
||||||
"somesub": {
|
"somesub": {
|
||||||
"serviceEnd": get_date(timedelta(days=10)),
|
"serviceEnd": get_date(timedelta(days=10)),
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"anothersub": {
|
"anothersub": {
|
||||||
"serviceEnd": get_date(timedelta(days=20)),
|
"serviceEnd": get_date(timedelta(days=20)),
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay.regions": 5,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -382,15 +383,15 @@ class TestLicense(unittest.TestCase):
|
||||||
"somesub": {
|
"somesub": {
|
||||||
"serviceEnd": get_date(timedelta(days=10)),
|
"serviceEnd": get_date(timedelta(days=10)),
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 1,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"anothersub": {
|
"anothersub": {
|
||||||
"trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
"trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
||||||
"trialOnly": True,
|
"trialOnly": True,
|
||||||
"entitlements": {
|
"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)
|
expired=ExpirationType.trial_only)
|
||||||
|
|
||||||
def test_valid_regions_across_multiple_sub_one_expired(self):
|
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)),
|
"trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
||||||
"trialOnly": True,
|
"trialOnly": True,
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 3,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"anothersub": {
|
"anothersub": {
|
||||||
"serviceEnd": get_date(timedelta(days=20)),
|
"serviceEnd": get_date(timedelta(days=20)),
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 5,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -445,14 +446,14 @@ class TestLicense(unittest.TestCase):
|
||||||
"trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
"trialEnd": get_date(TRIAL_GRACE_PERIOD * -1 + timedelta(days=-1)),
|
||||||
"trialOnly": True,
|
"trialOnly": True,
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"software.quay": 1,
|
QUAY_ENTITLEMENT: 1,
|
||||||
"software.quay.regions": 3,
|
QUAY_DEPLOYMENTS_ENTITLEMENT: 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"anothersub": {
|
"anothersub": {
|
||||||
"serviceEnd": get_date(timedelta(days=20)),
|
"serviceEnd": get_date(timedelta(days=20)),
|
||||||
"entitlements": {
|
"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,
|
self.assertNotValid(license, config=config, expired=ExpirationType.trial_only,
|
||||||
requirement='software.quay')
|
requirement=QUAY_ENTITLEMENT)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -26,6 +26,10 @@ MONTHLY_GRACE_PERIOD = timedelta(335, 0) # 11 months
|
||||||
YEARLY_GRACE_PERIOD = timedelta(90, 0) # 3 months
|
YEARLY_GRACE_PERIOD = timedelta(90, 0) # 3 months
|
||||||
LICENSE_FILENAME = 'license'
|
LICENSE_FILENAME = 'license'
|
||||||
|
|
||||||
|
QUAY_ENTITLEMENT = 'software.quay'
|
||||||
|
QUAY_DEPLOYMENTS_ENTITLEMENT = 'software.quay.deployments'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LicenseDecodeError(Exception):
|
class LicenseDecodeError(Exception):
|
||||||
""" Exception raised if the license could not be read, decoded or has expired. """
|
""" 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):
|
def _gen_entitlement_requirements(config_obj):
|
||||||
config_regions = len(config_obj.get('DISTRIBUTED_STORAGE_CONFIG', []))
|
config_regions = len(config_obj.get('DISTRIBUTED_STORAGE_CONFIG', []))
|
||||||
return [
|
return [
|
||||||
EntitlementRequirement('software.quay', 1),
|
EntitlementRequirement(QUAY_ENTITLEMENT, 1),
|
||||||
EntitlementRequirement('software.quay.regions', config_regions),
|
EntitlementRequirement(QUAY_DEPLOYMENTS_ENTITLEMENT, config_regions),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue