Best Python code snippet using localstack_python
fixtures.py
Source: fixtures.py
...624# kms_create_key fixture is used here not just to be able to create aliases without a key specified,625# but also to make sure that kms_create_key gets executed before and teared down after kms_create_alias -626# to make sure that we clean up aliases before keys get cleaned up.627@pytest.fixture()628def kms_create_alias(kms_client, kms_create_key):629 aliases = []630 def _create_alias(**kwargs):631 if "AliasName" not in kwargs:632 kwargs["AliasName"] = f"alias/{short_uid()}"633 if "TargetKeyId" not in kwargs:634 kwargs["TargetKeyId"] = kms_create_key()["KeyId"]635 kms_client.create_alias(**kwargs)636 aliases.append(kwargs["AliasName"])637 return kwargs["AliasName"]638 yield _create_alias639 for alias in aliases:640 try:641 kms_client.delete_alias(AliasName=alias)642 except Exception as e:...
test_kms.py
Source: test_kms.py
...189 return alias_list_entry["AliasArn"]190 key_metadata = kms_create_key()191 key_arn = key_metadata["Arn"]192 key_id = key_metadata["KeyId"]193 alias_name = kms_create_alias(TargetKeyId=key_id)194 alias_arn = get_alias_arn_by_alias_name(kms_client, alias_name)195 assert alias_arn196 kms_client.encrypt(KeyId=key_arn, Plaintext="encrypt-me")197 kms_client.encrypt(KeyId=key_id, Plaintext="encrypt-me")198 kms_client.encrypt(KeyId=alias_arn, Plaintext="encrypt-me")...
kms.py
Source: kms.py
...37 create_key_params['Policy'] = policy38 logger.debug({'create_key_params': create_key_params})39 return client.create_key(**create_key_params).get('KeyMetadata')40@boto_client('kms')41def kms_create_alias(alias_name, key_id, region=None, client=None):42 alias_name = __alias_name(alias_name)43 create_alias_params = {44 'AliasName': alias_name,45 'TargetKeyId': key_id46 }47 logger.debug({'create_alias_params': create_alias_params})48 try:49 client.create_alias(**create_alias_params)50 except Exception as e:51 logger.error(str(e))52 return False53 return True54def kms_ensure_key(alias_name, description=None, policy=None, bypass_policy_lockout_safety_check=False,55 key_usage='ENCRYPT_DECRYPT', origin='AWS_KMS', tags=[], region=None):56 alias_name = __alias_name(alias_name)57 key_alias = get_alias_attr(alias_name, region=region)58 if not key_alias:59 logger.debug('[kms_ensure_key] key does not exist... creating it...')60 if description is None:61 description = alias_name62 key = kms_create_key(63 description=description,64 policy=policy,65 bypass_policy_lockout_safety_check=bypass_policy_lockout_safety_check,66 key_usage=key_usage,67 origin=origin,68 tags=tags,69 region=region70 )71 if kms_create_alias(alias_name, key['KeyId'], region=region):72 # need to get the new alias arn73 key_alias = get_alias_attr(alias_name, region=region)...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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!!