diff --git a/tests/test_progit_flask_ui_admin.py b/tests/test_progit_flask_ui_admin.py index 5abdedb..115f997 100644 --- a/tests/test_progit_flask_ui_admin.py +++ b/tests/test_progit_flask_ui_admin.py @@ -99,6 +99,32 @@ class ProgitFlaskAdmintests(tests.Modeltests): self.assertTrue( 'Re-generate ssh authorized_key file' in output.data) + @patch('progit.generate_authorized_key_file') + def test_admin_refresh_ssh(self, gakf): + """ Test the admin_refresh_ssh endpoint. """ + gakf.return_value = True + + output = self.app.get('/admin/ssh') + self.assertEqual(output.status_code, 302) + + user = tests.FakeUser() + with tests.user_set(progit.APP, user): + output = self.app.get('/admin/ssh', follow_redirects=True) + self.assertEqual(output.status_code, 200) + self.assertTrue( + '
  • Access restricted
  • ' in output.data) + + user = tests.FakeUser( + username='pingou', + groups=progit.APP.config['ADMIN_GROUP']) + with tests.user_set(progit.APP, user): + output = self.app.get('/admin/ssh', follow_redirects=True) + self.assertEqual(output.status_code, 200) + self.assertTrue('

    Admin section

    ' in output.data) + self.assertTrue('Re-generate gitolite ACLs file' in output.data) + self.assertTrue( + 'Re-generate ssh authorized_key file' in output.data) + if __name__ == '__main__': SUITE = unittest.TestLoader().loadTestsFromTestCase(ProgitFlaskAdmintests)