You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/06/27 16:42:26 UTC

[GitHub] [airflow] phanikumv opened a new pull request, #24682: Add test_connection method to GoogleBaseHook

phanikumv opened a new pull request, #24682:
URL: https://github.com/apache/airflow/pull/24682

   This PR adds test connection functionality to Google Cloud connection type in airflow UI
   
   Test connection Pass
   <img width="1012" alt="Screenshot 2022-06-27 at 10 05 47 PM" src="https://user-images.githubusercontent.com/94376113/175992096-22b093d0-b193-4a58-bc7e-e33ca9065020.png">
   
   
   Test connection Failed
   
   <img width="1656" alt="image" src="https://user-images.githubusercontent.com/94376113/175991719-c6c8fbe7-8afb-4bbd-99c0-9dbf7452718a.png">
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragement file, named `{pr_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] phanikumv commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
phanikumv commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r909689498


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -270,7 +271,12 @@ def _get_credentials(self) -> google.auth.credentials.Credentials:
 
     def _get_access_token(self) -> str:
         """Returns a valid access token from Google API Credentials"""
-        return self._get_credentials().token
+        credentials = self._get_credentials()
+        auth_req = google.auth.transport.requests.Request()
+        # credentials.token is None
+        # Need to refresh credentials to populate the token

Review Comment:
   The method `_get_access_token()` wasn't being used anywhere earlier. A sample dump of the Credentials object just after calling `self._get_credentials()` is :
   
   ``{'token': None, 'expiry': None, '_quota_project_id': None, '_scopes': ('https://www.googleapis.com/auth/cloud-platform',), '_default_scopes': None, '_signer': <google.auth.crypt._cryptography_rsa.RSASigner object at 0x40359f3af0>, '_service_account_email': 'phani-svc-account@xxxxxxxx.iam.gserviceaccount.com', '_subject': None, '_project_id': 'xxxxxx-providers', '_token_uri': 'https://oauth2.googleapis.com/token', '_always_use_jwt_access': False, '_jwt_credentials': None, '_additional_claims': {}}``



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] mik-laj commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
mik-laj commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r908553228


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +580,16 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):
+        """Test the Google cloud connectivity from UI"""
+        status, message = False, ''
+        try:
+            if self.project_id:

Review Comment:
   The implementation of `projec_id` may change (see: https://github.com/apache/airflow/pull/23719 ) and I think it will be safer if we give an explicit access key check. 
   To do it, you should send the request to the following URL:
   ```
   https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=accessToken
   ```
   Source: https://stackoverflow.com/questions/359472/how-can-i-verify-a-google-authentication-api-access-token



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] kaxil merged pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
kaxil merged PR #24682:
URL: https://github.com/apache/airflow/pull/24682


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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] mik-laj commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
mik-laj commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r911473398


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +580,16 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):
+        """Test the Google cloud connectivity from UI"""
+        status, message = False, ''
+        try:
+            if self.project_id:

Review Comment:
   LGTM
   @rbiegacz WDYT?



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] phanikumv commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
phanikumv commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r909689498


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -270,7 +271,12 @@ def _get_credentials(self) -> google.auth.credentials.Credentials:
 
     def _get_access_token(self) -> str:
         """Returns a valid access token from Google API Credentials"""
-        return self._get_credentials().token
+        credentials = self._get_credentials()
+        auth_req = google.auth.transport.requests.Request()
+        # credentials.token is None
+        # Need to refresh credentials to populate the token

Review Comment:
   The method _get_access_token() wasn't being used anywhere earlier. A sample dump of the Credentials object is:
   
   ``{'token': None, 'expiry': None, '_quota_project_id': None, '_scopes': ('https://www.googleapis.com/auth/cloud-platform',), '_default_scopes': None, '_signer': <google.auth.crypt._cryptography_rsa.RSASigner object at 0x40359f3af0>, '_service_account_email': 'phani-svc-account@xxxxxxxx.iam.gserviceaccount.com', '_subject': None, '_project_id': 'xxxxxx-providers', '_token_uri': 'https://oauth2.googleapis.com/token', '_always_use_jwt_access': False, '_jwt_credentials': None, '_additional_claims': {}}``



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] phanikumv commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
phanikumv commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r908516993


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +580,16 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):

Review Comment:
   It is desireable , and  will enhance user experience, as all those hooks will now start allowing testing connection directly from ui



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] mik-laj commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
mik-laj commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r908553228


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +580,16 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):
+        """Test the Google cloud connectivity from UI"""
+        status, message = False, ''
+        try:
+            if self.project_id:

Review Comment:
   The implementation of `projec_id` may change (see: https://github.com/apache/airflow/pull/23719 ) and I think it will be safer if we add an explicit access key check. 
   To do it, you should send the request to the following URL:
   ```
   https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=accessToken
   ```
   Source: https://stackoverflow.com/questions/359472/how-can-i-verify-a-google-authentication-api-access-token



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] kosteev commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
kosteev commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r915600447


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +586,19 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):
+        """Test the Google cloud connectivity from UI"""
+        status, message = False, ''
+        try:
+            token = self._get_access_token()
+            url = f"https://www.googleapis.com/oauth2/v3/tokeninfo?access_token={token}"

Review Comment:
   It doesn't look safe, as we do not have url encoding here.
   If token contains "?", "/" etc. this url will be broken.



##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +586,19 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):
+        """Test the Google cloud connectivity from UI"""
+        status, message = False, ''
+        try:
+            token = self._get_access_token()
+            url = f"https://www.googleapis.com/oauth2/v3/tokeninfo?access_token={token}"
+            response = requests.post(url)
+            if response.status_code == 200:
+                status = True
+                message = 'Connection successfully tested'
+        except Exception as e:

Review Comment:
   AFAIK catching all type of exceptions is bad practice.
   What specific type of exceptions we want to catch here? Probably exception on request post - there has to be a contract what exception will be raised there.



##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +586,19 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):
+        """Test the Google cloud connectivity from UI"""

Review Comment:
   Nit: "Google **C**loud"



##########
tests/providers/google/common/hooks/test_base_google.py:
##########
@@ -341,6 +341,24 @@ def test_get_credentials_and_project_id_with_default_auth(self, mock_get_creds_a
         )
         assert ('CREDENTIALS', 'PROJECT_ID') == result
 
+    @mock.patch('requests.post')
+    @mock.patch(MODULE_NAME + '.get_credentials_and_project_id')
+    def test_connection_success(self, mock_get_creds_and_proj_id, requests_post):
+        requests_post.return_value.status_code = 200
+        credentials = mock.MagicMock()
+        type(credentials).token = mock.PropertyMock(return_value="TOKEN")

Review Comment:
   It should work instead:
   credentials = mock.MagicMock(token="TOKEN")



##########
tests/providers/google/common/hooks/test_base_google.py:
##########
@@ -341,6 +341,24 @@ def test_get_credentials_and_project_id_with_default_auth(self, mock_get_creds_a
         )
         assert ('CREDENTIALS', 'PROJECT_ID') == result
 
+    @mock.patch('requests.post')

Review Comment:
   Good practice is to mock with autospec=True to catch passing incorrect parameters to method.
   Unless there are real objections to use autospec, I would use it, as this actually the only way sometimes (and here specifically) we may spot misalignment in the contract of the function that is mocked and usage of it.



##########
tests/providers/google/common/hooks/test_base_google.py:
##########
@@ -341,6 +341,24 @@ def test_get_credentials_and_project_id_with_default_auth(self, mock_get_creds_a
         )
         assert ('CREDENTIALS', 'PROJECT_ID') == result
 
+    @mock.patch('requests.post')
+    @mock.patch(MODULE_NAME + '.get_credentials_and_project_id')
+    def test_connection_success(self, mock_get_creds_and_proj_id, requests_post):

Review Comment:
   for the consistency sake I would name "requests_post" -> "mock_requests_post"



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] ashb commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
ashb commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r908506613


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +580,16 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):

Review Comment:
   Hmmm, so this hook is used as the base class for a number of other connection types. Does this test method being inherited by those subclasses cause problems, or is that desireable?



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] mik-laj commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
mik-laj commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r908553228


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +580,16 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):
+        """Test the Google cloud connectivity from UI"""
+        status, message = False, ''
+        try:
+            if self.project_id:

Review Comment:
   The implementation of `projec_id` may change (see: https://github.com/apache/airflow/pull/23719 ) We should not rely on this to verify that the connection was working.
   
   
   
   I think it will be safer if we add an explicit access key check. To do it, you should send the request to the following URL:
   ```
   https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=accessToken
   ```
   Source: https://stackoverflow.com/questions/359472/how-can-i-verify-a-google-authentication-api-access-token



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] kaxil commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
kaxil commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r909675257


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -270,7 +271,12 @@ def _get_credentials(self) -> google.auth.credentials.Credentials:
 
     def _get_access_token(self) -> str:
         """Returns a valid access token from Google API Credentials"""
-        return self._get_credentials().token
+        credentials = self._get_credentials()
+        auth_req = google.auth.transport.requests.Request()
+        # credentials.token is None
+        # Need to refresh credentials to populate the token

Review Comment:
   How was it working before the change if it was returning `None`?



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] phanikumv commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
phanikumv commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r908299435


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +580,16 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):
+        """Test the Google cloud connectivity from UI"""
+        status, message = False, ''
+        try:
+            if self.project_id:

Review Comment:
   Based on based on provided key JSON , it will connect to GCP oauth module and derive project_id 
   
   ```
   def _get_credentials_using_keyfile_dict(self):
           self._log_debug('Getting connection using JSON Dict')
           # Depending on how the JSON was formatted, it may contain
           # escaped newlines. Convert those to actual newlines.
           self.keyfile_dict['private_key'] = self.keyfile_dict['private_key'].replace('\\n', '\n')
           credentials = google.oauth2.service_account.Credentials.from_service_account_info(
               self.keyfile_dict, scopes=self.scopes
           )
           project_id = credentials.project_id
           return credentials, project_id
   ```
   
   
   



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] pankajastro commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
pankajastro commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r908292880


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +580,16 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):
+        """Test the Google cloud connectivity from UI"""
+        status, message = False, ''
+        try:
+            if self.project_id:

Review Comment:
   While creating a credential object does it make some call to GCP and confirm or it just deserialises the key JSON file locally and create the credential object if it does locally then this may not be right always for example if wrong project-id in the key file



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] phanikumv commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
phanikumv commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r908299435


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +580,16 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):
+        """Test the Google cloud connectivity from UI"""
+        status, message = False, ''
+        try:
+            if self.project_id:

Review Comment:
   Based on provided key JSON , it will connect to GCP oauth module and derive project_id 
   
   ```
   def _get_credentials_using_keyfile_dict(self):
           self._log_debug('Getting connection using JSON Dict')
           # Depending on how the JSON was formatted, it may contain
           # escaped newlines. Convert those to actual newlines.
           self.keyfile_dict['private_key'] = self.keyfile_dict['private_key'].replace('\\n', '\n')
           credentials = google.oauth2.service_account.Credentials.from_service_account_info(
               self.keyfile_dict, scopes=self.scopes
           )
           project_id = credentials.project_id
           return credentials, project_id
   ```
   
   
   



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] phanikumv commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
phanikumv commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r909689498


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -270,7 +271,12 @@ def _get_credentials(self) -> google.auth.credentials.Credentials:
 
     def _get_access_token(self) -> str:
         """Returns a valid access token from Google API Credentials"""
-        return self._get_credentials().token
+        credentials = self._get_credentials()
+        auth_req = google.auth.transport.requests.Request()
+        # credentials.token is None
+        # Need to refresh credentials to populate the token

Review Comment:
   The method `_get_access_token()` wasn't being used anywhere earlier. A sample dump of the Credentials object is:
   
   ``{'token': None, 'expiry': None, '_quota_project_id': None, '_scopes': ('https://www.googleapis.com/auth/cloud-platform',), '_default_scopes': None, '_signer': <google.auth.crypt._cryptography_rsa.RSASigner object at 0x40359f3af0>, '_service_account_email': 'phani-svc-account@xxxxxxxx.iam.gserviceaccount.com', '_subject': None, '_project_id': 'xxxxxx-providers', '_token_uri': 'https://oauth2.googleapis.com/token', '_always_use_jwt_access': False, '_jwt_credentials': None, '_additional_claims': {}}``



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] phanikumv commented on a diff in pull request #24682: Add test_connection method to GoogleBaseHook

Posted by GitBox <gi...@apache.org>.
phanikumv commented on code in PR #24682:
URL: https://github.com/apache/airflow/pull/24682#discussion_r909692076


##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -580,3 +580,16 @@ def download_content_from_request(file_handle, request: dict, chunk_size: int) -
         while done is False:
             _, done = downloader.next_chunk()
         file_handle.flush()
+
+    def test_connection(self):
+        """Test the Google cloud connectivity from UI"""
+        status, message = False, ''
+        try:
+            if self.project_id:

Review Comment:
   @mik-laj could you please take a look at [ae4824e](https://github.com/apache/airflow/pull/24682/commits/ae4824e9e60ffb46d3d4d638c87b6da0fa7b5ac7)



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org