Browse Source

[raz] Update Raz Http Client to include actual SAS token (#2377)

Harsh Gupta 4 years ago
parent
commit
8491241071

+ 2 - 2
desktop/core/src/desktop/lib/rest/raz_http_client.py

@@ -43,9 +43,9 @@ class RazHttpClient(HttpClient):
 
     url = self._make_url(path, params)
 
-    token = raz_client.get_url(action=http_method, path=url, headers=headers)
+    response = raz_client.get_url(action=http_method, path=url, headers=headers)
 
-    signed_path = path + ('?' if '?' in url else '&') + token  # Same as using as params
+    signed_path = path + ('?' if '?' not in url else '&') + response['token']
 
     return super(RazHttpClient, self).execute(
         http_method=http_method,

+ 4 - 2
desktop/core/src/desktop/lib/rest/raz_http_client_test.py

@@ -33,7 +33,9 @@ class TestRazHttpClient():
     with patch('desktop.lib.rest.raz_http_client.AdlsRazClient.get_url') as raz_get_url:
       with patch('desktop.lib.rest.raz_http_client.HttpClient.execute') as http_execute:
 
-        raz_get_url.return_value = 'sv=2014-02-14&sr=b&sig=pJL%2FWyed41tptiwBM5ymYre4qF8wzrO05tS5MCjkutc%3D&st=2015-01-02T01%3A40%3A51Z&se=2015-01-02T02%3A00%3A51Z&sp=r'
+        raz_get_url.return_value = {
+          'token': 'sv=2014-02-14&sr=b&sig=pJL%2FWyed41tptiwBM5ymYre4qF8wzrO05tS5MCjkutc%3D&st=2015-01-02T01%3A40%3A51Z&se=2015-01-02T02%3A00%3A51Z&sp=r'
+        }
         http_execute.return_value = 'my file content'
 
         client = RazHttpClient(username='test', base_url='https://gethue.blob.core.windows.net')
@@ -43,7 +45,7 @@ class TestRazHttpClient():
         raz_get_url.assert_called_with(action='GET', path='https://gethue.blob.core.windows.net/gethue/data/customer.csv', headers=None)
         http_execute.assert_called_with(
             http_method='GET',
-            path='/gethue/data/customer.csv&sv=2014-02-14&sr=b&sig=pJL%2FWyed41tptiwBM5ymYre4qF8wzrO05tS5MCjkutc%3D&st=2015-01-02T01%3A40%3A51Z&se=2015-01-02T02%3A00%3A51Z&sp=r',
+            path='/gethue/data/customer.csv?sv=2014-02-14&sr=b&sig=pJL%2FWyed41tptiwBM5ymYre4qF8wzrO05tS5MCjkutc%3D&st=2015-01-02T01%3A40%3A51Z&se=2015-01-02T02%3A00%3A51Z&sp=r',
             params=None,
             data=None,
             headers=None,