Best Python code snippet using localstack_python
test_secretsmanager.py
Source:test_secretsmanager.py
...27 # secret is not in there - test we cannot retrieve it28 with pytest.raises(client.exceptions.InvalidRequestException):29 client.get_cloudfront_key_pair()30 # restore the value in there, test we can retrieve it31 client.boto_client.restore_secret(SecretId=cloudfront_key_pair_name)32 assert client.get_cloudfront_key_pair() == value33 # test caching: remove the secret from the backend store, check again34 client.boto_client.delete_secret(SecretId=cloudfront_key_pair_name)35 assert client.get_cloudfront_key_pair() == value36def test_retrieve_post_verification_api_creds(client):37 value = {38 'key': 'the-api-key',39 'root': 'https://api-root.root',40 }41 # add the secret, then remove it42 client.boto_client.create_secret(Name=post_verification_api_creds_name, SecretString=json.dumps(value))43 client.boto_client.delete_secret(SecretId=post_verification_api_creds_name)44 # secret is not in there - test we cannot retrieve it45 with pytest.raises(client.exceptions.InvalidRequestException):46 client.get_post_verification_api_creds()47 # restore the value in there, test we can retrieve it48 client.boto_client.restore_secret(SecretId=post_verification_api_creds_name)49 assert client.get_post_verification_api_creds() == value50 # test caching: remove the secret from the backend store, check again51 client.boto_client.delete_secret(SecretId=post_verification_api_creds_name)52 assert client.get_post_verification_api_creds() == value53def test_retrieve_google_client_ids(client):54 value = {55 'ios': 'ios-client-id',56 'web': 'web-client-id',57 }58 # add the secret, then remove it59 client.boto_client.create_secret(Name=google_client_ids_name, SecretString=json.dumps(value))60 client.boto_client.delete_secret(SecretId=google_client_ids_name)61 # secret is not in there - test we cannot retrieve it62 with pytest.raises(client.exceptions.InvalidRequestException):63 client.get_google_client_ids()64 # restore the value in there, test we can retrieve it65 client.boto_client.restore_secret(SecretId=google_client_ids_name)66 assert client.get_google_client_ids() == value67 # test caching: remove the secret from the backend store, check again68 client.boto_client.delete_secret(SecretId=google_client_ids_name)69 assert client.get_google_client_ids() == value70def test_retrieve_apple_appstore_params(client):71 value = {72 'bundleId': 'some.thing.yup',73 'sharedSecret': 'a-hex-string',74 }75 # add the secret, then remove it76 client.boto_client.create_secret(Name=apple_appstore_params_name, SecretString=json.dumps(value))77 client.boto_client.delete_secret(SecretId=apple_appstore_params_name)78 # secret is not in there - test we cannot retrieve it79 with pytest.raises(client.exceptions.InvalidRequestException):80 client.get_apple_appstore_params()81 # restore the value in there, test we can retrieve it82 client.boto_client.restore_secret(SecretId=apple_appstore_params_name)83 assert client.get_apple_appstore_params() == value84 # test caching: remove the secret from the backend store, check again85 client.boto_client.delete_secret(SecretId=apple_appstore_params_name)...
secret_test.py
Source:secret_test.py
...12 s1 = b'y$\x98\x14s$R:\x975\xb9'13 s2 = b'1A\xf4x\x1c\x04%U\xe5Y\xdd'14 assert xor(s1, s2) == b'Hello world'15def test_restore():16 assert 'ð¦ð' == restore_secret('xjPi/Lx125Jr', 'NqxEfEzqShJc')17def test_split_and_restore():18 secret = 'Helloð¤ªð'19 s1, s2 = split_secret(secret)20 assert secret == restore_secret(s2, s1)21def test_encode_decode():22 b = b'Hello world'23 s = bytes2storestring(b)24 assert b == storestring2bytes(s)25def test_storestring2bytes_err():26 s = 'x82Km0R/s0DDIpM='27 with pytest.raises(InvalidChecksum):28 storestring2bytes(s)29def test_storestring2bytes():30 b = b'Hello world'31 s = 'SGVsbG8gd29ybGQA'32 assert b == storestring2bytes(s)33def test_bytes2storestring():34 b = b'Hello world'35 s = 'SGVsbG8gd29ybGQA'36 assert s == bytes2storestring(b)37def test_restore_secret_invalid_unicode(capsys):38 restore_secret('4q1P', '+Fig')39 captured = capsys.readouterr()40 assert captured.err == (41 "Warning: The secret is not valid utf-8.\n"42 "python bytes representation: b'\\x1a\\xf5'\n"43 )44 assert captured.out == "Best effort uft-8 decoding:\n"45def test_storestring2bytes_invalid_b64():46 with pytest.raises(InvalidStoreString):...
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!!