Пример #1
0
 /**
  * Decryption succeeds
  * @return void
  * @throws \Exception
  */
 public function testDecryptSuccessfully()
 {
     $library = new \Seafile\Resource\Library($this->getMockedClient(new Response(200, ['Content-Type' => 'application/json'], '"success"')));
     $this->assertTrue($library->decrypt('some id', ['query' => ['password' => 'some password']]));
 }
Пример #2
0
 *   "baseUri": "https://your.seafile-server.example.com",
 *   "testLibId": "ID of an encrypted library",
 *   "testLibPassword": "******"
 * }
 */
$cfgFile = getenv("HOME") . "/.seafile-php-sdk/cfg.json";
if (!is_readable($tokenFile)) {
    throw new Exception($tokenFile . ' is not readable or does not exist.');
}
if (!is_readable($cfgFile)) {
    throw new Exception($cfgFile . ' is not readable or does not exist.');
}
$token = json_decode(file_get_contents($tokenFile));
$cfg = json_decode(file_get_contents($cfgFile));
$client = new Client(['base_uri' => $cfg->baseUri, 'debug' => true, 'handler' => $stack, 'headers' => ['Content-Type' => 'application/json', 'Authorization' => 'Token ' . $token->token]]);
$libraryResource = new Library($client);
$directoryResource = new Directory($client);
$fileResource = new File($client);
// get all libraries available
$logger->log(Logger::INFO, "#################### Getting all libraries");
$libs = $libraryResource->getAll();
foreach ($libs as $lib) {
    printf("Name: %s, ID: %s, is encrypted: %s\n", $lib->name, $lib->id, $lib->encrypted ? 'YES' : 'NO');
}
$libId = $cfg->testLibId;
// get specific library
$logger->log(Logger::INFO, "#################### Getting lib with ID " . $libId);
$lib = $libraryResource->getById($libId);
$lib->password = $cfg->testLibPassword;
// library is encrypted and thus we provide a password
if ($lib->encrypted) {
Пример #3
0
 /**
  * getById()
  *
  * @return void
  */
 public function testGetById()
 {
     $libraryResource = new Library($this->getMockedClient(new Response(200, ['Content-Type' => 'application/json'], file_get_contents(__DIR__ . '/../../assets/LibraryTest_getById.json'))));
     $this->assertInstanceOf('Seafile\\Type\\Library', $libraryResource->getById('some_id'));
 }