Files
dpl/scripts/fuc-xb-acceptance/test_bridge.py
T

12 lines
1.1 KiB
Python

import importlib.util,pathlib,unittest
s=importlib.util.spec_from_file_location('bridge',pathlib.Path(__file__).with_name('node-bridge.py'));b=importlib.util.module_from_spec(s);s.loader.exec_module(b)
class Scope(unittest.TestCase):
def test_exact_qa_node(self):
self.assertTrue(b.allowed('GET','/api/v1/server/UniProxy/user?node_id=7&token=test-only&node_type=v2ray',7,'test-only'))
def test_no_other_resources(self):
for path in ['/api/v1/user/info?node_id=7&token=test-only','/api/v1/server/UniProxy/user?node_id=8&token=test-only','/api/v1/server/UniProxy/user?node_id=7&token=wrong','/api/v1/server/UniProxy/user?node_id=7&node_id=8&token=test-only','https://other.invalid/api/v1/server/UniProxy/user?node_id=7&token=test-only','/api/v1/server/UniProxy/user?node_id=7&token=test-only&extra=1']:
with self.subTest(path=path):self.assertFalse(b.allowed('GET',path,7,'test-only'))
def test_no_unneeded_methods(self):
self.assertFalse(b.allowed('DELETE','/api/v1/server/UniProxy/user?node_id=7&token=test-only',7,'test-only'))
if __name__=='__main__':unittest.main()