Best Python code snippet using localstack_python
authorization_test.py
Source:authorization_test.py
1from lwr.tools.authorization import get_authorizer2from .test_utils import get_test_toolbox, TestCase3def test_allow_any_authorization():4 authorizer = get_authorizer(None)5 authorization = authorizer.get_authorization('tool1')6 authorization.authorize_setup()7 authorization.authorize_tool_file('cow', '#!/bin/bash\necho "Hello World!"')8class ToolBasedAuthorizationTestCase(TestCase):9 def setUp(self):10 self.toolbox = get_test_toolbox()11 self.authorizer = get_authorizer(self.toolbox)12 def test_valid_setup_passes(self):13 self.authorizer.get_authorization('tool1').authorize_setup()14 def test_invalid_setup_fails(self):15 with self.unauthorized_expectation():16 self.authorizer.get_authorization('tool2').authorize_setup()17 def test_valid_tool_file_passes(self):18 authorization = self.authorizer.get_authorization('tool1')19 authorization.authorize_tool_file('tool1_wrapper.py', 'print \'Hello World!\'\n')20 def test_invalid_tool_file_fails(self):21 authorization = self.authorizer.get_authorization('tool1')22 with self.unauthorized_expectation():23 authorization.authorize_tool_file('tool1_wrapper.py', '#!/bin/sh\nrm -rf /valuable/data')24 def unauthorized_expectation(self):25 return self.assertRaises(Exception)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!