def test_Main_createBridgeRings(self): """Main.createBridgeRings() should add three hashrings to the splitter. """ proxyList = None (splitter, emailDist, httpsDist) = Main.createBridgeRings(self.config, proxyList, self.key) # Should have an IPBasedDistributor ring, an EmailDistributor ring, # and an UnallocatedHolder ring: self.assertEqual(len(splitter.ringsByName.keys()), 3)
def test_Main_createBridgeRings_no_reserved_share(self): """When RESERVED_SHARE=0, Main.createBridgeRings() should add only two hashrings to the splitter. """ proxyList = Main.proxy.ProxySet() config = self.config config.RESERVED_SHARE = 0 (splitter, emailDist, httpsDist) = Main.createBridgeRings(config, proxyList, self.key) # Should have an IPBasedDistributor ring, and an EmailDistributor ring: self.assertEqual(len(splitter.ringsByName.keys()), 2) self.assertNotIn('unallocated', splitter.rings)
def test_Main_createBridgeRings_no_email_dist(self): """When EMAIL_DIST=False, Main.createBridgeRings() should add only two hashrings to the splitter. """ proxyList = Main.proxy.ProxySet() config = self.config config.EMAIL_DIST = False (splitter, emailDist, httpsDist) = Main.createBridgeRings(config, proxyList, self.key) # Should have an IPBasedDistributor ring, and an UnallocatedHolder ring: self.assertEqual(len(splitter.ringsByName.keys()), 2) self.assertNotIn('email', splitter.rings) self.assertNotIn(emailDist, splitter.ringsByName.values())
def test_Main_createBridgeRings_no_https_dist(self): """When HTTPS_DIST=False, Main.createBridgeRings() should add only two hashrings to the hashring. """ proxyList = Main.proxy.ProxySet() config = self.config config.HTTPS_DIST = False (hashring, emailDist, httpsDist) = Main.createBridgeRings(config, proxyList, self.key) # Should have an EmailDistributor ring, and an UnallocatedHolder ring: self.assertEqual(len(hashring.ringsByName.keys()), 2) self.assertNotIn('https', hashring.rings) self.assertNotIn(httpsDist, hashring.ringsByName.values())
def test_Main_createBridgeRings_with_proxyList(self): """Main.createBridgeRings() should add three hashrings to the splitter and add the proxyList to the IPBasedDistibutor. """ exitRelays = ['1.1.1.1', '2.2.2.2', '3.3.3.3'] proxyList = Main.proxy.ProxySet() proxyList.addExitRelays(exitRelays) (splitter, emailDist, httpsDist) = Main.createBridgeRings(self.config, proxyList, self.key) # Should have an IPBasedDistributor ring, an EmailDistributor ring, # and an UnallocatedHolder ring: self.assertEqual(len(splitter.ringsByName.keys()), 3) self.assertGreater(len(httpsDist.categories), 0) self.assertItemsEqual(exitRelays, httpsDist.categories[-1])
def test_Main_createBridgeRings_two_file_buckets(self): """When FILE_BUCKETS has two filenames in it, Main.createBridgeRings() should add three hashrings to the splitter, then add two "pseudo-rings". """ proxyList = Main.proxy.ProxySet() config = self.config config.FILE_BUCKETS = { 'bridges-for-support-desk': 10, 'bridges-for-ooni-tests': 10, } (splitter, emailDist, httpsDist) = Main.createBridgeRings(config, proxyList, self.key) # Should have an IPBasedDistributor ring, an EmailDistributor, and an # UnallocatedHolder ring: self.assertEqual(len(splitter.ringsByName.keys()), 3) # Should have two pseudoRings: self.assertEqual(len(splitter.pseudoRings), 2) self.assertIn('pseudo_bridges-for-support-desk', splitter.pseudoRings) self.assertIn('pseudo_bridges-for-ooni-tests', splitter.pseudoRings)