How to use describe_document_permission method in localstack

Best Python code snippet using localstack_python

test_ssm.py

Source:test_ssm.py Github

copy

Full Screen

...283 },284 session_factory=session_factory,285 )286 p.run()287 permissions = client.describe_document_permission(288 Name='Test-Document-1',289 PermissionType='Share'290 )291 self.assertEqual(len(permissions.get('AccountIds')), 1)292 self.assertEqual(permissions.get('AccountIds'), ['xxxxxxxxxxxx'])293 def test_ssm_document_add_sharing(self):294 session_factory = self.replay_flight_data("test_ssm_document_add_sharing")295 client = session_factory().client("ssm")296 p = self.load_policy(297 {298 "name": "add-sharing-ssm-documents",299 "resource": "ssm-document",300 "actions": [301 {302 "type": "set-sharing",303 "add": ['yyyyyyyyyyyy']304 }305 ],306 },307 session_factory=session_factory,308 )309 p.run()310 permissions = client.describe_document_permission(311 Name='Test-Document-1',312 PermissionType='Share'313 )314 self.assertEqual(len(permissions.get('AccountIds')), 2)315 self.assertEqual(permissions.get('AccountIds'), ['xxxxxxxxxxxx', 'yyyyyyyyyyyy'])316 def test_ssm_document_delete(self):317 session_factory = self.replay_flight_data("test_ssm_document_delete")318 client = session_factory().client("ssm")319 p = self.load_policy(320 {321 "name": "delete-ssm-documents",322 "resource": "ssm-document",323 "filters": [324 {...

Full Screen

Full Screen

test_ssm_doc_permissions.py

Source:test_ssm_doc_permissions.py Github

copy

Full Screen

...7@mock_ssm8def test_describe_document_permissions_unknown_document():9 client = boto3.client("ssm", region_name="us-east-1")10 with pytest.raises(ClientError) as ex:11 client.describe_document_permission(12 Name="UnknownDocument", PermissionType="Share"13 )14 err = ex.value.response["Error"]15 err["Code"].should.equal("InvalidDocument")16 err["Message"].should.equal("The specified document does not exist.")17def get_client():18 template_file = _get_yaml_template()19 json_doc = yaml.safe_load(template_file)20 client = boto3.client("ssm", region_name="us-east-1")21 client.create_document(22 Content=yaml.dump(json_doc),23 Name="TestDocument",24 DocumentType="Command",25 DocumentFormat="YAML",26 VersionName="Base",27 )28 return client29@mock_ssm30def test_describe_document_permissions_initial():31 client = get_client()32 res = client.describe_document_permission(33 Name="TestDocument", PermissionType="Share"34 )35 res.should.have.key("AccountIds").equal([])36 res.should.have.key("AccountSharingInfoList").equal([])37@pytest.mark.parametrize(38 "ids",39 [["111111111111"], ["all"], ["All"], ["111111111111", "222222222222"]],40 ids=["one_value", "all", "All", "multiple_values"],41)42@mock_ssm43def test_modify_document_permission_add_account_id(ids):44 client = get_client()45 client.modify_document_permission(46 Name="TestDocument", PermissionType="Share", AccountIdsToAdd=ids47 )48 res = client.describe_document_permission(49 Name="TestDocument", PermissionType="Share"50 )51 res.should.have.key("AccountIds")52 set(res["AccountIds"]).should.equal(set(ids))53 res.should.have.key("AccountSharingInfoList").length_of(len(ids))54 expected_account_sharing = [55 {"AccountId": _id, "SharedDocumentVersion": "$DEFAULT"} for _id in ids56 ]57 res.should.have.key("AccountSharingInfoList").equal(expected_account_sharing)58@pytest.mark.parametrize(59 "initial,to_remove",60 [61 (["all"], ["all"]),62 (["111111111111"], ["111111111111"]),63 (["111111111111", "222222222222"], ["222222222222"]),64 (65 ["111111111111", "222222222222", "333333333333"],66 ["111111111111", "333333333333"],67 ),68 ],69 ids=["all", "one_value", "multiple_initials", "multiple_to_remove"],70)71@mock_ssm72def test_modify_document_permission_remove_account_id(initial, to_remove):73 client = get_client()74 client.modify_document_permission(75 Name="TestDocument", PermissionType="Share", AccountIdsToAdd=initial76 )77 client.modify_document_permission(78 Name="TestDocument", PermissionType="Share", AccountIdsToRemove=to_remove79 )80 res = client.describe_document_permission(81 Name="TestDocument", PermissionType="Share"82 )83 res.should.have.key("AccountIds")84 expected_new_list = set([x for x in initial if x not in to_remove])85 set(res["AccountIds"]).should.equal(expected_new_list)86 expected_account_sharing = [87 {"AccountId": _id, "SharedDocumentVersion": "$DEFAULT"}88 for _id in expected_new_list89 ]90 res.should.have.key("AccountSharingInfoList").equal(expected_account_sharing)91@mock_ssm92def test_fail_modify_document_permission_wrong_permission_type():93 client = get_client()94 with pytest.raises(ClientError) as ex:...

Full Screen

Full Screen

ssm.py

Source:ssm.py Github

copy

Full Screen

...24 """25 Fetches ssm details.26 """27 resource = {**self.resource}28 resource["shared_permissions"] = self.describe_document_permission(29 self.resource["Name"]30 )31 return resource32 def describe_document_permission(self, document_name, permission_type="Share"):33 """Describe document permission"""34 response = self.conn.describe_document_permission(35 Name=document_name,36 PermissionType=permission_type,37 )38 if "ResponseMetadata" in response:39 del response["ResponseMetadata"]40 return response41def register() -> Any:42 """Register plugin"""...

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