How to use add_acl method in autotest

Best Python code snippet using autotest_python

test_sasl.py

Source:test_sasl.py Github

copy

Full Screen

...120 error_class = TopicAuthorizationFailedError121 if tmp_producer.client.api_version < (1, 0):122 error_class = UnknownTopicOrPartitionError123 del tmp_producer124 self.acl_manager.add_acl(125 allow_principal="test", operation="All", topic=self.topic)126 self.acl_manager.add_acl(127 deny_principal="test", operation="DESCRIBE", topic=self.topic)128 producer = await self.producer_factory(request_timeout_ms=10000)129 with self.assertRaises(error_class):130 await producer.send_and_wait(self.topic, value=b"Super sasl msg")131 # This will check for authorization on start()132 with self.assertRaises(error_class):133 await self.consumer_factory()134 @kafka_versions('>=0.10.0')135 @run_until_complete136 async def test_sasl_deny_topic_read(self):137 self.acl_manager.add_acl(138 allow_principal="test", operation="All", topic=self.topic)139 self.acl_manager.add_acl(140 deny_principal="test", operation="READ", topic=self.topic)141 producer = await self.producer_factory()142 await producer.send_and_wait(self.topic, value=b"Super sasl msg")143 consumer = await self.consumer_factory()144 with self.assertRaises(TopicAuthorizationFailedError):145 await consumer.getone()146 @kafka_versions('>=0.10.0')147 @run_until_complete148 async def test_sasl_deny_topic_write(self):149 self.acl_manager.add_acl(150 allow_principal="test", operation="All", topic=self.topic)151 self.acl_manager.add_acl(152 deny_principal="test", operation="WRITE", topic=self.topic)153 producer = await self.producer_factory()154 with self.assertRaises(TopicAuthorizationFailedError):155 await producer.send_and_wait(156 topic=self.topic, value=b"Super sasl msg")157 ##########################################################################158 # Group Resource159 ##########################################################################160 @kafka_versions('>=0.10.0')161 @run_until_complete162 async def test_sasl_deny_group_describe(self):163 self.acl_manager.add_acl(164 allow_principal="test", operation="All", group=self.group_id)165 self.acl_manager.add_acl(166 deny_principal="test", operation="DESCRIBE", group=self.group_id)167 # Consumer will require DESCRIBE to perform FindCoordinator168 with self.assertRaises(GroupAuthorizationFailedError):169 consumer = await self.consumer_factory()170 await consumer.getone()171 @kafka_versions('>=0.10.0')172 @run_until_complete173 async def test_sasl_deny_group_read(self):174 self.acl_manager.add_acl(175 allow_principal="test", operation="All", group=self.group_id)176 self.acl_manager.add_acl(177 deny_principal="test", operation="READ", group=self.group_id)178 # Consumer will require READ to perform JoinGroup179 with self.assertRaises(GroupAuthorizationFailedError):180 consumer = await self.consumer_factory()181 await consumer.getone()182 @kafka_versions('>=0.11.0')183 @run_until_complete184 async def test_sasl_deny_transaction_group_describe(self):185 self.acl_manager.add_acl(186 allow_principal="test", operation="All", group=self.group_id)187 self.acl_manager.add_acl(188 deny_principal="test", operation="DESCRIBE", group=self.group_id)189 # Transactional producers will also have the same problem to commit190 producer = await self.producer_factory(transactional_id="test_id")191 with self.assertRaises(GroupAuthorizationFailedError):192 async with producer.transaction():193 await producer.send_offsets_to_transaction(194 {TopicPartition(self.topic, 0): 0},195 group_id=self.group_id)196 @kafka_versions('>=0.11.0')197 @run_until_complete198 async def test_sasl_deny_transaction_group_read(self):199 self.acl_manager.add_acl(200 allow_principal="test", operation="All", group=self.group_id)201 self.acl_manager.add_acl(202 deny_principal="test", operation="READ", group=self.group_id)203 # Transactional producers will also have the same problem to commit204 producer = await self.producer_factory(transactional_id="test_id")205 await producer.begin_transaction()206 with self.assertRaises(GroupAuthorizationFailedError):207 await producer.send_offsets_to_transaction(208 {TopicPartition(self.topic, 0): 0},209 group_id=self.group_id)210 with self.assertRaises(GroupAuthorizationFailedError):211 await producer.commit_transaction()212 await producer.abort_transaction()213 # We can continue using producer after this error214 async with producer.transaction():215 await producer.send_and_wait(self.topic, b"TTTT")216 ##########################################################################217 # Transactional ID resource218 ##########################################################################219 @kafka_versions('>=0.11.0')220 @run_until_complete221 async def test_sasl_deny_txnid_describe(self):222 self.acl_manager.add_acl(223 allow_principal="test", operation="All",224 transactional_id="test_id")225 self.acl_manager.add_acl(226 deny_principal="test", operation="DESCRIBE",227 transactional_id="test_id")228 # Transactional producers will require DESCRIBE to perform229 # FindCoordinator230 with self.assertRaises(TransactionalIdAuthorizationFailed):231 await self.producer_factory(transactional_id="test_id")232 @kafka_versions('>=0.11.0')233 @run_until_complete234 async def test_sasl_deny_txnid_write(self):235 self.acl_manager.add_acl(236 allow_principal="test", operation="All",237 transactional_id="test_id")238 self.acl_manager.add_acl(239 deny_principal="test", operation="WRITE",240 transactional_id="test_id")241 # Transactional producers will require DESCRIBE to perform242 # FindCoordinator243 with self.assertRaises(TransactionalIdAuthorizationFailed):244 await self.producer_factory(transactional_id="test_id")245 @kafka_versions('>=0.11.0')246 @run_until_complete247 async def test_sasl_deny_txnid_during_transaction(self):248 self.acl_manager.add_acl(249 allow_principal="test", operation="All",250 transactional_id="test_id")251 # Transactional producers will require DESCRIBE to perform252 # FindCoordinator253 producer = await self.producer_factory(transactional_id="test_id")254 await producer.begin_transaction()255 await producer.send_and_wait(self.topic, b"123", partition=0)256 self.acl_manager.add_acl(257 deny_principal="test", operation="WRITE",258 transactional_id="test_id")259 with self.assertRaises(TransactionalIdAuthorizationFailed):...

Full Screen

Full Screen

build_database.py

Source:build_database.py Github

copy

Full Screen

1from api import db2from api import ACL3def add_acl(service, queue, value):4 acl = ACL(service=service, queue=queue, value=value)5 if len(list(ACL.query.filter(ACL.service==service).filter(ACL.queue==queue).all())) == 0:6 db.session.add(acl)7 db.session.commit()8try:9 db.session.remove()10 db.drop_all()11except:12 # fail silently13 pass14db.create_all()15add_acl("reporte_consolidado","q", 0)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful