Skip to content

Commit 090fa32

Browse files
authored
chore: auth* tests for license policy apply product (SecObserve#2269)
1 parent bf02f18 commit 090fa32

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

backend/unittests/access_control/api/test_authentication.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ def test_authentication(self, mock_user):
351351
)
352352
self._check_authentication(["post"], "/api/license_policies/1/copy/")
353353
self._check_authentication(["post"], "/api/license_policies/1/apply/")
354+
self._check_authentication(["post"], "/api/license_policies/apply_product/")
354355

355356
self._check_authentication(["get", "post"], "/api/license_policy_items/")
356357
self._check_authentication(

backend/unittests/access_control/api/test_authorization_license_policies.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from application.core.models import Product
12
from application.licenses.models import License_Policy
23
from unittests.access_control.api.test_authorization import (
34
APITest,
@@ -258,6 +259,59 @@ def test_authorization_license_policies(self):
258259
)
259260
)
260261

262+
product_1 = Product.objects.get(pk=1)
263+
license_policy_1000 = License_Policy.objects.get(pk=1000)
264+
product_1.license_policy = license_policy_1000
265+
product_1.save()
266+
267+
self._test_api(
268+
APITest(
269+
"db_admin",
270+
"post",
271+
"/api/license_policies/apply_product/?product=1",
272+
None,
273+
204,
274+
None,
275+
no_second_user=False,
276+
)
277+
)
278+
279+
self._test_api(
280+
APITest(
281+
"db_internal_write",
282+
"post",
283+
"/api/license_policies/apply_product/?product=1",
284+
None,
285+
204,
286+
None,
287+
no_second_user=False,
288+
)
289+
)
290+
291+
self._test_api(
292+
APITest(
293+
"db_internal_read",
294+
"post",
295+
"/api/license_policies/apply_product/?product=1",
296+
None,
297+
403,
298+
None,
299+
no_second_user=False,
300+
)
301+
)
302+
303+
self._test_api(
304+
APITest(
305+
"db_external",
306+
"post",
307+
"/api/license_policies/apply_product/?product=1",
308+
None,
309+
403,
310+
None,
311+
no_second_user=False,
312+
)
313+
)
314+
261315
self._test_api(
262316
APITest(
263317
"db_internal_write",

0 commit comments

Comments
 (0)