예제 #1
0
파일: policy.py 프로젝트: neelchauhan/stem
    def test_microdescriptor_can_exit_to(self):
        test_inputs = {
            'accept 443': {
                442: False,
                443: True,
                444: False
            },
            'reject 443': {
                442: True,
                443: False,
                444: True
            },
            'accept 80,443': {
                80: True,
                443: True,
                10: False
            },
            'reject 1-1024': {
                1: False,
                1024: False,
                1025: True
            },
        }

        for policy_arg, attr in test_inputs.items():
            policy = MicroExitPolicy(policy_arg)

            for port, expected_value in attr.items():
                self.assertEqual(expected_value, policy.can_exit_to(port=port))

        # address argument should be ignored
        policy = MicroExitPolicy('accept 80,443')

        self.assertFalse(policy.can_exit_to('127.0.0.1', 79))
        self.assertTrue(policy.can_exit_to('127.0.0.1', 80))
예제 #2
0
파일: policy.py 프로젝트: patrickod/stem
  def test_microdescriptor_can_exit_to(self):
    test_inputs = {
      'accept 443': {442: False, 443: True, 444: False},
      'reject 443': {442: True, 443: False, 444: True},
      'accept 80,443': {80: True, 443: True, 10: False},
      'reject 1-1024': {1: False, 1024: False, 1025: True},
    }

    for policy_arg, attr in test_inputs.items():
      policy = MicroExitPolicy(policy_arg)

      for port, expected_value in attr.items():
        self.assertEqual(expected_value, policy.can_exit_to(port = port))

    # address argument should be ignored
    policy = MicroExitPolicy('accept 80,443')

    self.assertFalse(policy.can_exit_to('127.0.0.1', 79))
    self.assertTrue(policy.can_exit_to('127.0.0.1', 80))
예제 #3
0
파일: rule.py 프로젝트: patrickod/stem
  def test_with_multiple_spaces(self):
    rule = ExitPolicyRule('accept    *:80')
    self.assertEqual('accept *:80', str(rule))

    policy = MicroExitPolicy('accept      80,443')
    self.assertTrue(policy.can_exit_to('75.119.206.243', 80))
예제 #4
0
파일: rule.py 프로젝트: rl1987/stem
    def test_with_multiple_spaces(self):
        rule = ExitPolicyRule('accept    *:80')
        self.assertEqual('accept *:80', str(rule))

        policy = MicroExitPolicy('accept      80,443')
        self.assertTrue(policy.can_exit_to('75.119.206.243', 80))