##// END OF EJS Templates
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
Imported some of the GPLv3'd changes from RhodeCode v2.2.5. This imports changes between changesets 21af6c4eab3d and 6177597791c2 in RhodeCode's original repository, including only changes to Python files and HTML. RhodeCode clearly licensed its changes to these files under GPLv3 in their /LICENSE file, which states the following: The Python code and integrated HTML are licensed under the GPLv3 license. (See: https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE or http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE for an online copy of that LICENSE file) Conservancy reviewed these changes and confirmed that they can be licensed as a whole to the Kallithea project under GPLv3-only. While some of the contents committed herein are clearly licensed GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the statement above from RhodeCode indicates that they intend GPLv3-only as their license, per GPLv3ยง14 and other relevant sections of GPLv3.

File last commit:

r4116:ffd45b18 rhodecode-2.2.5-gpl
r4116:ffd45b18 rhodecode-2.2.5-gpl
Show More
test_license.py
68 lines | 2.1 KiB | text/x-python | PythonLexer
from __future__ import with_statement
from rhodecode.tests import *
from rhodecode.tests.fixture import Fixture
from rhodecode.lib.compat import json
from rhodecode.model.license import LicenseModel
fixture = Fixture()
TEST_KEY = ''
class LicenseTest(BaseTestCase):
def setUp(self):
global TEST_KEY
token = LicenseModel.generate_license_token()
TEST_KEY = token
def test_encryption_decryption(self):
test_license = {
'foo': 'baar',
'signature': 'test'
}
enc = LicenseModel(key=TEST_KEY).encrypt(json.dumps(test_license))
dec = json.loads(LicenseModel(key=TEST_KEY).decrypt(enc))
self.assertEqual(test_license, dec)
def test_signature(self):
enc_with_key = '1234567890123456'
test_license = {
'foo': 'baar',
'signature': None
}
test_license['signature'] = LicenseModel(key=TEST_KEY)\
.generate_signature(test_license, enc_with_key)
enc = LicenseModel(key=TEST_KEY).encrypt(json.dumps(test_license))
signature = LicenseModel(key=TEST_KEY).verify(enc, enc_with_key)
del test_license['signature']
self.assertEqual(test_license, signature)
def test_signature_mismatch(self):
enc_with_key = '1234567890123456'
test_license = {
'foo': 'baar',
'signature': 'cnashs62tdsbcsaaisuda6215sagc'
}
enc = LicenseModel(key=TEST_KEY).encrypt(json.dumps(test_license))
self.assertRaises(TypeError,
lambda: LicenseModel(key=TEST_KEY).verify(enc, enc_with_key))
def test_generate_license_token(self):
token = LicenseModel.generate_license_token()
self.assertEqual(4, len(token.split('-')))
def test_get_license_info(self):
info = LicenseModel.get_license_info('', '')
self.assertEqual(info, {})
def test_get_license_info_default(self):
info = LicenseModel.get_license_info('', '', fill_defaults=True)
self.assertEqual(info['users'], 20)
self.assertEqual(info['valid_till'], 1421884937.512214)
self.assertEqual(info['email'], 'support@rhodecode.com')