Logo Search packages:      
Sourcecode: ubuntu-sso-client version File versions  Download package

def ubuntu_sso::tests::test_auth::AcquireAccessTokenTests::test_acquire_access_token (   self  ) 

Test that acquire_access_token() can acquire the access token.

Definition at line 221 of file test_auth.py.

00221                                        :
        """Test that acquire_access_token() can acquire the access token."""

        def make_token_request(oauth_request):
            """Make an OAuth token request via the test browser."""
            return oauth.OAuthToken.from_string("oauth_token=access_token&" +
                                                "oauth_token_secret=" +
                                                "access_secret")

        def open_in_browser(url):
            """Just return as we aren't subscribed to the page."""
            return

        def got_token(token):
            """Called with the token once auth is completed"""
            self.assertTrue(isinstance(token, oauth.OAuthToken))

        def get_temporary_httpd(nonce, retrieve_function, store):
            """Mock the temporary httpd and return a callback URL"""
            # returns callback URL; this is an invalid URL, of course,
            # (port is too high) but we check later that the mechanize
            # browser tries to navigate there
            return "http://localhost:99999/?nonce=99999"

        def store_token(token):
            """Don't use the keyring; do nothing"""
            pass

        client = AuthorisationClient(
            'http://ubuntuone/',
            'http://ubuntuone/oauth/request/',
            'http://ubuntuone/oauth/authorize/',
            'http://ubuntuone/oauth/access/',
            'consumer_key', 'consumer_secret',
            callback_parent=got_token)
        client.make_token_request = make_token_request
        client.open_in_browser = open_in_browser
        client.get_temporary_httpd = get_temporary_httpd
        client.store_token = store_token

        client.acquire_access_token('token description')
        client.acquire_access_token('token description')


Generated by  Doxygen 1.6.0   Back to index