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')])
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)
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)
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')])
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')])