Best Python code snippet using localstack_python
access.py
Source: access.py
...14GROUPS_TOML = ".groups.toml"15TOKENS_TOML = ".tokens.toml"16GLOBUS_SDK_TUTORIAL = "https://globus-sdk-python.readthedocs.io/en/stable/tutorial.html"17DEVELOPER_PAGE = "https://auth.globus.org/v2/web/developers"18def create_authorizer(tokens_file, key, client):19 token_data = toml.load(tokens_file)20 auth_rt = token_data[key]["refresh_token"]21 auth_at = token_data[key]["access_token"]22 expiration = token_data[key]["expires_at_seconds"]23 authorizer = globus_sdk.RefreshTokenAuthorizer(24 auth_rt, client, access_token=auth_at, expires_at=expiration)25 return authorizer26 27def get_auth_client(client):28 auth_authorizer = create_authorizer(TOKENS_TOML, 'auth', client)29 ac = AuthClient(authorizer=auth_authorizer)30 return ac31def get_groups_client(client):32 groups_authorizer = create_authorizer(TOKENS_TOML, 'groups', client)33 gc = GroupsClient(authorizer=groups_authorizer)34 return gc35def get_transfer_client(client):36 transfer_authorizer = create_authorizer(TOKENS_TOML, 'transfer', client)37 tc = globus_sdk.TransferClient(authorizer=transfer_authorizer)38 return tc39def get_client_id(f=CLIENT_TOML):40 try:41 client_id = toml.load(f)['client_id']42 except:43 print (f"Could not find or read Client ID from {CLIENT_TOML} file.\n")44 print (f"If you haven't done so already, register a Globus app and get a Client ID as described here: {GLOBUS_SDK_TUTORIAL}\n")45 print (f"If your already registered the app, you can look up your Client ID here: {DEVELOPER_PAGE}")46 client_id = input("Please enter your client ID: ").strip()47 with open(CLIENT_TOML, "w") as f:48 toml.dump({"client_id": client_id}, f)49 return client_id50 ...
iot_custom_authorizer_provider.py
...16 custom_authorizer_function_arn = event["ResourceProperties"]["authorizer_function_arn"]17 custom_authorizer_name = event["ResourceProperties"]["authorizer_name"]18 public_key = event["ResourceProperties"]["public_key"]19 token_key_name = event["ResourceProperties"]["token_key_name"]20 create_authorizer(21 custom_authorizer_name, custom_authorizer_function_arn, public_key, token_key_name22 )23 response = {"PhysicalResourceId": physical_id}24 print(f"### on_create_or_update response: {response}")25 return response26def on_delete(event):27 print(f"### on_delete({event})")28 custom_authorizer_name = event["ResourceProperties"]["authorizer_name"]29 delete_authorizer(custom_authorizer_name)30 response = {"PhysicalResourceId": physical_id}31 print(f"### on_delete response: {response}")32 return response33def create_authorizer(name, function_arn, public_key, token_key_name):34 print(f"### create_authorizer({name, function_arn, public_key, token_key_name})")35 client = boto3.client("iot")36 formatted_key = format_public_key(public_key)37 create_authorizer_response = client.create_authorizer(38 authorizerName=name,39 authorizerFunctionArn=function_arn,40 tokenKeyName=token_key_name,41 status="ACTIVE",42 signingDisabled=False,43 tokenSigningPublicKeys={"public_key": formatted_key},44 )45 print(f"### create_authorizer_response: {create_authorizer_response}")46def format_public_key(public_key):47 return f"-----BEGIN PUBLIC KEY-----\n{public_key}\n-----END PUBLIC KEY-----"48def delete_authorizer(name):49 print(f"### delete_authorizer({name})")50 client = boto3.client("iot")51 update_authorizer_response = client.update_authorizer(authorizerName=name, status="INACTIVE")...
authorizer_factory_abc.py
Source: authorizer_factory_abc.py
...4from servey.access_control.authorizer_abc import AuthorizerABC5class AuthorizerFactoryABC(ABC):6 priority: int = 1007 @abstractmethod8 def create_authorizer(self) -> Optional[AuthorizerABC]:9 """Create a new authorizer instance. Return None if this was not possible"""10def create_authorizer():11 """12 Use the highest priority factory that can actually do it to create an authorizer.13 For example, the KmsAuthorizerFactory requires that boto3 is available and that a KMS_KEY_ID specified14 as an environment variable, so will yield nothing if either of these constraints are not met.15 The JwtAuthorizationFactory has lower priority, will make up a key on the fly as required, but requires16 that pyjwt is installed.17 """18 factories = list(get_impls(AuthorizerFactoryABC))19 factories.sort(key=lambda f: f.priority, reverse=True)20 for factory in factories:21 authorizer = factory().create_authorizer()22 if authorizer:23 return authorizer24_default_authorizer = None25def get_default_authorizer():26 global _default_authorizer27 if not _default_authorizer:28 _default_authorizer = create_authorizer()...
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!!