Эх сурвалжийг харах

[raz] Allow users to list root path in ABFS (#3019)

Harsh Gupta 3 жил өмнө
parent
commit
169b3feffb

+ 2 - 0
desktop/core/src/desktop/lib/raz/raz_client.py

@@ -214,6 +214,8 @@ class RazClient(object):
       access_type = ''
       if params.get('action') == 'getStatus' or params.get('resource') == 'filesystem':
         access_type = 'get-status'
+      if params.get('action') == 'getAccessControl':
+        access_type = 'get-acl'
 
     if method == 'DELETE':
       access_type = 'delete-recursive' if params.get('recursive') == 'true' else 'delete'

+ 7 - 0
desktop/core/src/desktop/lib/raz/raz_client_test.py

@@ -205,6 +205,13 @@ class RazClientTest(unittest.TestCase):
     access_type = client.handle_adls_req_mapping(method, url_params)
     assert_equal(access_type, 'get-status')
 
+    method = 'HEAD'
+    relative_path = '/'
+    url_params = {'action': 'getAccessControl'} # Stats call for root directory path
+
+    access_type = client.handle_adls_req_mapping(method, url_params)
+    assert_equal(access_type, 'get-acl')
+
     # Delete path
     method = 'DELETE'
     relative_path = '/user/csso_hueuser/test_dir/customer.csv'

+ 7 - 0
desktop/core/src/desktop/lib/rest/raz_http_client.py

@@ -48,6 +48,13 @@ class RazHttpClient(HttpClient):
     """
 
     url = self._make_url(path, params)
+
+    # For root stats, the root path needs to end with '/' before adding the query params.
+    if params and 'action' in params and params['action'] == 'getAccessControl':
+      partition_url = list(url.partition('?'))
+      partition_url[0] += '/'
+      url = ''.join(partition_url)
+
     sas_token = self.get_sas_token(http_method, self.username, url, params, headers)
 
     signed_url = url + ('?' if '?' not in url else '&') + sas_token

+ 19 - 0
desktop/core/src/desktop/lib/rest/raz_http_client_test.py

@@ -80,6 +80,25 @@ class TestRazHttpClient():
             timeout=120
         )
 
+        # Check for root path stats
+        f = client.execute(http_method='HEAD', path='/gethue', params={'action': 'getAccessControl'})
+        url = 'https://gethue.dfs.core.windows.net/gethue/?action=getAccessControl'
+
+        raz_get_url.assert_called_with(action='HEAD', path=url, headers=None)
+        raz_http_execute.assert_called_with(
+            http_method='HEAD',
+            path='/gethue/?action=getAccessControl&sv=2014-02-14&sr=b&sig=pJL%2FWyed41tptiwBM5ymYre4qF8wzrO05tS5MCjkutc%3D' \
+              '&st=2015-01-02T01%3A40%3A51Z&se=2015-01-02T02%3A00%3A51Z&sp=r',
+            data=None,
+            headers=None,
+            allow_redirects=False,
+            urlencode=False,
+            files=None,
+            stream=False,
+            clear_cookies=False,
+            timeout=120
+        )
+
 
   def test_handle_raz_adls_response(self):
     with patch('desktop.lib.rest.raz_http_client.AdlsRazClient.get_url') as raz_get_url:

+ 6 - 1
desktop/libs/azure/src/azure/abfs/abfs.py

@@ -266,7 +266,12 @@ class ABFS(object):
     """
     if params is None:
       params = {}
-    params['resource'] = 'filesystem'
+
+    # For RAZ ABFS, the root path stats should have 'getAccessControl' param.
+    if is_raz_abfs():
+      params['action'] = 'getAccessControl'
+    else:
+      params['resource'] = 'filesystem'
 
     res = self._root._invoke('HEAD', schemeless_path, params, headers=self._getheaders(), **kwargs)