How to use get_parameters_for_import method in localstack

Best Python code snippet using localstack_python

client.py

Source:client.py Github

copy

Full Screen

...58 def get_key_rotation_status(self, KeyId: str) -> Dict:59 pass60 def get_paginator(self, operation_name: str = None) -> Paginator:61 pass62 def get_parameters_for_import(self, KeyId: str, WrappingAlgorithm: str, WrappingKeySpec: str) -> Dict:63 pass64 def get_waiter(self, waiter_name: str = None) -> Waiter:65 pass66 def import_key_material(self, KeyId: str, ImportToken: bytes, EncryptedKeyMaterial: bytes, ValidTo: datetime = None, ExpirationModel: str = None) -> Dict:67 pass68 def list_aliases(self, KeyId: str = None, Limit: int = None, Marker: str = None) -> Dict:69 pass70 def list_grants(self, KeyId: str, Limit: int = None, Marker: str = None) -> Dict:71 pass72 def list_key_policies(self, KeyId: str, Limit: int = None, Marker: str = None) -> Dict:73 pass74 def list_keys(self, Limit: int = None, Marker: str = None) -> Dict:75 pass76 def list_resource_tags(self, KeyId: str, Limit: int = None, Marker: str = None) -> Dict:...

Full Screen

Full Screen

external_key.py

Source:external_key.py Github

copy

Full Screen

...11class KMSExternalKey:12 key_id: str13 key_material: bytes14 algorithm: str = "RSAES_OAEP_SHA_256"15 def get_parameters_for_import(self):16 try:17 response = self.kms_client.get_parameters_for_import(18 KeyId=self.key_id,19 WrappingAlgorithm=self.algorithm,20 WrappingKeySpec='RSA_2048',21 )22 token = response.get("ImportToken")23 public_key = response.get("PublicKey")24 return public_key, token25 except ClientError as err:26 print(f"Client error: {err}")27 return None, None28@kms_client29class KMSExternalKeyImporter:30 def __init__(self):31 self.encryptor = PublicKeyEncryptor()32 def import_external_key_to_kms(self, kms_external_key):33 if not isinstance(kms_external_key, KMSExternalKey):34 raise TypeError(f"Must be an instance of KMSExternalKey")35 wrapping_key, token = kms_external_key.get_parameters_for_import()36 encrypted_key_material = self.encryptor.encrypt_key_material(37 key_material=kms_external_key.key_material,38 wrapping_key=wrapping_key,39 )40 return self.kms_client.import_key_material(41 KeyId=kms_external_key.key_id,42 ImportToken=token,43 EncryptedKeyMaterial=encrypted_key_material,44 ExpirationModel='KEY_MATERIAL_DOES_NOT_EXPIRE',...

Full Screen

Full Screen

test_external_key.py

Source:test_external_key.py Github

copy

Full Screen

...17 "kms",18 region_name="us-east-1"19 )20@mock_kms21def test_get_parameters_for_import(key_material):22 with mock.patch("import_key_material.external_key.KMSExternalKey") \23 as external_key:24 external_key.get_parameters_for_import()25 external_key.get_parameters_for_import.assert_called()26@mock_kms27def test_adding_attributes_to_external_key(key_material):28 with pytest.raises(FrozenInstanceError):29 external_key = KMSExternalKey(30 key_id="123456789",31 key_material=key_material32 )33 external_key.test_attribute = "Test"34@mock_kms35def test_import_key_material_to_kms_with_wrong_argument():36 wrong_agrument = "Test_string"37 kms_key_importer = KMSExternalKeyImporter()38 with pytest.raises(TypeError):...

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