~ubuntuone-control-tower/ubuntu-sso-client/trunk

« back to all changes in this revision

Viewing changes to ubuntu_sso/utils/webclient/tests/test_webclient.py

  • Committer: Tarmac
  • Author(s): Alejandro J. Cura
  • Date: 2012-03-18 20:53:35 UTC
  • mfrom: (920.1.1 fix-wrong-credentials)
  • Revision ID: tarmac-20120318205335-x011hv9qnd2kqvk0
- Handle wrong credentials properly in qtnetwork webclient (LP: #957317)

Show diffs side-by-side

added added

removed removed

Lines of Context:
318
318
    @defer.inlineCallbacks
319
319
    def test_send_basic_auth(self):
320
320
        """The basic authentication headers are sent."""
321
 
        other_wc = webclient.webclient_factory(username=SAMPLE_USERNAME,
322
 
                                               password=SAMPLE_PASSWORD)
 
321
        other_wc = self.webclient_factory(username=SAMPLE_USERNAME,
 
322
                                          password=SAMPLE_PASSWORD)
323
323
        self.addCleanup(other_wc.shutdown)
324
324
        result = yield other_wc.request(self.base_iri + GUARDED)
325
325
        self.assertEqual(SAMPLE_RESOURCE, result.content)
326
326
 
327
327
    @defer.inlineCallbacks
 
328
    def test_send_basic_auth_wrong_credentials(self):
 
329
        """Wrong credentials returns a webclient error."""
 
330
        other_wc = self.webclient_factory(username=SAMPLE_USERNAME,
 
331
                                          password="wrong password!")
 
332
        self.addCleanup(other_wc.shutdown)
 
333
        yield self.assertFailure(other_wc.request(self.base_iri + GUARDED),
 
334
                                 webclient.UnauthorizedError)
 
335
 
 
336
    @defer.inlineCallbacks
328
337
    def test_request_is_oauth_signed(self):
329
338
        """The request is oauth signed."""
330
339
        tsc = self.wc.get_timestamp_checker()