summaryrefslogtreecommitdiffstats
path: root/qa/tasks/mgr/dashboard/test_feedback.py
blob: 0ec5ac31880606f13b7d503687d9dce02dde645d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import time

from .helper import DashboardTestCase


class FeedbackTest(DashboardTestCase):

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls._ceph_cmd(['mgr', 'module', 'enable', 'feedback'])
        time.sleep(10)

    def test_create_api_key(self):
        self._post('/api/feedback/api_key', {'api_key': 'testapikey'}, version='0.1')
        self.assertStatus(201)

    def test_get_api_key(self):
        response = self._get('/api/feedback/api_key', version='0.1')
        self.assertStatus(200)
        self.assertEqual(response, 'testapikey')

    def test_remove_api_key(self):
        self._delete('/api/feedback/api_key', version='0.1')
        self.assertStatus(204)

    def test_issue_tracker_create_with_invalid_key(self):
        self._post('/api/feedback', {'api_key': 'invalidapikey', 'description': 'test',
                                     'project': 'dashboard', 'subject': 'sub', 'tracker': 'bug'},
                   version='0.1')
        self.assertStatus(400)

    def test_issue_tracker_create_with_invalid_params(self):
        self._post('/api/feedback', {'api_key': '', 'description': 'test', 'project': 'xyz',
                                     'subject': 'testsub', 'tracker': 'invalid'}, version='0.1')
        self.assertStatus(400)