forked from extern/egroupware
WIP - Sharing test - some debug, starting to test writable
This commit is contained in:
parent
600872a4bf
commit
b5a4b050d5
@ -3,6 +3,9 @@
|
|||||||
/**
|
/**
|
||||||
* Tests for sharing files and directories
|
* Tests for sharing files and directories
|
||||||
*
|
*
|
||||||
|
* This is a bit of a mess, but I think we probably want to automatically test
|
||||||
|
* this to make sure we don't expose more than desired.
|
||||||
|
*
|
||||||
* @link http://www.egroupware.org
|
* @link http://www.egroupware.org
|
||||||
* @author Nathan Gray
|
* @author Nathan Gray
|
||||||
* @package
|
* @package
|
||||||
@ -52,7 +55,7 @@ class SharingTest extends LoggedInTest
|
|||||||
|
|
||||||
foreach($this->shares as $share)
|
foreach($this->shares as $share)
|
||||||
{
|
{
|
||||||
Sharing::delete($share);
|
// Sharing::delete($share);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +64,7 @@ class SharingTest extends LoggedInTest
|
|||||||
* Test to make sure a readonly link to home gives just readonly access,
|
* Test to make sure a readonly link to home gives just readonly access,
|
||||||
* and just to user's home
|
* and just to user's home
|
||||||
*/
|
*/
|
||||||
public function testHomeReadonly()
|
public function _testHomeReadonly()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete(
|
$this->markTestIncomplete(
|
||||||
'This test has not been implemented yet.'
|
'This test has not been implemented yet.'
|
||||||
@ -102,17 +105,36 @@ class SharingTest extends LoggedInTest
|
|||||||
return;
|
return;
|
||||||
// Still have problems finding the files
|
// Still have problems finding the files
|
||||||
|
|
||||||
var_dump(Vfs::find('/',array('maxdepth' => 1)));
|
|
||||||
$dir = Vfs::get_home_dir().'/test_subdir/';
|
$dir = Vfs::get_home_dir().'/';
|
||||||
|
|
||||||
|
if(!Vfs::is_writable($dir))
|
||||||
|
{
|
||||||
|
$this->markTestSkipped("Unable to write to '$dir' as expected");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add some things for us to find, and make sure the dir is actually writable
|
||||||
|
error_log(__METHOD__ . "------------\n");
|
||||||
|
error_log("Mount:");
|
||||||
|
error_log(print_r(Vfs::mount(),true));
|
||||||
|
$stat = Vfs::stat($dir.'/test_subdir/');
|
||||||
|
error_log("Stat: " . print_r($stat, true));
|
||||||
|
error_log("Perms: " . Vfs::int2mode($stat['mode']));
|
||||||
|
error_log( __METHOD__." ------------\n");
|
||||||
|
Vfs::mkdir($dir.'/test_subdir/');
|
||||||
|
$file = $dir.'test_file.txt';
|
||||||
|
echo "Test file: $file\n";
|
||||||
|
file_put_contents(Vfs::PREFIX.$dir.'test_file.txt', 'Test for ' . $this->getName());
|
||||||
|
|
||||||
$logged_in_files = array_map(
|
$logged_in_files = array_map(
|
||||||
function($path) use ($dir) {return str_replace($dir, '/', $path);},
|
function($path) use ($dir) {return str_replace($dir, '/', $path);},
|
||||||
Vfs::find($dir)
|
Vfs::find($dir)
|
||||||
);
|
);
|
||||||
var_dump($logged_in_files);
|
|
||||||
|
var_dump($logged_in_files);
|
||||||
$this->shareLink($dir, Sharing::WRITABLE);
|
$this->shareLink($dir, Sharing::WRITABLE);
|
||||||
var_dump(Vfs::find('/',array('maxdepth' => 1)));
|
var_dump(Vfs::find('/',array('maxdepth' => 1)));
|
||||||
$files = Vfs::find(Vfs::get_home_dir().'/test_subdir');
|
$files = Vfs::find(Vfs::get_home_dir());
|
||||||
|
|
||||||
// Make sure files are the same
|
// Make sure files are the same
|
||||||
$this->assertEquals($logged_in_files, $files);
|
$this->assertEquals($logged_in_files, $files);
|
||||||
@ -120,7 +142,8 @@ class SharingTest extends LoggedInTest
|
|||||||
// Make sure all are writable
|
// Make sure all are writable
|
||||||
foreach($files as $file)
|
foreach($files as $file)
|
||||||
{
|
{
|
||||||
echo "\t".$file . "\n";
|
// Root is not writable
|
||||||
|
if($file == '/') continue;
|
||||||
$this->assertTrue(Vfs::is_writable($file), $file . ' was not writable');
|
$this->assertTrue(Vfs::is_writable($file), $file . ' was not writable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,6 +178,7 @@ class SharingTest extends LoggedInTest
|
|||||||
// Setup - create path and share
|
// Setup - create path and share
|
||||||
$share = $this->createShare($path, $mode);
|
$share = $this->createShare($path, $mode);
|
||||||
$link = Vfs\Sharing::share2link($share);
|
$link = Vfs\Sharing::share2link($share);
|
||||||
|
echo __METHOD__ . " link: $link\n";
|
||||||
|
|
||||||
// Setup for share to load
|
// Setup for share to load
|
||||||
$_SERVER['REQUEST_URI'] = $link;
|
$_SERVER['REQUEST_URI'] = $link;
|
||||||
@ -197,6 +221,14 @@ class SharingTest extends LoggedInTest
|
|||||||
$html = curl_exec($curl);
|
$html = curl_exec($curl);
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
|
|
||||||
|
if(!$html)
|
||||||
|
{
|
||||||
|
// No response - could mean something is terribly wrong, or it could
|
||||||
|
// mean we're running on Travis with no webserver to answer the
|
||||||
|
// request
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Parse & check for nextmatch
|
// Parse & check for nextmatch
|
||||||
$dom = new \DOMDocument();
|
$dom = new \DOMDocument();
|
||||||
@$dom->loadHTML($html);
|
@$dom->loadHTML($html);
|
||||||
@ -205,6 +237,9 @@ class SharingTest extends LoggedInTest
|
|||||||
$data = json_decode($form->getAttribute('data-etemplate'));
|
$data = json_decode($form->getAttribute('data-etemplate'));
|
||||||
|
|
||||||
$this->assertEquals('filemanager.index', $data->name);
|
$this->assertEquals('filemanager.index', $data->name);
|
||||||
|
|
||||||
|
// Make sure we start at root, not somewhere else like the token mounted
|
||||||
|
// as a sub-directory
|
||||||
$this->assertEquals('/', $data->data->content->nm->path);
|
$this->assertEquals('/', $data->data->content->nm->path);
|
||||||
|
|
||||||
unset($data->data->content->nm->actions);
|
unset($data->data->content->nm->actions);
|
||||||
|
Loading…
Reference in New Issue
Block a user