示例#1
0
 def test_published_test_vectors_for_valid_matches(self):
     VALID_MATCHES = [
         ['profile:write', 'profile'],
         ['profile', 'profile:email'],
         ['profile:write', 'profile:email'],
         ['profile:write', 'profile:email:write'],
         ['profile:email:write', 'profile:email'],
         ['profile profile:email:write', 'profile:email'],
         ['profile profile:email:write', 'profile:display_name'],
         ['profile https://identity.mozilla.com/apps/oldsync', 'profile'],
         ['foo bar:baz', 'foo:dee'],
         ['foo bar:baz', 'bar:baz'],
         ['foo bar:baz', 'foo:mah:pa bar:baz:quux'],
         ['profile https://identity.mozilla.com/apps/oldsync',
             'https://identity.mozilla.com/apps/oldsync'],
         ['https://identity.mozilla.com/apps/oldsync',
             'https://identity.mozilla.com/apps/oldsync#read'],
         ['https://identity.mozilla.com/apps/oldsync',
             'https://identity.mozilla.com/apps/oldsync/bookmarks'],
         ['https://identity.mozilla.com/apps/oldsync',
             'https://identity.mozilla.com/apps/oldsync/bookmarks#read'],
         ['https://identity.mozilla.com/apps/oldsync#read',
             'https://identity.mozilla.com/apps/oldsync/bookmarks#read'],
         ['https://identity.mozilla.com/apps/oldsync#read profile',
             'https://identity.mozilla.com/apps/oldsync/bookmarks#read']
     ]
     for (provided, required) in VALID_MATCHES:
         self.assertTrue(scope_matches(provided.split(), required.split()),
                         '"{}" should match "{}"'.format(provided, required))
示例#2
0
 def test_published_test_vectors_for_invalid_matches(self):
     INVALID_MATCHES = [
         ['profile:email:write', 'profile'],
         ['profile:email:write', 'profile:write'],
         ['profile:email', 'profile:display_name'],
         ['profilebogey', 'profile'],
         ['foo bar:baz', 'bar'],
         ['profile:write', 'https://identity.mozilla.com/apps/oldsync'],
         ['profile profile:email:write', 'profile:write'],
         ['https', 'https://identity.mozilla.com/apps/oldsync'],
         ['https://identity.mozilla.com/apps/oldsync', 'profile'],
         ['https://identity.mozilla.com/apps/oldsync#read',
             'https://identity.mozila.com/apps/oldsync/bookmarks'],
         ['https://identity.mozilla.com/apps/oldsync#write',
             'https://identity.mozila.com/apps/oldsync/bookmarks#read'],
         ['https://identity.mozilla.com/apps/oldsync/bookmarks',
             'https://identity.mozila.com/apps/oldsync'],
         ['https://identity.mozilla.com/apps/oldsync/bookmarks',
             'https://identity.mozila.com/apps/oldsync/passwords'],
         ['https://identity.mozilla.com/apps/oldsyncer',
             'https://identity.mozila.com/apps/oldsync'],
         ['https://identity.mozilla.com/apps/oldsync',
             'https://identity.mozila.com/apps/oldsyncer'],
         ['https://identity.mozilla.org/apps/oldsync',
             'https://identity.mozila.com/apps/oldsync']
     ]
     for (provided, required) in INVALID_MATCHES:
         self.assertFalse(scope_matches(provided.split(), required.split()),
                          '"{}" should not match "{}"'.format(provided, required))
示例#3
0
 def test_published_test_vectors_for_invalid_matches(self):
     INVALID_MATCHES = [
         ['profile:email:write', 'profile'],
         ['profile:email:write', 'profile:write'],
         ['profile:email', 'profile:display_name'],
         ['profilebogey', 'profile'], ['foo bar:baz', 'bar'],
         ['profile:write', 'https://identity.mozilla.com/apps/oldsync'],
         ['profile profile:email:write', 'profile:write'],
         ['https', 'https://identity.mozilla.com/apps/oldsync'],
         ['https://identity.mozilla.com/apps/oldsync', 'profile'],
         [
             'https://identity.mozilla.com/apps/oldsync#read',
             'https://identity.mozila.com/apps/oldsync/bookmarks'
         ],
         [
             'https://identity.mozilla.com/apps/oldsync#write',
             'https://identity.mozila.com/apps/oldsync/bookmarks#read'
         ],
         [
             'https://identity.mozilla.com/apps/oldsync/bookmarks',
             'https://identity.mozila.com/apps/oldsync'
         ],
         [
             'https://identity.mozilla.com/apps/oldsync/bookmarks',
             'https://identity.mozila.com/apps/oldsync/passwords'
         ],
         [
             'https://identity.mozilla.com/apps/oldsyncer',
             'https://identity.mozila.com/apps/oldsync'
         ],
         [
             'https://identity.mozilla.com/apps/oldsync',
             'https://identity.mozila.com/apps/oldsyncer'
         ],
         [
             'https://identity.mozilla.org/apps/oldsync',
             'https://identity.mozila.com/apps/oldsync'
         ]
     ]
     for (provided, required) in INVALID_MATCHES:
         self.assertFalse(
             scope_matches(provided.split(), required.split()),
             '"{}" should not match "{}"'.format(provided, required))
