##// END OF EJS Templates
ssh: show fingerprint when adding already existing key....
marcink -
r2594:dc2a5f04 default
parent child Browse files
Show More
@@ -67,6 +67,7 b' class TestAdminUsersSshKeysView(TestCont'
67 67 'I4fG8+hBHzpeFxUGvSGNtXPUbwaAY8j/oHYrTpMgkj6pUEFsiKfC5zPq' \
68 68 'PFR5HyKTCHW0nFUJnZsbyFT5hMiF/hZkJc9A0ZbdSvJwCRQ/g3bmdL ' \
69 69 'your_email@example.com'
70 FINGERPRINT = 'MD5:01:4f:ad:29:22:6e:01:37:c9:d2:52:26:52:b0:2d:93'
70 71
71 72 def test_ssh_keys_default_user(self):
72 73 self.log_user()
@@ -111,9 +112,11 b' class TestAdminUsersSshKeysView(TestCont'
111 112 route_path('edit_user_ssh_keys_add', user_id=user_id),
112 113 {'description': desc, 'key_data': key_data,
113 114 'csrf_token': self.csrf_token})
115
116 err = 'Such key with fingerprint `{}` already exists, ' \
117 'please use a different one'.format(self.FINGERPRINT)
114 118 assert_session_flash(response, 'An error occurred during ssh key '
115 'saving: Such key already exists, '
116 'please use a different one')
119 'saving: {}'.format(err))
117 120
118 121 def test_add_ssh_key(self, user_util):
119 122 self.log_user()
@@ -817,6 +817,7 b' class UsersView(UserAppView):'
817 817 key_data = self.request.POST.get('key_data')
818 818 description = self.request.POST.get('description')
819 819
820 fingerprint = 'unknown'
820 821 try:
821 822 if not key_data:
822 823 raise ValueError('Please add a valid public key')
@@ -841,8 +842,9 b' class UsersView(UserAppView):'
841 842
842 843 except IntegrityError:
843 844 log.exception("Exception during ssh key saving")
844 h.flash(_('An error occurred during ssh key saving: {}').format(
845 'Such key already exists, please use a different one'),
845 err = 'Such key with fingerprint `{}` already exists, ' \
846 'please use a different one'.format(fingerprint)
847 h.flash(_('An error occurred during ssh key saving: {}').format(err),
846 848 category='error')
847 849 except Exception as e:
848 850 log.exception("Exception during ssh key saving")
@@ -66,6 +66,7 b' class TestMyAccountSshKeysView(TestContr'
66 66 'I4fG8+hBHzpeFxUGvSGNtXPUbwaAY8j/oHYrTpMgkj6pUEFsiKfC5zPq' \
67 67 'PFR5HyKTCHW0nFUJnZsbyFT5hMiF/hZkJc9A0ZbdSvJwCRQ/g3bmdL ' \
68 68 'your_email@example.com'
69 FINGERPRINT = 'MD5:01:4f:ad:29:22:6e:01:37:c9:d2:52:26:52:b0:2d:93'
69 70
70 71 def test_add_ssh_key_error(self, user_util):
71 72 user = user_util.create_user(password='qweqwe')
@@ -100,9 +101,11 b' class TestMyAccountSshKeysView(TestContr'
100 101 route_path('my_account_ssh_keys_add'),
101 102 {'description': desc, 'key_data': key_data,
102 103 'csrf_token': self.csrf_token})
104
105 err = 'Such key with fingerprint `{}` already exists, ' \
106 'please use a different one'.format(self.FINGERPRINT)
103 107 assert_session_flash(response, 'An error occurred during ssh key '
104 'saving: Such key already exists, '
105 'please use a different one')
108 'saving: {}'.format(err))
106 109
107 110 def test_add_ssh_key(self, user_util):
108 111 user = user_util.create_user(password='qweqwe')
@@ -89,7 +89,7 b' class MyAccountSshKeysView(BaseAppView, '
89 89 user_data = c.user.get_api_data()
90 90 key_data = self.request.POST.get('key_data')
91 91 description = self.request.POST.get('description')
92
92 fingerprint = 'unknown'
93 93 try:
94 94 if not key_data:
95 95 raise ValueError('Please add a valid public key')
@@ -114,8 +114,9 b' class MyAccountSshKeysView(BaseAppView, '
114 114
115 115 except IntegrityError:
116 116 log.exception("Exception during ssh key saving")
117 h.flash(_('An error occurred during ssh key saving: {}').format(
118 'Such key already exists, please use a different one'),
117 err = 'Such key with fingerprint `{}` already exists, ' \
118 'please use a different one'.format(fingerprint)
119 h.flash(_('An error occurred during ssh key saving: {}').format(err),
119 120 category='error')
120 121 except Exception as e:
121 122 log.exception("Exception during ssh key saving")
General Comments 0
You need to be logged in to leave comments. Login now