def test_delete(self): oauth2.add_client('hi','password') assert_in('hi', oauth2.clients) assert_equal(oauth2.clients['hi'], 'password') oauth2.del_client('hi','wrong') assert_in('hi', oauth2.clients) assert_equal(oauth2.clients['hi'], 'password') oauth2.del_client('hi','password') assert_not_in('hi', oauth2.clients)
def test_create_and_revoke(self): oauth2.add_client('hi','password') code = self.get_code('hi') token_request = {'client_id':'hi', 'client_secret':'password', 'grant_type':'authorization_code', 'code':code} resp = oauth2.token(token_request) token_data = json.loads(resp) assert_in('access_token', token_data) assert_in('expires_in', token_data) assert_in('token_type', token_data) assert_not_in('refresh_token', token_data) # throws an exception if invalid works = oauth2.validate_access_token(token_data['access_token']) # revoke oauth2.del_client('hi','password') try: works = oauth2.validate_access_token(token_data['access_token']) fail() except: pass