@@ -16,52 +16,68 @@ def test_read_root(anon_client):
16
16
assert get_settings ().jira_base_url in infos ["configuration" ]["jira_base_url" ]
17
17
18
18
19
- def test_whiteboard_tags (anon_client ):
20
- resp = anon_client .get ("/whiteboard_tags" )
19
+ @pytest .mark .parametrize (
20
+ "endpoint" ,
21
+ [
22
+ "/whiteboard_tags" ,
23
+ "/jira_projects/" ,
24
+ "/powered_by_jbi/" ,
25
+ "/bugzilla_webhooks/" ,
26
+ ],
27
+ )
28
+ def test_get_protected_endpoints (
29
+ endpoint , webhook_request_factory , mocked_bugzilla , anon_client
30
+ ):
31
+ resp = anon_client .get (endpoint )
32
+ assert resp .status_code == 403
33
+
34
+
35
+ def test_whiteboard_tags (authenticated_client ):
36
+ resp = authenticated_client .get ("/whiteboard_tags" )
21
37
actions = resp .json ()
22
38
23
39
assert actions ["devtest" ]["description" ] == "DevTest whiteboard tag"
24
40
25
41
26
- def test_jira_projects (anon_client , mocked_jira ):
42
+ def test_jira_projects (authenticated_client , mocked_jira ):
27
43
mocked_jira .permitted_projects .return_value = [{"key" : "Firefox" }, {"key" : "Fenix" }]
28
44
29
- resp = anon_client .get ("/jira_projects/" )
45
+ resp = authenticated_client .get ("/jira_projects/" )
30
46
infos = resp .json ()
31
47
32
48
assert infos == ["Firefox" , "Fenix" ]
33
49
34
50
35
- def test_whiteboard_tags_filtered (anon_client ):
36
- resp = anon_client .get ("/whiteboard_tags/?whiteboard_tag=devtest" )
51
+ def test_whiteboard_tags_filtered (authenticated_client ):
52
+ resp = authenticated_client .get ("/whiteboard_tags/?whiteboard_tag=devtest" )
37
53
infos = resp .json ()
38
54
assert sorted (infos .keys ()) == ["devtest" ]
39
55
40
- resp = anon_client .get ("/whiteboard_tags/?whiteboard_tag=foo" )
56
+ resp = authenticated_client .get ("/whiteboard_tags/?whiteboard_tag=foo" )
41
57
infos = resp .json ()
42
58
assert sorted (infos .keys ()) == ["devtest" ]
43
59
44
60
45
- def test_powered_by_jbi (exclude_middleware , anon_client ):
46
- resp = anon_client .get ("/powered_by_jbi/" )
61
+ def test_powered_by_jbi (exclude_middleware , authenticated_client ):
62
+ resp = authenticated_client .get ("/powered_by_jbi/" )
47
63
html = resp .text
48
64
assert "<title>Powered by JBI</title>" in html
49
65
assert 'href="/static/styles.css"' in html
50
66
assert "DevTest" in html
51
67
52
68
53
- def test_powered_by_jbi_filtered (exclude_middleware , anon_client ):
54
- resp = anon_client .get ("/powered_by_jbi/?enabled=false" )
69
+ def test_powered_by_jbi_filtered (exclude_middleware , authenticated_client ):
70
+ resp = authenticated_client .get ("/powered_by_jbi/?enabled=false" )
55
71
html = resp .text
56
72
assert "DevTest" not in html
57
73
58
74
59
- def test_webhooks_details (anon_client , mocked_bugzilla , webhook_factory ):
75
+ def test_webhooks_details (authenticated_client , mocked_bugzilla , webhook_factory ):
60
76
mocked_bugzilla .list_webhooks .return_value = [
61
77
webhook_factory (),
62
78
webhook_factory (errors = 42 , enabled = False ),
63
79
]
64
- resp = anon_client .get ("/bugzilla_webhooks/" )
80
+ resp = authenticated_client .get ("/bugzilla_webhooks/" )
65
81
66
82
wh1 , wh2 = resp .json ()
67
83
@@ -72,8 +88,8 @@ def test_webhooks_details(anon_client, mocked_bugzilla, webhook_factory):
72
88
assert wh2 ["errors" ] == 42
73
89
74
90
75
- def test_statics_are_served (anon_client ):
76
- resp = anon_client .get ("/static/styles.css" )
91
+ def test_statics_are_served (authenticated_client ):
92
+ resp = authenticated_client .get ("/static/styles.css" )
77
93
assert resp .status_code == 200
78
94
79
95
0 commit comments