def __init__(self, memory=None, memcache=None, loadtest_mode=False, verify=True): """If the loadtest mode is set, when looking for loadtest.local, the certificate bundled in browserid.tests.support will be returned instead of failing. setting :param memory: or :param memcache: to False will cause the support document manager to not use them :param memory: the dict to use for in-memory cache :param memcache: the memcache instance, already configured. :param loadtest_mode: is the instance in loadtest mode? :param verify: do we want to check the ssl certificates when requesting the support documents (defaults to True) """ if memory is None: memory = TTLedDict(60 * 10) # TTL of 10 minutes for the certs if memcache is None: memcache = False self.memory = memory self.memcache = memcache self.loadtest_mode = loadtest_mode self.verify = verify if loadtest_mode is True: supportdoc = fetch_support_document('loadtest.local') self.memory['loadtest.local'] = supportdoc self.memory.set_ttl('loadtest.local', 0) # never expire
def test_check_signature_with_key(self): hostname = 'browserid.org' data = 'NOBODY EXPECTS THE SPANISH INQUISITION!' sig = sign_data(hostname, data) cert = json.dumps(fetch_support_document(hostname)["public-key"]) result = self.runner.check_signature_with_cert(cert=cert, signed_data=data, signature=sig, algorithm='DS128') self.assertTrue(result)