コード例 #1
0
ファイル: test_auth.py プロジェクト: zhouzhuojie/libgreader
 def test_getting_request_token(self):
     auth = OAuthMethod(oauth_key, oauth_secret)
     token, token_secret = auth.setAndGetRequestToken()
     url = auth.buildAuthUrl()
     response = automated_oauth_approval(url)
     self.assertNotEqual(
         -1,
         response.get_data().find('You have successfully granted'))
コード例 #2
0
    def test_full_auth_process_without_callback(self):
        auth = OAuthMethod(oauth_key, oauth_secret)
        auth.setRequestToken()
        auth_url = auth.buildAuthUrl()
        response = automated_oauth_approval(auth_url)
        auth.setAccessToken()
        reader = GoogleReader(auth)

        info = reader.getUserInfo()
        self.assertEqual(dict, type(info))
        self.assertEqual(firstname, info['userName'])
コード例 #3
0
    def test_full_auth_process_with_callback(self):
        auth = OAuthMethod(oauth_key, oauth_secret)
        #must be a working callback url for testing
        auth.setCallback("http://www.asktherelic.com")
        token, token_secret = auth.setAndGetRequestToken()
        auth_url = auth.buildAuthUrl()

        #callback section
        #get response, which is a redirect to the callback url
        response = automated_oauth_approval(auth_url)
        query_string = urlparse.urlparse(response.geturl()).query
        #grab the verifier token from the callback url query string
        token_verifier = urlparse.parse_qs(query_string)['oauth_verifier'][0]

        auth.setAccessTokenFromCallback(token, token_secret, token_verifier)
        reader = GoogleReader(auth)

        info = reader.getUserInfo()
        self.assertEqual(dict, type(info))
        self.assertEqual(firstname, info['userName'])
コード例 #4
0
 def test_oauth_login(self):
     auth = OAuthMethod(oauth_key, oauth_secret)
     self.assertNotEqual(auth, None)