~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/test_account.py

  • Committer: John Arbash Meinel
  • Date: 2008-10-30 00:55:00 UTC
  • mto: (3815.2.5 prepare-1.9)
  • mto: This revision was merged to the branch mainline in revision 3811.
  • Revision ID: john@arbash-meinel.com-20081030005500-r5cej1cxflqhs3io
Switch so that we are using a simple timestamp as the first action.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        self.assertEqualDiff('The user test-user has not registered any '
64
64
                             'SSH keys with Launchpad.', str(error))
65
65
 
 
66
    def test_set_lp_login_updates_authentication_conf(self):
 
67
        self.assertIs(None, account._get_auth_user())
 
68
        account.set_lp_login('foo')
 
69
        self.assertEqual('foo', account._get_auth_user())
 
70
 
 
71
    def test_get_lp_login_does_not_update_for_none_user(self):
 
72
        account.get_lp_login()
 
73
        self.assertIs(None, account._get_auth_user())
 
74
 
 
75
    def test_get_lp_login_updates_authentication_conf(self):
 
76
        account._set_global_option('foo')
 
77
        self.assertIs(None, account._get_auth_user())
 
78
        account.get_lp_login()
 
79
        auth = config.AuthenticationConfig()
 
80
        self.assertEqual('foo', account._get_auth_user(auth))
 
81
        self.assertEqual('foo', auth.get_user('ssh', 'bazaar.launchpad.net'))
 
82
        self.assertEqual('foo', auth.get_user('ssh',
 
83
                                              'bazaar.staging.launchpad.net'))
 
84
 
 
85
    def test_get_lp_login_leaves_existing_credentials(self):
 
86
        auth = config.AuthenticationConfig()
 
87
        auth.set_credentials('Foo', 'bazaar.launchpad.net', 'foo', 'ssh')
 
88
        auth.set_credentials('Bar', 'bazaar.staging.launchpad.net', 'foo',
 
89
                             'ssh')
 
90
        account._set_global_option('foo')
 
91
        account.get_lp_login()
 
92
        auth = config.AuthenticationConfig()
 
93
        credentials = auth.get_credentials('ssh', 'bazaar.launchpad.net')
 
94
        self.assertEqual('Foo', credentials['name'])
 
95
 
 
96
    def test_get_lp_login_errors_on_mismatch(self):
 
97
        account._set_auth_user('foo')
 
98
        account._set_global_option('bar')
 
99
        e = self.assertRaises(account.MismatchedUsernames,
 
100
                              account.get_lp_login)
 
101
        self.assertEqual('bazaar.conf and authentication.conf disagree about'
 
102
            ' launchpad account name.  Please re-run launchpad-login.', str(e))
 
103
 
66
104
 
67
105
class CheckAccountTests(TestCaseWithMemoryTransport):
68
106