Best Python code snippet using localstack_python
test_secretsmanager.py
Source:test_secretsmanager.py
...1042 if client_request_token:1043 http_body["ClientRequestToken"] = client_request_token1044 return self.secretsmanager_http_json_post("secretsmanager.UpdateSecret", http_body)1045 @staticmethod1046 def secretsmanager_http_update_secret_val_res(1047 res: requests.Response, secret_name: str, client_request_token: Optional[str]1048 ):1049 assert res.status_code == 2001050 res_json: json = res.json()1051 assert res_json["Name"] == secret_name1052 if client_request_token:1053 assert res_json["VersionId"] == client_request_token1054 return res_json1055 def secretsmanager_http_put_secret_value_with_version(1056 self,1057 secret_id: str,1058 secret_string: str,1059 client_request_token: Optional[str],1060 version_stages: List[str],1061 ) -> requests.Response:1062 http_body: json = {1063 "SecretId": secret_id,1064 "SecretString": secret_string,1065 "ClientRequestToken": client_request_token,1066 "VersionStages": version_stages,1067 }1068 return self.secretsmanager_http_json_post("secretsmanager.PutSecretValue", http_body)1069 @staticmethod1070 def secretsmanager_http_put_secret_value_with_version_val_res(1071 res: requests.Response,1072 secret_name: str,1073 client_request_token: Optional[str],1074 version_stages: List[str],1075 ) -> json:1076 req_version_id: str1077 if client_request_token is None:1078 assert res.status_code == 2001079 req_version_id = res.json()["VersionId"]1080 else:1081 req_version_id = client_request_token1082 res_json = TestSecretsManager.secretsmanager_http_put_secret_value_with_val_res(1083 res, secret_name, req_version_id1084 )1085 assert res_json["VersionStages"] == version_stages1086 return res_json1087 def test_http_update_secret_with_missing_client_request_token(self):1088 secret_name = f"s-{short_uid()}"1089 # Create v0.1090 secret_string_v0: str = "secret_string_v0"1091 cr_v0_res_json: json = self.secretsmanager_http_create_secret_string_val_res(1092 self.secretsmanager_http_create_secret_string(secret_name, secret_string_v0),1093 secret_name,1094 )1095 version_id_v0 = cr_v0_res_json["VersionId"]1096 # Update with client request token.1097 secret_string_v1: str = "secret_string_v1"1098 version_id_v1: str = str(uuid.uuid4())1099 self.secretsmanager_http_update_secret_val_res(1100 self.secretsmanager_http_update_secret(secret_name, secret_string_v1, version_id_v1),1101 secret_name,1102 version_id_v1,1103 )1104 # Get.1105 self.secretsmanager_http_get_secret_value_val_res(1106 self.secretsmanager_http_get_secret_value(secret_name),1107 secret_name,1108 secret_string_v1,1109 version_id_v1,1110 )1111 # Update without client request token.1112 secret_string_v2: str = "secret_string_v2"1113 res_update_json = self.secretsmanager_http_update_secret_val_res(1114 self.secretsmanager_http_update_secret(secret_name, secret_string_v2, None),1115 secret_name,1116 None,1117 )1118 version_id_v2 = res_update_json["VersionId"]1119 assert version_id_v2 != version_id_v11120 assert version_id_v2 != version_id_v01121 # Get.1122 self.secretsmanager_http_get_secret_value_val_res(1123 self.secretsmanager_http_get_secret_value(secret_name),1124 secret_name,1125 secret_string_v2,1126 version_id_v2,1127 )...
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!!