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]'] }
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]'
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'
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]'
def test_read_something(): obj = oauth2.Read('something') assert str(obj) == 'read[something]' assert obj.resource_id == 'something'
def test_read(): obj = oauth2.Read() assert str(obj) == 'read' assert obj.resource_id is None