Esempio n. 1
0
  def test_get_raz_client(self):

    with patch('desktop.lib.raz.raz_client.RazToken') as RazToken:
      with patch('desktop.lib.raz.raz_client.requests_kerberos.HTTPKerberosAuth') as HTTPKerberosAuth:
        client = get_raz_client(
          raz_url=self.raz_url,
          username=self.username,
          auth='kerberos',
          service='s3',
          service_name='gethue_s3',
          cluster_name='gethueCluster'
        )

        assert_true(isinstance(client, RazClient))

        HTTPKerberosAuth.assert_called()
        assert_equal(
          client.raz_url, self.raz_url
        )
        assert_equal(
          client.service_name, 'gethue_s3'
        )
        assert_equal(
          client.cluster_name, 'gethueCluster'
        )
Esempio n. 2
0
    def get_url(self, action='GET', path=None, headers=None):
        c = get_raz_client(
            raz_url=RAZ.API_URL.get(),
            username=self.username,
            auth=RAZ.API_AUTHENTICATION.get(),
            service='adls',
        )

        return c.check_access(method=action, url=path, headers=headers)
Esempio n. 3
0
    def get_url(self, action='GET', path=None, headers=None):
        c = get_raz_client(
            raz_url=RAZ.API_URL.get(),
            username=self.username,
            auth=RAZ.API_AUTHENTICATION.get(),
            service='adls',
        )

        # We need to sign the header source path separately for rename operation
        if headers.get('x-ms-rename-source'):
            partition_path = path.partition('.dfs.core.windows.net')
            source_path = partition_path[0] + partition_path[1] + headers.get(
                'x-ms-rename-source')

            sas_token = c.check_access(method=action,
                                       url=source_path,
                                       headers=None)
            headers['x-ms-rename-source'] += '?' + sas_token.get('token')

        return c.check_access(method=action, url=path, headers=headers)
Esempio n. 4
0
    def get_url(self, action='GET', path=None, headers=None):
        '''
    Example of headers:
    {
      u'x-amz-content-sha256': u'UNSIGNED-PAYLOAD',
      u'Host': u'prakashmowdev1.s3-us-west-2.amazonaws.com',
      u'X-Amz-Security-Token': u'IQoJb3JpZ2luX2Vj...C',
      u'X-Amz-Date': u'20210604T102022Z',
      u'Authorization': u'AWS4-HMAC-SHA256 Credential=ASIAYO3P24NAOAYMMDNN/20210604/us-west-2/s3/aws4_request, SignedHeaders=host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=d341a194c2998c64b6fc726b69d0c3c2b97d520265f80df7e1bc1ac59a21ef94',
      u'User-Agent': u'user:csso_romain'
    }
    '''
        c = get_raz_client(
            raz_url=RAZ.API_URL.get(),
            username=self.username,
            auth=RAZ.API_AUTHENTICATION.get(),
            service='s3',
        )

        return c.check_access(method=action, url=path, headers=headers)