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