Ejemplo n.º 1
0
    def test_get_token_with_scope(self):
        token = yield oauth2.get_token('https://localhost:8007',
                                       '4225f4774d6874a68565a04130001144',
                                       'FMjU7vNIay5HGNABQVTTghOfEJqbet',
                                       scope=oauth2.Scope(
                                           oauth2.Write(1), oauth2.Read()))

        assert token == self.token

        body = self.API().auth.token.post.call_args[1]['body']
        assert urlparse.parse_qs(body) == {
            'grant_type': [oauth2.CLIENT_CREDENTIALS],
            'scope': ['read write[1]']
        }
Ejemplo n.º 2
0
def test_scope_remove_does_not_exist():
    scope = oauth2.Scope(oauth2.Read(), oauth2.Write(1),
                         oauth2.Delegate(2, oauth2.Write(3)))
    scope.remove(oauth2.Write(5))

    assert str(scope) == 'delegate[2]:write[3] read write[1]'
Ejemplo n.º 3
0
def test_scope_remove():
    scope = oauth2.Scope(oauth2.Read(), oauth2.Write(1),
                         oauth2.Delegate(2, oauth2.Write(3)))
    scope.remove(oauth2.Write(1))

    assert str(scope) == 'delegate[2]:write[3] read'
Ejemplo n.º 4
0
def test_scope_add():
    scope = oauth2.Scope(oauth2.Read(), oauth2.Write(1),
                         oauth2.Delegate(2, oauth2.Write(3)))
    scope.add(oauth2.Write(4))

    assert str(scope) == 'delegate[2]:write[3] read write[1] write[4]'
Ejemplo n.º 5
0
def test_read_something():
    obj = oauth2.Read('something')
    assert str(obj) == 'read[something]'
    assert obj.resource_id == 'something'
Ejemplo n.º 6
0
def test_read():
    obj = oauth2.Read()
    assert str(obj) == 'read'
    assert obj.resource_id is None