예제 #1
0
 def test_unknown_cred_given_with_login(self):
     self.context['cred_list'] = ['badcred']
     self.context['credentials']['default'].pop('username')
     with self.assertRaisesRegex(UniconAuthenticationError,
                                 '.*No username.*badcred'):
         login_handler(self.spawn, self.context, self.session)
         password_handler(self.spawn, self.context, self.session)
 def test_cred_seq_login_password(self):
     self.context['cred_list'] = ['mycred', 'default']
     login_handler(self.spawn, self.context, self.session)
     login_handler(self.spawn, self.context, self.session)
     password_handler(self.spawn, self.context, self.session)
     login_handler(self.spawn, self.context, self.session)
     password_handler(self.spawn, self.context, self.session)
     self.spawn.sendline.assert_has_calls(
         [call('admin'), call('cisco'),
          call('defun'), call('defpw')])
예제 #3
0
 def _test_password_handler(self):
     """ Execute password handler twice
     """
     password_handler(self.spawn, self.context, self.session)
     password_handler(self.spawn, self.context, self.session)
예제 #4
0
 def test_password_failed(self):
     with self.assertRaisesRegex(CredentialsExhaustedError,
                                 '.*tried without success.*default'):
         login_handler(self.spawn, self.context, self.session)
         password_handler(self.spawn, self.context, self.session)
         password_handler(self.spawn, self.context, self.session)
예제 #5
0
 def test_no_password_specified(self):
     self.context['credentials']['default'].pop('password')
     with self.assertRaisesRegex(UniconAuthenticationError,
                                 '.*No password.*default'):
         login_handler(self.spawn, self.context, self.session)
         password_handler(self.spawn, self.context, self.session)
예제 #6
0
 def test_default_cred_sent_when_unknown_cred_given_with_login(self):
     self.context['cred_list'] = ['badcred']
     login_handler(self.spawn, self.context, self.session)
     password_handler(self.spawn, self.context, self.session)
     self.spawn.sendline.assert_has_calls([call('defun'), call('defpw')])
예제 #7
0
 def test_default_cred_sent_if_no_creds_given_with_login(self):
     login_handler(self.spawn, self.context, self.session)
     password_handler(self.spawn, self.context, self.session)
     self.spawn.sendline.assert_has_calls([call('defun'), call('defpw')])
예제 #8
0
 def test_password_retries(self):
     with self.assertRaises(UniconAuthenticationError):
         for x in range(4):
             password_handler(self.spawn, self.context, self.session)