How to use get_access_point_policy method in localstack

Best Python code snippet using localstack_python

test_s3_control_redirects.py

Source:test_s3_control_redirects.py Github

copy

Full Screen

...315def test_accesspoint_arn_redirection(test_case):316 session = _bootstrap_session()317 client, stubber = _bootstrap_test_case_client(session, test_case)318 with _assert_test_case(test_case, client, stubber):319 client.get_access_point_policy(Name=test_case['arn'])320@pytest.mark.parametrize("test_case", BUCKET_ARN_TEST_CASES)321def test_bucket_arn_redirection(test_case):322 session = _bootstrap_session()323 client, stubber = _bootstrap_test_case_client(session, test_case)324 with _assert_test_case(test_case, client, stubber):325 client.get_bucket(Bucket=test_case['arn'])326@contextmanager327def _assert_test_case(test_case, client, stubber):328 stubber.add_response()329 assertions = test_case['assertions']330 exception_raised = None331 try:332 with stubber:333 yield334 except Exception as e:335 if 'exception' not in assertions:336 raise337 exception_raised = e338 if 'exception' in assertions:339 exception_cls = getattr(exceptions, assertions['exception'])340 if exception_raised is None:341 raise RuntimeError(342 'Expected exception "%s" was not raised' % exception_cls343 )344 error_msg = ('Expected exception "%s", got "%s"') % (345 exception_cls,346 type(exception_raised),347 )348 assert isinstance(exception_raised, exception_cls), error_msg349 else:350 assert len(stubber.requests) == 1351 if 'signing_name' in assertions:352 _assert_signing_name(stubber, assertions['signing_name'])353 if 'headers' in assertions:354 _assert_headers(stubber, assertions['headers'])355 if 'netloc' in assertions:356 _assert_netloc(stubber, assertions['netloc'])357class TestS3ControlRedirection(unittest.TestCase):358 def setUp(self):359 self.session = _bootstrap_session()360 self.region = 'us-west-2'361 self._bootstrap_client()362 def _bootstrap_client(self, **kwargs):363 client, stubber = _bootstrap_client(364 self.session, self.region, **kwargs365 )366 self.client = client367 self.stubber = stubber368 def test_outpost_id_redirection_dualstack(self):369 config = Config(s3={'use_dualstack_endpoint': True})370 self._bootstrap_client(config=config)371 with self.assertRaises(UnsupportedS3ControlConfigurationError):372 self.client.create_bucket(Bucket='foo', OutpostId='op-123')373 def test_outpost_id_redirection_create_bucket(self):374 self.stubber.add_response()375 with self.stubber:376 self.client.create_bucket(Bucket='foo', OutpostId='op-123')377 _assert_netloc(self.stubber, 's3-outposts.us-west-2.amazonaws.com')378 _assert_header(self.stubber, 'x-amz-outpost-id', 'op-123')379 def test_outpost_id_redirection_list_regional_buckets(self):380 self.stubber.add_response()381 with self.stubber:382 self.client.list_regional_buckets(383 OutpostId='op-123',384 AccountId='1234',385 )386 _assert_netloc(self.stubber, 's3-outposts.us-west-2.amazonaws.com')387 _assert_header(self.stubber, 'x-amz-outpost-id', 'op-123')388 def test_outpost_redirection_custom_endpoint(self):389 self._bootstrap_client(endpoint_url='https://outpost.foo.com/')390 self.stubber.add_response()391 with self.stubber:392 self.client.create_bucket(Bucket='foo', OutpostId='op-123')393 _assert_netloc(self.stubber, 'outpost.foo.com')394 _assert_header(self.stubber, 'x-amz-outpost-id', 'op-123')395 def test_normal_ap_request_has_correct_endpoint(self):396 self.stubber.add_response()397 with self.stubber:398 self.client.get_access_point_policy(Name='MyAp', AccountId='1234')399 _assert_netloc(self.stubber, '1234.s3-control.us-west-2.amazonaws.com')400 def test_normal_ap_request_custom_endpoint(self):401 self._bootstrap_client(endpoint_url='https://example.com/')402 self.stubber.add_response()403 with self.stubber:404 self.client.get_access_point_policy(Name='MyAp', AccountId='1234')405 _assert_netloc(self.stubber, '1234.example.com')406 def test_normal_bucket_request_has_correct_endpoint(self):407 self.stubber.add_response()408 with self.stubber:409 self.client.create_bucket(Bucket='foo')410 _assert_netloc(self.stubber, 's3-control.us-west-2.amazonaws.com')411 def test_arn_account_id_mismatch(self):412 arn = (413 'arn:aws:s3-outposts:us-west-2:123456789012:outpost:'414 'op-01234567890123456:accesspoint:myaccesspoint'415 )416 with self.assertRaises(UnsupportedS3ControlArnError):417 self.client.get_access_point_policy(Name=arn, AccountId='1234')418 def test_create_access_point_does_not_expand_name(self):419 arn = (420 'arn:aws:s3-outposts:us-west-2:123456789012:outpost:'421 'op-01234567890123456:accesspoint:myaccesspoint'422 )423 # AccountId will not be backfilled by the arn expansion and thus424 # fail parameter validation425 with self.assertRaises(ParamValidationError):426 self.client.create_access_point(Name=arn, Bucket='foo')427 def test_arn_invalid_host_label(self):428 config = Config(s3={'use_arn_region': True})429 self._bootstrap_client(config=config)430 arn = (431 'arn:aws:s3-outposts:us-we$t-2:123456789012:outpost:'432 'op-01234567890123456:accesspoint:myaccesspoint'433 )434 with self.assertRaises(InvalidHostLabelError):435 self.client.get_access_point_policy(Name=arn)436 def test_unknown_arn_format(self):437 arn = 'arn:aws:foo:us-west-2:123456789012:bar:myresource'438 with self.assertRaises(UnsupportedS3ControlArnError):...

Full Screen

Full Screen

get_access_point_policy.py

Source:get_access_point_policy.py Github

copy

Full Screen

...32 if False:33 yield self34 return GetAccessPointPolicyResult(35 policy_document=self.policy_document)36def get_access_point_policy(object_lambda_access_point: Optional[str] = None,37 opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetAccessPointPolicyResult:38 """39 AWS::S3ObjectLambda::AccessPointPolicy resource is an Amazon S3ObjectLambda policy type that you can use to control permissions for your S3ObjectLambda40 :param str object_lambda_access_point: The name of the Amazon S3 ObjectLambdaAccessPoint to which the policy applies.41 """42 __args__ = dict()43 __args__['objectLambdaAccessPoint'] = object_lambda_access_point44 opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)45 __ret__ = pulumi.runtime.invoke('aws-native:s3objectlambda:getAccessPointPolicy', __args__, opts=opts, typ=GetAccessPointPolicyResult).value46 return AwaitableGetAccessPointPolicyResult(47 policy_document=__ret__.policy_document)48@_utilities.lift_output_func(get_access_point_policy)49def get_access_point_policy_output(object_lambda_access_point: Optional[pulumi.Input[str]] = None,50 opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetAccessPointPolicyResult]:...

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 localstack 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