Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 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())
Esempio n. 5
0
 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())
Esempio n. 6
0
 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)
Esempio n. 7
0
 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])
Esempio n. 8
0
 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())
Esempio n. 9
0
 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])
Esempio n. 10
0
    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)
Esempio n. 11
0
    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)