We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Route to check connection
At this moment in GUI possible check connection only for already exists integration. Route need for checking connection before integration created.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mindsdb/api/http/namespaces/config.py`
Content:
```
1 import copy
2 import traceback
3 
4 from flask import request
5 from flask_restx import Resource, abort
6 from flask import current_app as ca
7 
8 from mindsdb.api.http.namespaces.configs.config import ns_conf
9 from mindsdb.interfaces.database.database import DatabaseWrapper
10 from mindsdb.utilities.functions import get_all_models_meta_data
11 
12 
13 def get_integration(name):
14     integrations = ca.config_obj.get('integrations', {})
15     return integrations.get(name)
16 
17 
18 @ns_conf.route('/integrations')
19 @ns_conf.param('name', 'List all database integration')
20 class ListIntegration(Resource):
21     @ns_conf.doc('get_integrations')
22     def get(self):
23         return {'integrations': [k for k in ca.config_obj.get('integrations', {})]}
24 
25 
26 @ns_conf.route('/all_integrations')
27 @ns_conf.param('name', 'List all database integration')
28 class AllIntegration(Resource):
29     @ns_conf.doc('get_all_integrations')
30     def get(self):
31         integrations = copy.deepcopy(
32             ca.config_obj.get('integrations', {})
33         )
34         for integration in integrations.values():
35             if 'password' in integration:
36                 integration['password'] = None
37         return integrations
38 
39 
40 @ns_conf.route('/integrations/<name>')
41 @ns_conf.param('name', 'Database integration')
42 class Integration(Resource):
43     @ns_conf.doc('get_integration')
44     def get(self, name):
45         integration = get_integration(name)
46         if integration is None:
47             abort(404, f'Can\'t find database integration: {name}')
48         integration = copy.deepcopy(integration)
49         if 'password' in integration:
50             integration['password'] = None
51         return integration
52 
53     @ns_conf.doc('put_integration')
54     def put(self, name):
55         params = request.json.get('params')
56         if not isinstance(params, dict):
57             abort(400, "type of 'params' must be dict")
58         integration = get_integration(name)
59         if integration is not None:
60             abort(400, f"Integration with name '{name}' already exists")
61         try:
62             if 'enabled' in params:
63                 params['publish'] = params['enabled']
64                 del params['enabled']
65             ca.config_obj.add_db_integration(name, params)
66 
67             mdb = ca.mindsdb_native
68             cst = ca.custom_models
69             model_data_arr = get_all_models_meta_data(mdb, cst)
70             dbw = DatabaseWrapper(ca.config_obj)
71             dbw.register_predictors(model_data_arr)
72         except Exception as e:
73             print(traceback.format_exc())
74             abort(500, f'Error during config update: {str(e)}')
75         return '', 200
76 
77     @ns_conf.doc('delete_integration')
78     def delete(self, name):
79         integration = get_integration(name)
80         if integration is None:
81             abort(400, f"Nothing to delete. '{name}' not exists.")
82         try:
83             ca.config_obj.remove_db_integration(name)
84         except Exception as e:
85             print(traceback.format_exc())
86             abort(500, f'Error during integration delete: {str(e)}')
87         return '', 200
88 
89     @ns_conf.doc('modify_integration')
90     def post(self, name):
91         params = request.json.get('params')
92         if not isinstance(params, dict):
93             abort(400, "type of 'params' must be dict")
94         integration = get_integration(name)
95         if integration is None:
96             abort(400, f"Nothin to modify. '{name}' not exists.")
97         try:
98             if 'enabled' in params:
99                 params['publish'] = params['enabled']
100                 del params['enabled']
101             ca.config_obj.modify_db_integration(name, params)
102             DatabaseWrapper(ca.config_obj)
103         except Exception as e:
104             print(traceback.format_exc())
105             abort(500, f'Error during integration modifycation: {str(e)}')
106         return '', 200
107 
108 
109 @ns_conf.route('/integrations/<name>/check')
110 @ns_conf.param('name', 'Database integration checks')
111 class Check(Resource):
112     @ns_conf.doc('check')
113     def get(self, name):
114         if get_integration(name) is None:
115             abort(404, f'Can\'t find database integration: {name}')
116         dbw = DatabaseWrapper(ca.config_obj)
117         connections = dbw.check_connections()
118         return connections.get(name, False), 200
119
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mindsdb/api/http/namespaces/config.py b/mindsdb/api/http/namespaces/config.py
--- a/mindsdb/api/http/namespaces/config.py
+++ b/mindsdb/api/http/namespaces/config.py
@@ -55,6 +55,11 @@
         params = request.json.get('params')
         if not isinstance(params, dict):
             abort(400, "type of 'params' must be dict")
+
+        is_test = params.get('test', False)
+        if is_test:
+            del params['test']
+
         integration = get_integration(name)
         if integration is not None:
             abort(400, f"Integration with name '{name}' already exists")
@@ -72,6 +77,12 @@
         except Exception as e:
             print(traceback.format_exc())
             abort(500, f'Error during config update: {str(e)}')
