@@ -3103,6 +3103,59 @@ def test_secrets_provider_get_multiple_basic(config):
31033103 stubber .deactivate ()
31043104
31053105
3106+ def test_secrets_provider_get_multiple_does_not_mutate_caller_filters (config ):
3107+ """
3108+ Test SecretsProvider.get_multiple() leaves the caller's Filters list untouched
3109+ """
3110+ # GIVEN a SecretsProvider instance
3111+ provider = parameters .SecretsProvider (boto_config = config )
3112+
3113+ # GIVEN a shared Filters list, as used in the documentation example
3114+ my_filters = [{"Key" : "primary-region" , "Values" : ["us-east-1" ]}]
3115+
3116+ # Stub the boto3 client with two paginated-free responses, one per call
3117+ stubber = stub .Stubber (provider .client )
3118+ response_a = {
3119+ "SecretValues" : [
3120+ {
3121+ "Name" : "a" ,
3122+ "SecretString" : "1" ,
3123+ },
3124+ ],
3125+ "Errors" : [],
3126+ }
3127+ expected_params_a = {
3128+ "Filters" : [* my_filters , {"Key" : "name" , "Values" : ["a" ]}],
3129+ }
3130+ stubber .add_response ("batch_get_secret_value" , response_a , expected_params_a )
3131+
3132+ response_b = {
3133+ "SecretValues" : [
3134+ {
3135+ "Name" : "b" ,
3136+ "SecretString" : "2" ,
3137+ },
3138+ ],
3139+ "Errors" : [],
3140+ }
3141+ expected_params_b = {
3142+ "Filters" : [* my_filters , {"Key" : "name" , "Values" : ["b" ]}],
3143+ }
3144+ stubber .add_response ("batch_get_secret_value" , response_b , expected_params_b )
3145+ stubber .activate ()
3146+
3147+ try :
3148+ # WHEN calling get_multiple twice with the same Filters list
3149+ assert provider .get_multiple (["a" ], Filters = my_filters ) == {"a" : "1" }
3150+ assert provider .get_multiple (["b" ], Filters = my_filters ) == {"b" : "2" }
3151+ stubber .assert_no_pending_responses ()
3152+
3153+ # THEN the caller's list must not have grown stale name filters
3154+ assert my_filters == [{"Key" : "primary-region" , "Values" : ["us-east-1" ]}]
3155+ finally :
3156+ stubber .deactivate ()
3157+
3158+
31063159def test_secrets_provider_get_multiple_with_binary (config ):
31073160 """
31083161 Test SecretsProvider.get_multiple() with binary secrets
0 commit comments