bblommers commented on a change in pull request #15051:
URL: https://github.com/apache/airflow/pull/15051#discussion_r602738287



##########
File path: tests/providers/amazon/aws/hooks/test_secrets_manager.py
##########
@@ -43,12 +43,17 @@ def test_get_secret_string(self):
         secret_value = '{"user": "test"}'
         hook = SecretsManagerHook(aws_conn_id='aws_default')
 
-        param = {
+        create_param = {
+            'Name': secret_name,
+        }
+
+        put_param = {
             'SecretId': secret_name,
             'SecretString': secret_value,
         }
 
-        hook.get_conn().put_secret_value(**param)
+        hook.get_conn().create_secret(**create_param)

Review comment:
       Background info on why this change is necessary: AWS will throw an error 
if you call `put_secret_value` on a secret that hasn't been explicitly created 
first. Moto now follows that behaviour, as of 2.x.
   
   If you want to simplify these tests: there's no need to both create and 
update the secret. It works by just creating the secret:
   ```
   secret_name = "db_cluster-YYYYYYY"  # no need for this to be an ARN (anymore)
   param = {
               'Name': secret_name,
               'SecretString': secret_value_binary,
           }
   
           hook.get_conn().create_secret(**param)
   ```
   The three tests all pass on moto>=2 with this pattern.
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to