public function testUnlimited()
 {
     $quota = 'unlimited';
     $expiration = time() + 86400 * 365;
     $response = API::post('users/' . self::$config['userID'] . '/storageadmin', "quota={$quota}&expiration={$expiration}", [], ["username" => self::$config['rootUsername'], "password" => self::$config['rootPassword']]);
     $this->assert200($response);
     $xml = API::getXMLFromResponse($response);
     $this->assertEquals($quota, (string) $xml->quota);
     $this->assertEquals($expiration, (int) $xml->expiration);
 }
Beispiel #2
0
 public function testKeyCreateAndModifyWithCredentials()
 {
     API::useAPIKey("");
     $name = "Test " . uniqid();
     // Can't create on /users/:userID/keys with credentials
     $response = API::userPost(self::$config['userID'], 'keys', json_encode(['username' => self::$config['username'], 'password' => self::$config['password'], 'name' => $name, 'access' => ['user' => ['library' => true]]]));
     $this->assert403($response);
     // Create with credentials
     $response = API::post('keys', json_encode(['username' => self::$config['username'], 'password' => self::$config['password'], 'name' => $name, 'access' => ['user' => ['library' => true]]]), [], []);
     $this->assert201($response);
     $json = API::getJSONFromResponse($response);
     $key = $json['key'];
     $this->assertEquals($json['userID'], self::$config['userID']);
     $this->assertEquals($json['name'], $name);
     $this->assertEquals(['user' => ['library' => true, 'files' => true]], $json['access']);
     $name = "Test " . uniqid();
     // Can't modify on /users/:userID/keys/:key with credentials
     $response = API::userPut(self::$config['userID'], "keys/{$key}", json_encode(['username' => self::$config['username'], 'password' => self::$config['password'], 'name' => $name, 'access' => ['user' => ['library' => true]]]));
     $this->assert403($response);
     // Modify with credentials
     $response = API::put("keys/{$key}", json_encode(['username' => self::$config['username'], 'password' => self::$config['password'], 'name' => $name, 'access' => ['user' => ['library' => true]]]));
     $this->assert200($response);
     $json = API::getJSONFromResponse($response);
     $key = $json['key'];
     $this->assertEquals($json['name'], $name);
     $response = API::userDelete(self::$config['userID'], "keys/{$key}");
     $this->assert204($response);
 }