Replace the hard-coded 522-bit RSA key size used for tests with a TEST_RSA_KEY_SIZE constant defined in test/common.py (part 1). refs #393

This commit is contained in:
david-sarah 2011-08-10 13:22:43 -07:00
parent 95a7551586
commit fbe0e42bbf
5 changed files with 13 additions and 13 deletions

View File

@ -69,14 +69,14 @@ class KeyGenerator:
mutable files which don't otherwise specify a size. This will affect
all subsequent calls to generate() without a keysize= argument. The
default size is 2048 bits. Test cases should call this method once
during setup, to cause me to create smaller (522 bit) keys, so the
unit tests run faster."""
during setup, to cause me to create smaller keys, so the unit tests
run faster."""
self.default_keysize = keysize
def generate(self, keysize=None):
"""I return a Deferred that fires with a (verifyingkey, signingkey)
pair. I accept a keysize in bits (522 bit keys are fast for testing,
2048 bit keys are standard). If you do not provide a keysize, I will
pair. I accept a keysize in bits (2048 bit keys are standard, smaller
keys are used for testing). If you do not provide a keysize, I will
use my default, which is set by a call to set_default_keysize(). If
set_default_keysize() has never been called, I will create 2048 bit
keys."""

View File

@ -539,7 +539,7 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin):
self.key_generator_svc = KeyGeneratorService(kgsdir,
display_furl=False,
default_key_size=522)
default_key_size=TEST_RSA_KEY_SIZE)
self.key_generator_svc.key_generator.pool_size = 4
self.key_generator_svc.key_generator.pool_refresh_delay = 60
self.add_service(self.key_generator_svc)
@ -599,7 +599,7 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin):
# will have registered the helper furl).
c = self.add_service(client.Client(basedir=basedirs[0]))
self.clients.append(c)
c.set_default_mutable_keysize(522)
c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE)
d = c.when_tub_ready()
def _ready(res):
f = open(os.path.join(basedirs[0],"private","helper.furl"), "r")
@ -617,7 +617,7 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin):
for i in range(1, self.numclients):
c = self.add_service(client.Client(basedir=basedirs[i]))
self.clients.append(c)
c.set_default_mutable_keysize(522)
c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE)
log.msg("STARTING")
return self.wait_for_connections()
d.addCallback(_ready)
@ -650,7 +650,7 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin):
def _stopped(res):
new_c = client.Client(basedir=self.getdir("client%d" % num))
self.clients[num] = new_c
new_c.set_default_mutable_keysize(522)
new_c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE)
self.add_service(new_c)
return new_c.when_tub_ready()
d.addCallback(_stopped)
@ -678,7 +678,7 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin):
c = client.Client(basedir=basedir)
self.clients.append(c)
c.set_default_mutable_keysize(522)
c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE)
self.numclients += 1
if add_to_sparent:
c.setServiceParent(self.sparent)

View File

@ -236,7 +236,7 @@ class NoNetworkGrid(service.MultiService):
c = client_config_hooks[i](clientdir)
if not c:
c = NoNetworkClient(clientdir)
c.set_default_mutable_keysize(522)
c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE)
c.nodeid = clientid
c.short_nodeid = b32encode(clientid).lower()[:8]
c._servers = self.all_servers # can be updated later

View File

@ -41,7 +41,7 @@ class KeyGenService(unittest.TestCase, pollmixin.PollMixin):
return junk
#print 'starting key generator service'
keysize = 522
keysize = TEST_RSA_KEY_SIZE
kgs = key_generator.KeyGeneratorService(display_furl=False, default_key_size=keysize)
kgs.key_generator.verbose = True
kgs.setServiceParent(self.parent)

View File

@ -228,7 +228,7 @@ def make_nodemaker(s=None, num_peers=10):
storage_broker = make_storagebroker(s, num_peers)
sh = client.SecretHolder("lease secret", "convergence secret")
keygen = client.KeyGenerator()
keygen.set_default_keysize(522)
keygen.set_default_keysize(TEST_RSA_KEY_SIZE)
nodemaker = NodeMaker(storage_broker, sh, None,
None, None,
{"k": 3, "n": 10}, keygen)
@ -2600,7 +2600,7 @@ class Problems(GridTestMixin, unittest.TestCase, testutil.ShouldFailMixin):
# use #467 static-server-selection to disable permutation and force
# the choice of server for share[0].
d = nm.key_generator.generate(522)
d = nm.key_generator.generate(TEST_RSA_KEY_SIZE)
def _got_key( (pubkey, privkey) ):
nm.key_generator = SameKeyGenerator(pubkey, privkey)
pubkey_s = pubkey.serialize()