@@ 114-134 (lines=21) @@ | ||
111 | tag_exists = TestPlan.objects.filter(pk=self.plans[0].pk, tag__pk=self.tag0.pk).exists() |
|
112 | self.assertFalse(tag_exists) |
|
113 | ||
114 | def test_remove_tag_without_permissions(self): |
|
115 | unauthorized_user = UserFactory() |
|
116 | unauthorized_user.set_password('api-testing') |
|
117 | unauthorized_user.save() |
|
118 | ||
119 | unauthorized_user.user_permissions.add(*Permission.objects.all()) |
|
120 | remove_perm_from_user(unauthorized_user, 'testplans.delete_testplantag') |
|
121 | ||
122 | rpc_client = xmlrpc.TCMSXmlrpc(unauthorized_user.username, |
|
123 | 'api-testing', |
|
124 | '%s/xml-rpc/' % self.live_server_url).server |
|
125 | ||
126 | with self.assertRaisesRegex(ProtocolError, '403 Forbidden'): |
|
127 | rpc_client.TestPlan.remove_tag(self.plans[0].pk, self.tag0.name) |
|
128 | ||
129 | # tags were not modified |
|
130 | tag_exists = TestPlan.objects.filter(pk=self.plans[0].pk, tag__pk=self.tag0.pk).exists() |
|
131 | self.assertTrue(tag_exists) |
|
132 | ||
133 | tag_exists = TestPlan.objects.filter(pk=self.plans[0].pk, tag__pk=self.tag1.pk).exists() |
|
134 | self.assertFalse(tag_exists) |
|
135 | ||
136 | ||
137 | class TestUpdate(XmlrpcAPIBaseTest): # pylint: disable=too-many-instance-attributes |
|
@@ 72-89 (lines=18) @@ | ||
69 | tag_exists = TestPlan.objects.filter(pk=self.plans[0].pk, tag__pk=self.tag1.pk).exists() |
|
70 | self.assertTrue(tag_exists) |
|
71 | ||
72 | def test_add_tag_without_permissions(self): |
|
73 | unauthorized_user = UserFactory() |
|
74 | unauthorized_user.set_password('api-testing') |
|
75 | unauthorized_user.save() |
|
76 | ||
77 | unauthorized_user.user_permissions.add(*Permission.objects.all()) |
|
78 | remove_perm_from_user(unauthorized_user, 'testplans.add_testplantag') |
|
79 | ||
80 | rpc_client = xmlrpc.TCMSXmlrpc(unauthorized_user.username, |
|
81 | 'api-testing', |
|
82 | '%s/xml-rpc/' % self.live_server_url).server |
|
83 | ||
84 | with self.assertRaisesRegex(ProtocolError, '403 Forbidden'): |
|
85 | rpc_client.TestPlan.add_tag(self.plans[0].pk, self.tag1.name) |
|
86 | ||
87 | # tags were not modified |
|
88 | tag_exists = TestPlan.objects.filter(pk=self.plans[0].pk, tag__pk=self.tag1.pk).exists() |
|
89 | self.assertFalse(tag_exists) |
|
90 | ||
91 | ||
92 | class TestRemoveTag(XmlrpcAPIBaseTest): |
@@ 147-167 (lines=21) @@ | ||
144 | tag_exists = TestRun.objects.filter(pk=self.test_runs[0].pk, tag__pk=self.tag1.pk).exists() |
|
145 | self.assertTrue(tag_exists) |
|
146 | ||
147 | def test_remove_tag_without_permissions(self): |
|
148 | unauthorized_user = UserFactory() |
|
149 | unauthorized_user.set_password('api-testing') |
|
150 | unauthorized_user.save() |
|
151 | ||
152 | unauthorized_user.user_permissions.add(*Permission.objects.all()) |
|
153 | remove_perm_from_user(unauthorized_user, 'testruns.delete_testruntag') |
|
154 | ||
155 | rpc_client = xmlrpc.TCMSXmlrpc(unauthorized_user.username, |
|
156 | 'api-testing', |
|
157 | '%s/xml-rpc/' % self.live_server_url).server |
|
158 | ||
159 | with self.assertRaisesRegex(ProtocolError, '403 Forbidden'): |
|
160 | rpc_client.TestRun.remove_tag(self.test_runs[0].pk, self.tag0.name) |
|
161 | ||
162 | # tags were not modified |
|
163 | tag_exists = TestRun.objects.filter(pk=self.test_runs[0].pk, tag__pk=self.tag0.pk).exists() |
|
164 | self.assertTrue(tag_exists) |
|
165 | ||
166 | tag_exists = TestRun.objects.filter(pk=self.test_runs[0].pk, tag__pk=self.tag1.pk).exists() |
|
167 | self.assertTrue(tag_exists) |
|
168 | ||
169 | ||
170 | class TestProductVersionWhenCreating(XmlrpcAPIBaseTest): |