Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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']))
Exemplo n.º 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']))
Exemplo n.º 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']))
Exemplo n.º 8
0
 def test_matches_if_one_of_required_is_not_provided(self):
     self.assertFalse(scope_matches(['abc'], ['abc', 'def']))
Exemplo n.º 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']))
Exemplo n.º 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']))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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']))
Exemplo n.º 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']))
Exemplo n.º 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']))
Exemplo n.º 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']))
Exemplo n.º 17
0
 def test_matches_if_one_of_required_is_not_provided(self):
     self.assertFalse(scope_matches(['abc'], ['abc', 'def']))
Exemplo n.º 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']))
Exemplo n.º 19
0
 def test_always_matches_if_required_is_empty(self):
     self.assertTrue(scope_matches(['abc'], []))
Exemplo n.º 20
0
 def test_always_matches_if_required_is_empty(self):
     self.assertTrue(scope_matches(['abc'], []))