~ubuntu-branches/ubuntu/utopic/keystone/utopic

« back to all changes in this revision

Viewing changes to keystone/tests/test_auth.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-10-16 09:27:09 UTC
  • mfrom: (1.1.39)
  • Revision ID: package-import@ubuntu.com-20131016092709-aecqzw81zvkt7214
Tags: 1:2013.2~rc3-0ubuntu1
New upstream release candidate (LP: #1240254).

Show diffs side-by-side

added added

removed removed

Lines of Context:
603
603
        self.sample_data = {'trustor_user_id': self.trustor['id'],
604
604
                            'trustee_user_id': self.trustee['id'],
605
605
                            'project_id': self.tenant_bar['id'],
606
 
                            'impersonation': 'True',
 
606
                            'impersonation': True,
607
607
                            'roles': [{'id': self.role_browser['id']},
608
608
                                      {'name': self.role_member['name']}]}
609
609
        expires_at = timeutils.strtime(timeutils.utcnow() +
611
611
                                       fmt=TIME_FORMAT)
612
612
        self.create_trust(expires_at=expires_at)
613
613
 
614
 
    def create_trust(self, expires_at=None, impersonation='True'):
 
614
    def create_trust(self, expires_at=None, impersonation=True):
615
615
        username = self.trustor['name'],
616
616
        password = 'foo2'
617
617
        body_dict = _build_user_auth(username=username, password=password)
676
676
            self.assertIn(role['id'], role_ids)
677
677
 
678
678
    def test_create_trust_no_impersonation(self):
679
 
        self.create_trust(expires_at=None, impersonation='False')
 
679
        self.create_trust(expires_at=None, impersonation=False)
680
680
        self.assertEquals(self.new_trust['trustor_user_id'],
681
681
                          self.trustor['id'])
682
682
        self.assertEquals(self.new_trust['trustee_user_id'],
683
683
                          self.trustee['id'])
684
 
        self.assertEquals(self.new_trust['impersonation'],
685
 
                          'False')
 
684
        self.assertIs(self.new_trust['impersonation'], False)
686
685
        auth_response = self.fetch_v2_token_from_trust()
687
686
        token_user = auth_response['access']['user']
688
687
        self.assertEquals(token_user['id'],
690
689
 
691
690
        # TODO(ayoung): Endpoints
692
691
 
 
692
    def test_create_trust_impersonation(self):
 
693
        self.create_trust(expires_at=None)
 
694
        self.assertEqual(self.new_trust['trustor_user_id'], self.trustor['id'])
 
695
        self.assertEqual(self.new_trust['trustee_user_id'], self.trustee['id'])
 
696
        self.assertIs(self.new_trust['impersonation'], True)
 
697
        auth_response = self.fetch_v2_token_from_trust()
 
698
        token_user = auth_response['access']['user']
 
699
        self.assertEqual(token_user['id'], self.new_trust['trustor_user_id'])
 
700
 
693
701
    def test_token_from_trust_wrong_user_fails(self):
694
702
        request_body = self.build_v2_token_request('FOO', 'foo2')
695
703
        self.assertRaises(