mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-26 15:59:23 +01:00
WIP on sharing test - now actually finding & checking the files
This commit is contained in:
parent
54dcc794a2
commit
05f7754f0e
@ -22,12 +22,20 @@ class SharingTest extends LoggedInTest
|
||||
|
||||
protected $shares = Array();
|
||||
|
||||
// Keep some server stuff to reset when done
|
||||
protected $original_server;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
|
||||
$this->original_server = array(
|
||||
'REQUEST_URI' => $_SERVER['REQUEST_URI'],
|
||||
'SCRIPT_NAME' => $_SERVER['SCRIPT_NAME']
|
||||
);
|
||||
}
|
||||
public function tearDown()
|
||||
{
|
||||
$_SERVER += $this->original_server;
|
||||
LoggedInTest::setupBeforeClass();
|
||||
foreach($this->shares as $share)
|
||||
{
|
||||
Sharing::delete($share);
|
||||
@ -58,41 +66,72 @@ class SharingTest extends LoggedInTest
|
||||
{
|
||||
// Setup - create path and share
|
||||
$share = $this->createShare($path, $mode);
|
||||
|
||||
$link = Vfs\Sharing::share2link($share);
|
||||
|
||||
// Log out
|
||||
//LoggedInTest::tearDownAfterClass();
|
||||
|
||||
// Load share
|
||||
echo __METHOD__ . " LINK: $link\n";
|
||||
var_dump($share);
|
||||
// Setup for share to load
|
||||
$_SERVER['REQUEST_URI'] = $link;
|
||||
$this->setup_info();
|
||||
Sharing::create_session();
|
||||
preg_match('|^https?://[^/]+(/.*)share.php/'.$share['share_token'].'$|', $path_info=$_SERVER['REQUEST_URI'], $matches);
|
||||
$_SERVER['SCRIPT_NAME'] = $matches[1];
|
||||
|
||||
// Try to read
|
||||
echo __METHOD__ . ' PATH: ' . $path. "\n";
|
||||
// Log out
|
||||
LoggedInTest::tearDownAfterClass();
|
||||
|
||||
// If it's a directory, check to make sure it gives the filemanager UI
|
||||
if(Vfs::is_dir($path))
|
||||
{
|
||||
$this->checkDirectoryLink($link, $share);
|
||||
}
|
||||
|
||||
LoggedInTest::setupBeforeClass();
|
||||
|
||||
// Load share
|
||||
$this->setup_info();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to make sure a readonly link to home gives just readonly access,
|
||||
* and just to user's home
|
||||
*/
|
||||
public function testHomeReadonly()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->readableLink('/home/'.$GLOBALS['egw_info']['user']['account_lid'], Sharing::READONLY);
|
||||
);
|
||||
return;
|
||||
$dir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
|
||||
|
||||
$logged_in_files = array_map(
|
||||
function($path) use ($dir) {return str_replace($dir, '/', $path);},
|
||||
Vfs::find($dir)
|
||||
);
|
||||
$this->readableLink($dir, Sharing::READONLY);
|
||||
$files = Vfs::find('/');
|
||||
|
||||
// Make sure files are the same
|
||||
$this->assertEquals($logged_in_files, $files);
|
||||
|
||||
// Make sure all are readonly
|
||||
foreach($files as $file)
|
||||
{
|
||||
$this->assertFalse(Vfs::is_writable($file));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to make sure that a directory link leads to a limited filemanager
|
||||
* interface (not a file or 404).
|
||||
*
|
||||
* @param type $link
|
||||
* @param type $share
|
||||
*/
|
||||
public function checkDirectoryLink($link, $share)
|
||||
{
|
||||
$curl = curl_init($link);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
||||
//curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10');
|
||||
$html = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$dom = new \DOMDocument();
|
||||
@ -121,6 +160,6 @@ class SharingTest extends LoggedInTest
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
static::load_egw('anonymous','','',$GLOBALS['egw_info']);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user