+
+        if is_test:
+            cons = dbw.check_connections()
+            ca.config_obj.remove_db_integration(name)
+            return {'success': cons[name]}, 200
+
         return '', 200
 
     @ns_conf.doc('delete_integration')

{"golden_diff": "diff --git a/mindsdb/api/http/namespaces/config.py b/mindsdb/api/http/namespaces/config.py\n--- a/mindsdb/api/http/namespaces/config.py\n+++ b/mindsdb/api/http/namespaces/config.py\n@@ -55,6 +55,11 @@\n         params = request.json.get('params')\n         if not isinstance(params, dict):\n             abort(400, \"type of 'params' must be dict\")\n+\n+        is_test = params.get('test', False)\n+        if is_test:\n+            del params['test']\n+\n         integration = get_integration(name)\n         if integration is not None:\n             abort(400, f\"Integration with name '{name}' already exists\")\n@@ -72,6 +77,12 @@\n         except Exception as e:\n             print(traceback.format_exc())\n             abort(500, f'Error during config update: {str(e)}')\n+\n+        if is_test:\n+            cons = dbw.check_connections()\n+            ca.config_obj.remove_db_integration(name)\n+            return {'success': cons[name]}, 200\n+\n         return '', 200\n \n     @ns_conf.doc('delete_integration')\n", "issue": "Route to check connection\nAt this moment in GUI possible check connection only for already exists integration. Route need for checking connection before integration created.\n", "before_files": [{"content": "import copy\nimport traceback\n\nfrom flask import request\nfrom flask_restx import Resource, abort\nfrom flask import current_app as ca\n\nfrom mindsdb.api.http.namespaces.configs.config import ns_conf\nfrom mindsdb.interfaces.database.database import DatabaseWrapper\nfrom mindsdb.utilities.functions import get_all_models_meta_data\n\n\ndef get_integration(name):\n    integrations = ca.config_obj.get('integrations', {})\n    return integrations.get(name)\n\n\n@ns_conf.route('/integrations')\n@ns_conf.param('name', 'List all database integration')\nclass ListIntegration(Resource):\n    @ns_conf.doc('get_integrations')\n    def get(self):\n        return {'integrations': [k for k in ca.config_obj.get('integrations', {})]}\n\n\n@ns_conf.route('/all_integrations')\n@ns_conf.param('name', 'List all database integration')\nclass AllIntegration(Resource):\n    @ns_conf.doc('get_all_integrations')\n    def get(self):\n        integrations = copy.deepcopy(\n            ca.config_obj.get('integrations', {})\n        )\n        for integration in integrations.values():\n            if 'password' in integration:\n                integration['password'] = None\n        return integrations\n\n\n@ns_conf.route('/integrations/<name>')\n@ns_conf.param('name', 'Database integration')\nclass Integration(Resource):\n    @ns_conf.doc('get_integration')\n    def get(self, name):\n        integration = get_integration(name)\n        if integration is None:\n            abort(404, f'Can\\'t find database integration: {name}')\n        integration = copy.deepcopy(integration)\n        if 'password' in integration:\n            integration['password'] = None\n        return integration\n\n    @ns_conf.doc('put_integration')\n    def put(self, name):\n        params = request.json.get('params')\n        if not isinstance(params, dict):\n            abort(400, \"type of 'params' must be dict\")\n        integration = get_integration(name)\n        if integration is not None:\n            abort(400, f\"Integration with name '{name}' already exists\")\n        try:\n            if 'enabled' in params:\n                params['publish'] = params['enabled']\n                del params['enabled']\n            ca.config_obj.add_db_integration(name, params)\n\n            mdb = ca.mindsdb_native\n            cst = ca.custom_models\n            model_data_arr = get_all_models_meta_data(mdb, cst)\n            dbw = DatabaseWrapper(ca.config_obj)\n            dbw.register_predictors(model_data_arr)\n        except Exception as e:\n            print(traceback.format_exc())\n            abort(500, f'Error during config update: {str(e)}')\n        return '', 200\n\n    @ns_conf.doc('delete_integration')\n    def delete(self, name):\n        integration = get_integration(name)\n        if integration is None:\n            abort(400, f\"Nothing to delete. '{name}' not exists.\")\n        try:\n            ca.config_obj.remove_db_integration(name)\n        except Exception as e:\n            print(traceback.format_exc())\n            abort(500, f'Error during integration delete: {str(e)}')\n        return '', 200\n\n    @ns_conf.doc('modify_integration')\n    def post(self, name):\n        params = request.json.get('params')\n        if not isinstance(params, dict):\n            abort(400, \"type of 'params' must be dict\")\n        integration = get_integration(name)\n        if integration is None:\n            abort(400, f\"Nothin to modify. '{name}' not exists.\")\n        try:\n            if 'enabled' in params:\n                params['publish'] = params['enabled']\n                del params['enabled']\n            ca.config_obj.modify_db_integration(name, params)\n            DatabaseWrapper(ca.config_obj)\n        except Exception as e:\n            print(traceback.format_exc())\n            abort(500, f'Error during integration modifycation: {str(e)}')\n        return '', 200\n\n\n@ns_conf.route('/integrations/<name>/check')\n@ns_conf.param('name', 'Database integration checks')\nclass Check(Resource):\n    @ns_conf.doc('check')\n    def get(self, name):\n        if get_integration(name) is None:\n            abort(404, f'Can\\'t find database integration: {name}')\n        dbw = DatabaseWrapper(ca.config_obj)\n        connections = dbw.check_connections()\n        return connections.get(name, False), 200\n", "path": "mindsdb/api/http/namespaces/config.py"}], "after_files": [{"content": "import copy\nimport traceback\n\nfrom flask import request\nfrom flask_restx import Resource, abort\nfrom flask import current_app as ca\n\nfrom mindsdb.api.http.namespaces.configs.config import ns_conf\nfrom mindsdb.interfaces.database.database import DatabaseWrapper\nfrom mindsdb.utilities.functions import get_all_models_meta_data\n\n\ndef get_integration(name):\n    integrations = ca.config_obj.get('integrations', {})\n    return integrations.get(name)\n\n\n@ns_conf.route('/integrations')\n@ns_conf.param('name', 'List all database integration')\nclass ListIntegration(Resource):\n    @ns_conf.doc('get_integrations')\n    def get(self):\n        return {'integrations': [k for k in ca.config_obj.get('integrations', {})]}\n\n\n@ns_conf.route('/all_integrations')\n@ns_conf.param('name', 'List all database integration')\nclass AllIntegration(Resource):\n    @ns_conf.doc('get_all_integrations')\n    def get(self):\n        integrations = copy.deepcopy(\n            ca.config_obj.get('integrations', {})\n        )\n        for integration in integrations.values():\n            if 'password' in integration:\n                integration['password'] = None\n        return integrations\n\n\n@ns_conf.route('/integrations/<name>')\n@ns_conf.param('name', 'Database integration')\nclass Integration(Resource):\n    @ns_conf.doc('get_integration')\n    def get(self, name):\n        integration = get_integration(name)\n        if integration is None:\n            abort(404, f'Can\\'t find database integration: {name}')\n        integration = copy.deepcopy(integration)\n        if 'password' in integration:\n            integration['password'] = None\n        return integration\n\n    @ns_conf.doc('put_integration')\n    def put(self, name):\n        params = request.json.get('params')\n        if not isinstance(params, dict):\n            abort(400, \"type of 'params' must be dict\")\n\n        is_test = params.get('test', False)\n        if is_test:\n            del params['test']\n\n        integration = get_integration(name)\n        if integration is not None:\n            abort(400, f\"Integration with name '{name}' already exists\")\n        try:\n            if 'enabled' in params:\n                params['publish'] = params['enabled']\n                del params['enabled']\n            ca.config_obj.add_db_integration(name, params)\n\n            mdb = ca.mindsdb_native\n            cst = ca.custom_models\n            model_data_arr = get_all_models_meta_data(mdb, cst)\n            dbw = DatabaseWrapper(ca.config_obj)\n            dbw.register_predictors(model_data_arr)\n        except Exception as e:\n            print(traceback.format_exc())\n            abort(500, f'Error during config update: {str(e)}')\n\n        if is_test:\n            cons = dbw.check_connections()\n            ca.config_obj.remove_db_integration(name)\n            return {'success': cons[name]}, 200\n\n        return '', 200\n\n    @ns_conf.doc('delete_integration')\n    def delete(self, name):\n        integration = get_integration(name)\n        if integration is None:\n            abort(400, f\"Nothing to delete. '{name}' not exists.\")\n        try:\n            ca.config_obj.remove_db_integration(name)\n        except Exception as e:\n            print(traceback.format_exc())\n            abort(500, f'Error during integration delete: {str(e)}')\n        return '', 200\n\n    @ns_conf.doc('modify_integration')\n    def post(self, name):\n        params = request.json.get('params')\n        if not isinstance(params, dict):\n            abort(400, \"type of 'params' must be dict\")\n        integration = get_integration(name)\n        if integration is None:\n            abort(400, f\"Nothin to modify. '{name}' not exists.\")\n        try:\n            if 'enabled' in params:\n                params['publish'] = params['enabled']\n                del params['enabled']\n            ca.config_obj.modify_db_integration(name, params)\n            DatabaseWrapper(ca.config_obj)\n        except Exception as e:\n            print(traceback.format_exc())\n            abort(500, f'Error during integration modifycation: {str(e)}')\n        return '', 200\n\n\n@ns_conf.route('/integrations/<name>/check')\n@ns_conf.param('name', 'Database integration checks')\nclass Check(Resource):\n    @ns_conf.doc('check')\n    def get(self, name):\n        if get_integration(name) is None:\n            abort(404, f'Can\\'t find database integration: {name}')\n        dbw = DatabaseWrapper(ca.config_obj)\n        connections = dbw.check_connections()\n        return connections.get(name, False), 200\n", "path": "mindsdb/api/http/namespaces/config.py"}]}