<commit_before><?php

/*
 *  FileTrader - Web based file sharing platform
 *  Copyright (C) 2011 <NAME> <<EMAIL>>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

require_once('config.php');
require_once('../fts/utils.php'); /* steal fts utils ;) */
require_once('lib/StorageClient/StorageClient.class.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'testUtils.php');

if (!isset($config) || !is_array($config)) {
	die("broken or missing configuration file?");
}

/* generate some random names in order to be reasonably sure they don't exist yet */
$fileName = generateToken(4);
$dirName = generateToken(4);

/* act as this user, also use a random name */
$userName = generateToken(4);

/* we use the first configured storage provider as defined in the config file,
 * make sure it is valid! */
$storageProviders = getConfig($config, 'storage_providers');

$sc = new StorageClient($storageProviders[0]);
$sc->performDecode(TRUE);

$response = $sc->call("pingServer");
handleResponse("ping", $response);

/* create a directory */
$response = $sc
		->call("createDirectory",
				array('relativeDirPath' => $dirName), "POST");
handleResponse("dir create", $response);

/* upload a file, use random name, but actually send COPYING as it is 
 * there anyway... */
$response = $sc
		->call("getUploadToken",
				array('relativeFilePath' => $fileName,
						'fileSize' => filesize("COPYING")), "POST");
handleResponse("get upload token", $response);

$response = uploadFile($response->uploadLocation, "COPYING", 1024);
handleResponse("upload file", $response);

/* download the file */
$response = $sc
		->call("getDownloadToken",
				array('relativeFilePath' => $fileName),
				"POST");
handleResponse("get download token", $response);

$response = downloadFile($response->downloadLocation, "COPYING");
handleResponse("download file", $response);

/* show directory */
$response = $sc->call("getFileList", array('relativeDirPath' => '.'), "GET");
// showDirectoryListing($response);
handleResponse("get file list", $response);

/* delete the directory */
$response = $sc
		->call("deleteDirectory",
				array('relativeDirPath' => $dirName), "POST");
handleResponse("dir delete", $response);

/* delete the file */
$response = $sc
		->call("deleteFile",
				array('relativeFilePath' => $fileName),
				"POST");
handleResponse("delete file", $response);
?>
<commit_msg>update tests again<commit_after><?php

/*
 *  FileTrader - Web based file sharing platform
 *  Copyright (C) 2011 <NAME> <<EMAIL>>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

require_once('config.php');
require_once('../fts/utils.php'); /* steal fts utils ;) */
require_once('lib/StorageClient/StorageClient.class.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'testUtils.php');

if (!isset($config) || !is_array($config)) {
	die("broken or missing configuration file?");
}

/* generate some random names in order to be reasonably sure they don't exist yet */
$fileName = generateToken(4);
$dirName = generateToken(4);
$otherDirName = generateToken(4);

/* act as this user, also use a random name */
$userName = generateToken(4);

/* we use the first configured storage provider as defined in the config file,
 * make sure it is valid! */
$storageProviders = getConfig($config, 'storage_providers');

$sc = new StorageClient($storageProviders[0]);
$sc->performDecode(TRUE);

$response = $sc->call("pingServer");
handleResponse("ping", $response);

/* create a directory */
$response = $sc
		->call("createDirectory",
				array('relativeDirPath' => $dirName), "POST");
handleResponse("dir create", $response);

/* create another directory */
$response = $sc
                ->call("createDirectory",
                                array('relativeDirPath' => $dirName . DIRECTORY_SEPARATOR . $otherDirName), "POST");
handleResponse("dir create 2", $response);

/* list this directory */
$response = $sc->call("getFileList", array('relativeDirPath' => $dirName), "GET");
handleResponse("get listing of directory", $response);
var_dump($response);

/* upload a file, use random name, but actually send COPYING as it is 
 * there anyway... */
$response = $sc
		->call("getUploadToken",
				array('relativeFilePath' => $fileName,
						'fileSize' => filesize("COPYING")), "POST");
handleResponse("get upload token", $response);

$response = uploadFile($response->uploadLocation, "COPYING", 1024);
handleResponse("upload file", $response);

/* download the file */
$response = $sc
		->call("getDownloadToken",
				array('relativeFilePath' => $fileName),
				"POST");
handleResponse("get download token", $response);

$response = downloadFile($response->downloadLocation, "COPYING");
handleResponse("download file", $response);

/* show directory */
$response = $sc->call("getFileList", array('relativeDirPath' => '.'), "GET");
// showDirectoryListing($response);
handleResponse("get file list", $response);
var_dump($response);

/* delete the directory */
//$response = $sc
//		->call("deleteDirectory",
//				array('relativeDirPath' => $dirName), "POST");
//handleResponse("dir delete", $response);

/* delete the file */
///$response = $sc
//		->call("deleteFile",
//				array('relativeFilePath' => $fileName),
//				"POST");
//handleResponse("delete file", $response);
?>

{'fraction_non_alphanumeric': 0.1505293846862053, 'fraction_numerical': 0.004296455424274973, 'mean_word_length': 4.633535004321521, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7423585', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1834, 'n_words': 612}