Exemple #1
0
 def test_using_oauth_token_credential_to_create_directory(self):
     # generate a token with directory level create permission
     directory_name = self._get_directory_reference()
     token_credential = self.generate_oauth_token()
     directory_client = DataLakeDirectoryClient(self.dsc.url,
                                                self.file_system_name,
                                                directory_name,
                                                credential=token_credential)
     response = directory_client.create_directory()
     self.assertIsNotNone(response)
    def test_rename_dir_with_file_system_sas(self):
        if TestMode.need_recording_file(self.test_mode):
            return

        token = generate_file_system_sas(
            self.dsc.account_name,
            self.file_system_name,
            self.dsc.credential.account_key,
            FileSystemSasPermissions(write=True, read=True, delete=True),
            datetime.utcnow() + timedelta(hours=1),
        )

        # read the created file which is under root directory
        dir_client = DataLakeDirectoryClient(self.dsc.url,
                                             self.file_system_name,
                                             "olddirectory",
                                             credential=token)
        dir_client.create_directory()
        new_client = dir_client.rename_directory(dir_client.file_system_name +
                                                 '/' + 'newdirectory')

        new_client.get_directory_properties()
        self.assertEqual(new_client.path_name, "newdirectory")
Exemple #3
0
    def test_using_directory_sas_to_create(self):
        # SAS URL is calculated from storage key, so this test runs live only
        if TestMode.need_recording_file(self.test_mode):
            return

        # generate a token with directory level create permission
        directory_name = self._get_directory_reference()
        token = generate_directory_sas(
            self.dsc.account_name,
            self.file_system_name,
            directory_name,
            account_key=self.dsc.credential.account_key,
            permission=DirectorySasPermissions(create=True),
            expiry=datetime.utcnow() + timedelta(hours=1),
        )
        directory_client = DataLakeDirectoryClient(self.dsc.url,
                                                   self.file_system_name,
                                                   directory_name,
                                                   credential=token)
        response = directory_client.create_directory()
        self.assertIsNotNone(response)