示例#4
0
 def test_published_test_vectors_for_valid_matches(self):
     VALID_MATCHES = [
         ['profile:write', 'profile'], ['profile', 'profile:email'],
         ['profile:write', 'profile:email'],
         ['profile:write', 'profile:email:write'],
         ['profile:email:write', 'profile:email'],
         ['profile profile:email:write', 'profile:email'],
         ['profile profile:email:write', 'profile:display_name'],
         ['profile https://identity.mozilla.com/apps/oldsync', 'profile'],
         ['foo bar:baz', 'foo:dee'], ['foo bar:baz', 'bar:baz'],
         ['foo bar:baz', 'foo:mah:pa bar:baz:quux'],
         [
             'profile https://identity.mozilla.com/apps/oldsync',
             'https://identity.mozilla.com/apps/oldsync'
         ],
         [
             'https://identity.mozilla.com/apps/oldsync',
             'https://identity.mozilla.com/apps/oldsync#read'
         ],
         [
             'https://identity.mozilla.com/apps/oldsync',
             'https://identity.mozilla.com/apps/oldsync/bookmarks'
         ],
         [
             'https://identity.mozilla.com/apps/oldsync',
             'https://identity.mozilla.com/apps/oldsync/bookmarks#read'
         ],
         [
             'https://identity.mozilla.com/apps/oldsync#read',
             'https://identity.mozilla.com/apps/oldsync/bookmarks#read'
         ],
         [
             'https://identity.mozilla.com/apps/oldsync#read profile',
             'https://identity.mozilla.com/apps/oldsync/bookmarks#read'
         ]
     ]
     for (provided, required) in VALID_MATCHES:
         self.assertTrue(
             scope_matches(provided.split(), required.split()),
             '"{}" should match "{}"'.format(provided, required))
示例#5
0
 def test_do_not_match_if_provided_is_a_subscope(self):
     self.assertFalse(scope_matches(['abc:xyz'], 'abc'))
     self.assertFalse(scope_matches(['abc:xyz'], ['abc']))
     self.assertFalse(scope_matches(['abc:xyz', 'def'], ['abc', 'def']))
示例#6
0
 def test_do_not_match_if_subscopes_do_not_match(self):
     self.assertFalse(scope_matches(['abc:xyz'], 'abc:123'))
     self.assertFalse(scope_matches(['abc:xyz'], ['abc:xyz', 'abc:123']))
示例#7
0
 def test_matches_if_required_is_a_subscope(self):
     self.assertTrue(scope_matches(['abc'], 'abc:xyz'))
     self.assertTrue(scope_matches(['abc'], ['abc:xyz']))
     self.assertTrue(scope_matches(['abc', 'def'], ['abc:xyz', 'def']))
     self.assertTrue(scope_matches(['abc', 'def'], ['abc:xyz', 'def:123']))
示例#8
0
 def test_matches_if_one_of_required_is_not_provided(self):
     self.assertFalse(scope_matches(['abc'], ['abc', 'def']))
示例#9
0
 def test_matches_if_root_scopes_are_the_same(self):
     self.assertTrue(scope_matches(['abc', 'def'], 'abc'))
     self.assertTrue(scope_matches(['abc', 'def'], ['abc']))
示例#10
0
 def test_do_not_match_if_root_scopes_are_different(self):
     self.assertFalse(scope_matches(['abc'], 'def'))
     self.assertFalse(scope_matches(['abc'], ['def']))
示例#11
0
 def test_do_not_match_if_invalid_scope_provided(self):
     self.assertFalse(scope_matches(['abc'], ''))
     with self.assertRaises(Exception):
         scope_matches(['abc'], None)
示例#12
0
 def test_do_not_match_if_invalid_scope_provided(self):
     self.assertFalse(scope_matches(['abc'], ''))
     with self.assertRaises(Exception):
         scope_matches(['abc'], None)
示例#13
0
 def test_do_not_match_if_root_scopes_are_different(self):
     self.assertFalse(scope_matches(['abc'], 'def'))
     self.assertFalse(scope_matches(['abc'], ['def']))
示例#14
0
 def test_do_not_match_if_provided_is_a_subscope(self):
     self.assertFalse(scope_matches(['abc:xyz'], 'abc'))
     self.assertFalse(scope_matches(['abc:xyz'], ['abc']))
     self.assertFalse(scope_matches(['abc:xyz', 'def'], ['abc', 'def']))
示例#15
0
 def test_do_not_match_if_subscopes_do_not_match(self):
     self.assertFalse(scope_matches(['abc:xyz'], 'abc:123'))
     self.assertFalse(scope_matches(['abc:xyz'], ['abc:xyz', 'abc:123']))
示例#16
0
 def test_matches_if_required_is_a_subscope(self):
     self.assertTrue(scope_matches(['abc'], 'abc:xyz'))
     self.assertTrue(scope_matches(['abc'], ['abc:xyz']))
     self.assertTrue(scope_matches(['abc', 'def'], ['abc:xyz', 'def']))
     self.assertTrue(scope_matches(['abc', 'def'], ['abc:xyz', 'def:123']))
示例#17
0
 def test_matches_if_one_of_required_is_not_provided(self):
     self.assertFalse(scope_matches(['abc'], ['abc', 'def']))
示例#18
0
 def test_matches_if_root_scopes_are_the_same(self):
     self.assertTrue(scope_matches(['abc', 'def'], 'abc'))
     self.assertTrue(scope_matches(['abc', 'def'], ['abc']))
示例#19
0
 def test_always_matches_if_required_is_empty(self):
     self.assertTrue(scope_matches(['abc'], []))
示例#20
0
 def test_always_matches_if_required_is_empty(self):
     self.assertTrue(scope_matches(['abc'], []))