Remove license code in Quay
No longer needed under Red Hat rules \o/ Fixes https://jira.coreos.com/browse/QUAY-883
This commit is contained in:
parent
041a7fcd36
commit
3586955669
23 changed files with 19 additions and 1471 deletions
|
@ -1,48 +0,0 @@
|
|||
import pytest
|
||||
|
||||
from mock import patch
|
||||
|
||||
from util.config.validators import ConfigValidationException
|
||||
from util.config.validators.validate_license import LicenseValidator
|
||||
from util.morecollections import AttrDict
|
||||
from util.license import License, QUAY_DEPLOYMENTS_ENTITLEMENT, QUAY_ENTITLEMENT
|
||||
|
||||
from test.fixtures import *
|
||||
|
||||
@pytest.mark.parametrize('deployments, allowed_deployments', [
|
||||
(1, 1),
|
||||
(3, 3),
|
||||
(3, 2),
|
||||
(3, 1),
|
||||
])
|
||||
def test_too_many_storage_engines(deployments, allowed_deployments, app):
|
||||
def get_license():
|
||||
decoded = {
|
||||
'expirationDate': '2157-12-1',
|
||||
'subscriptions': {
|
||||
'someSubscription': {
|
||||
'serviceEnd': '2157-12-1',
|
||||
'durationPeriod': 'yearly',
|
||||
'entitlements': {
|
||||
QUAY_ENTITLEMENT: 1,
|
||||
QUAY_DEPLOYMENTS_ENTITLEMENT: allowed_deployments,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return License(decoded)
|
||||
|
||||
storage_configs = [(str(i), {}) for i in range(0, deployments)]
|
||||
|
||||
with patch('app.config_provider.get_license', get_license):
|
||||
validator = LicenseValidator()
|
||||
|
||||
if allowed_deployments < deployments:
|
||||
with pytest.raises(ConfigValidationException):
|
||||
validator.validate({
|
||||
'DISTRIBUTED_STORAGE_CONFIG': storage_configs,
|
||||
}, None, None)
|
||||
else:
|
||||
validator.validate({
|
||||
'DISTRIBUTED_STORAGE_CONFIG': storage_configs,
|
||||
}, None, None)
|
|
@ -1,19 +0,0 @@
|
|||
from app import config_provider
|
||||
from util.config.validators import BaseValidator, ConfigValidationException
|
||||
from util.license import LicenseDecodeError, EntitlementStatus
|
||||
|
||||
class LicenseValidator(BaseValidator):
|
||||
name = "license"
|
||||
|
||||
@classmethod
|
||||
def validate(cls, config, user, user_password):
|
||||
try:
|
||||
decoded_license = config_provider.get_license()
|
||||
except LicenseDecodeError as le:
|
||||
raise ConfigValidationException('Could not decode license: %s' % le.message)
|
||||
|
||||
results = decoded_license.validate(config)
|
||||
all_met = all(result.is_met() for result in results)
|
||||
if not all_met:
|
||||
reason = [result.description() for result in results if not result.is_met()]
|
||||
raise ConfigValidationException('License does not match configuration: %s' % reason)
|
Reference in a new issue