Skip to content

Commit

Permalink
Adjust few more tests b/c RPC authentication failures now return 200
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Nov 28, 2023
1 parent 88e80f1 commit acde406
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions tcms/rpc/tests/test_environment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from xmlrpc.client import Fault as XmlRPCFault
from xmlrpc.client import ProtocolError

from django.test import override_settings

Expand All @@ -16,7 +15,9 @@ def verify_api_with_permission(self):
self.assertTrue(isinstance(result, list))

def verify_api_without_permission(self):
with self.assertRaisesRegex(ProtocolError, "403 Forbidden"):
with self.assertRaisesRegex(
XmlRPCFault, 'Authentication failed when calling "Environment.filter"'
):
self.rpc_client.Environment.filter(None)


Expand Down Expand Up @@ -60,7 +61,9 @@ def verify_api_with_permission(self):
self.assertEqual(environment.description, description)

def verify_api_without_permission(self):
with self.assertRaisesRegex(ProtocolError, "403 Forbidden"):
with self.assertRaisesRegex(
XmlRPCFault, 'Authentication failed when calling "Environment.create"'
):
self.rpc_client.Environment.create(
{"name": "E8", "description": "Environment without Permissions"}
)
2 changes: 1 addition & 1 deletion tcms/rpc/tests/test_testcase.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# pylint: disable=attribute-defined-outside-init
# pylint: disable=attribute-defined-outside-init,too-many-lines

import unittest
from datetime import timedelta
Expand Down
4 changes: 3 additions & 1 deletion tcms/rpc/tests/test_testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,9 @@ def verify_api_with_permission(self):
self.assertEqual(attachments[0].object_id, str(self.test_run.pk))

def verify_api_without_permission(self):
with self.assertRaisesRegex(ProtocolError, "403 Forbidden"):
with self.assertRaisesRegex(
XmlRPCFault, 'Authentication failed when calling "TestRun.add_attachment"'
):
self.rpc_client.TestRun.add_attachment(
self.test_run.pk, "test.txt", "a2l3aXRjbXM="
)

0 comments on commit acde406

Please sign in to comment.