def test_lone_asterisk_matches_everything(self):
     pattern = '*'
     assert_true(Origin.match(pattern, 'https://ishkabibble.com:443'))
Example #2
0
 def check_origin_permission(self, origin, dataset):
     for ds_origin in dataset.origins.all().prefetch_related('permissions'):
         if Origin.match(ds_origin.pattern, origin):
             return ds_origin, ds_origin
     raise PermissionDenied("None of the dataset's origin permission policies matched")
 def test_match_ports_with_asterisk(self):
     pattern = 'localhost:*'
     assert_false(Origin.match(pattern, 'https://github.com'))
     assert_true(Origin.match(pattern, 'http://localhost:8000'))
 def test_match_domains_with_scheme(self):
     pattern = 'http://github.com'
     assert_false(Origin.match(pattern, 'https://github.com'))
     assert_true(Origin.match(pattern, 'http://github.com'))
 def test_match_simple_domains(self):
     pattern = 'github.com'
     assert_true(Origin.match(pattern, 'https://github.com'))
     assert_false(Origin.match(pattern, 'ftp://github.com'))
     assert_false(Origin.match(pattern, 'http://openplans.github.com'))
 def test_match_subdomains_with_asterisk(self):
     pattern = '*.github.com'
     assert_false(Origin.match(pattern, 'https://github.com'))
     assert_true(Origin.match(pattern, 'http://openplans.github.com'))
     assert_false(Origin.match(pattern, 'http://openplansngithub.com'))
Example #7
0
 def test_lone_asterisk_matches_everything(self):
     pattern = '*'
     assert_true(Origin.match(pattern, 'https://ishkabibble.com:443'))
Example #8
0
 def test_match_domains_with_scheme(self):
     pattern = 'http://github.com'
     assert_false(Origin.match(pattern, 'https://github.com'))
     assert_true(Origin.match(pattern, 'http://github.com'))
Example #9
0
 def test_match_ports_with_asterisk(self):
     pattern = 'localhost:*'
     assert_false(Origin.match(pattern, 'https://github.com'))
     assert_true(Origin.match(pattern, 'http://localhost:8000'))
Example #10
0
 def test_match_subdomains_with_asterisk(self):
     pattern = '*.github.com'
     assert_false(Origin.match(pattern, 'https://github.com'))
     assert_true(Origin.match(pattern, 'http://openplans.github.com'))
     assert_false(Origin.match(pattern, 'http://openplansngithub.com'))
Example #11
0
 def test_match_simple_domains(self):
     pattern = 'github.com'
     assert_true(Origin.match(pattern, 'https://github.com'))
     assert_false(Origin.match(pattern, 'ftp://github.com'))
     assert_false(Origin.match(pattern, 'http://openplans.github.com'))