AAfghahi commented on a change in pull request #14451:
URL: https://github.com/apache/superset/pull/14451#discussion_r628560713



##########
File path: superset/databases/commands/update.py
##########
@@ -75,12 +75,21 @@ def validate(self) -> None:
         if not self._model:
             raise DatabaseNotFoundError()
         database_name: Optional[str] = self._properties.get("database_name")
+        configuration_method: Optional[str] = self._properties.get(
+            "configuration_method"
+        )
         if database_name:
             # Check database_name uniqueness
             if not DatabaseDAO.validate_update_uniqueness(
                 self._model_id, database_name
             ):
                 exceptions.append(DatabaseExistsValidationError())
+        if configuration_method:
+            if ConfigurationMethod(configuration_method) not in {

Review comment:
       ```
   def test_update_database_with_invalid_configuration_method(self):
           """
           Database API: Test update
           """
           example_db = get_example_database()
           test_database = self.insert_database(
               "test-database", example_db.sqlalchemy_uri_decrypted
           )
           self.login(username="admin")
           database_data = {
               "database_name": "test-database-updated",
               "configuration_method": "BAD_FORM",
           }
           uri = f"api/v1/database/{test_database.id}"
           rv = self.client.put(uri, json=database_data)
           self.assertEqual(rv.status_code, 400)
   ```
   
   THis is the test I wrote for it. 




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to