def test_HTTPSDistributor_getBridges_with_varied_blocked_bridges(self):
    dist = distributor.HTTPSDistributor(1, self.key)
    bridges = self.bridges[:]
    for bridge in bridges:
        bridge.setBlockedIn('cn', methodname='vanilla')
        bridge.setBlockedIn('cn', methodname='obfs2')
        if self.coinFlip():
            bridge.setBlockedIn('cn', methodname='obfs3')
    [dist.insert(bridge) for bridge in bridges]
    for i in xrange(5):
        bridgeRequest1 = self.randomClientRequestForNotBlockedIn('cn')
        bridgeRequest1.transports.append('obfs2')
        bridgeRequest1.generateFilters()
        bridges = dist.getBridges(bridgeRequest1, 'faketimestamp')
        self.assertEqual(len(bridges), 0)
        bridgeRequest2 = self.randomClientRequestForNotBlockedIn('cn')
        bridgeRequest2.transports.append('obfs3')
        bridgeRequest2.generateFilters()
        bridges = dist.getBridges(bridgeRequest2, 'faketimestamp')
        self.assertGreater(len(bridges), 0)
        bridgeRequest3 = self.randomClientRequestForNotBlockedIn('nl')
        bridgeRequest3.transports.append('obfs3')
        bridgeRequest3.generateFilters()
        bridges = dist.getBridges(bridgeRequest3, 'faketimestamp')
        self.assertGreater(len(bridges), 0)
def test_HTTPSDistributor_getBridges_with_varied_blocked_bridges(self):
    dist = distributor.HTTPSDistributor(1, self.key)
    bridges = self.bridges[:]
    for bridge in bridges:
        bridge.setBlockedIn('cn', methodname='vanilla')
        bridge.setBlockedIn('cn', methodname='obfs2')
        if self.coinFlip():
            bridge.setBlockedIn('cn', methodname='obfs3')
    [dist.insert(bridge) for bridge in bridges]
    for i in xrange(5):
        bridgeRequest1 = self.randomClientRequestForNotBlockedIn('cn')
        bridgeRequest1.transports.append('obfs2')
        bridgeRequest1.generateFilters()
        bridges = dist.getBridges(bridgeRequest1, 'faketimestamp')
        self.assertEqual(len(bridges), 0)
        bridgeRequest2 = self.randomClientRequestForNotBlockedIn('cn')
        bridgeRequest2.transports.append('obfs3')
        bridgeRequest2.generateFilters()
        bridges = dist.getBridges(bridgeRequest2, 'faketimestamp')
        self.assertGreater(len(bridges), 0)
        bridgeRequest3 = self.randomClientRequestForNotBlockedIn('nl')
        bridgeRequest3.transports.append('obfs3')
        bridgeRequest3.generateFilters()
        bridges = dist.getBridges(bridgeRequest3, 'faketimestamp')
        self.assertGreater(len(bridges), 0)