From: david-sarah Date: Wed, 10 Aug 2011 20:22:43 +0000 (-0700) Subject: Replace the hard-coded 522-bit RSA key size used for tests with a TEST_RSA_KEY_SIZE... X-Git-Tag: trac-5200~7 X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/install.html?a=commitdiff_plain;h=fbe0e42bbf54ea99f391c9cebdee5210c20a842a;p=tahoe-lafs%2Ftahoe-lafs.git 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 --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 46eb3c09..3cb4cd66 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -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.""" diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index 33678a00..d728bcb0 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -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) diff --git a/src/allmydata/test/no_network.py b/src/allmydata/test/no_network.py index 535cac1f..4730a952 100644 --- a/src/allmydata/test/no_network.py +++ b/src/allmydata/test/no_network.py @@ -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 diff --git a/src/allmydata/test/test_keygen.py b/src/allmydata/test/test_keygen.py index 45fbaea2..c282a888 100644 --- a/src/allmydata/test/test_keygen.py +++ b/src/allmydata/test/test_keygen.py @@ -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) diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index 5113a5db..1ef424da 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -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()