Esempio n. 1
0
 public function testAccountBy()
 {
     $values = array('adminName', 'appAdminName', 'id', 'foreignPrincipal', 'name', 'krb5Principal');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\AccountBy::has($value));
     }
 }
 public function testDeleteGalSyncAccountApi()
 {
     $value = $this->faker->word;
     $account = new AccountSelector(AccountBy::NAME(), $value);
     $this->api->deleteGalSyncAccount($account);
     $client = $this->api->getClient();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:DeleteGalSyncAccountRequest>' . '<urn1:account by="' . AccountBy::NAME() . '">' . $value . '</urn1:account>' . '</urn1:DeleteGalSyncAccountRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testGetAdminConsoleUICompApi()
 {
     $value = $this->faker->word;
     $account = new AccountSelector(AccountBy::NAME(), $value);
     $dl = new DistributionListSelector(DLBy::NAME(), $value);
     $this->api->getAdminConsoleUIComp($account, $dl);
     $client = $this->api->getClient();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:GetAdminConsoleUICompRequest>' . '<urn1:account by="' . AccountBy::NAME() . '">' . $value . '</urn1:account>' . '<urn1:dl by="' . DLBy::NAME() . '">' . $value . '</urn1:dl>' . '</urn1:GetAdminConsoleUICompRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 4
0
 public function testCheckPermissionApi()
 {
     $value = $this->faker->word;
     $right = $this->faker->word;
     $target = new TargetSpec(TargetType::ACCOUNT(), AccountBy::NAME(), $value);
     $this->api->checkPermission($target, [$right]);
     $client = $this->api->getClient();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraMail">' . '<env:Body>' . '<urn1:CheckPermissionRequest>' . '<urn1:target type="' . TargetType::ACCOUNT() . '" by="' . AccountBy::NAME() . '">' . $value . '</urn1:target>' . '<urn1:right>' . $right . '</urn1:right>' . '</urn1:CheckPermissionRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 5
0
 public function testAuthByAccount()
 {
     $name = $this->faker->word;
     $password = $this->faker->sha1;
     $virtualHost = $this->faker->word;
     $account = new \Zimbra\Struct\AccountSelector(AccountBy::NAME(), $name);
     $this->api->authByAccount($account, $password, $virtualHost);
     $client = $this->api->getClient();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:AuthRequest password="******" persistAuthTokenCookie="true">' . '<urn1:account by="' . AccountBy::NAME() . '">' . $name . '</urn1:account>' . '<urn1:virtualHost>' . $virtualHost . '</urn1:virtualHost>' . '</urn1:AuthRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 6
0
 public function testResumeDeviceApi()
 {
     $id = $this->faker->uuid;
     $value = $this->faker->word;
     $account = new AccountSelector(AccountBy::NAME(), $value);
     $device = new DeviceId($id);
     $this->api->resumeDevice($account, $device);
     $client = $this->api->getClient();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:ResumeDeviceRequest>' . '<urn1:account by="' . AccountBy::NAME() . '">' . $value . '</urn1:account>' . '<urn1:device id="' . $id . '" />' . '</urn1:ResumeDeviceRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 7
0
 public function testAccountSelector()
 {
     $value = $this->faker->word;
     $acc = new AccountSelector(AccountBy::ID(), $value);
     $this->assertTrue($acc->getBy()->is('id'));
     $acc->setBy(AccountBy::ADMIN_NAME());
     $this->assertTrue($acc->getBy()->is('adminName'));
     $xml = '<?xml version="1.0"?>' . "\n" . '<account by="' . AccountBy::ADMIN_NAME() . '">' . $value . '</account>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $acc);
     $array = ['account' => ['by' => AccountBy::ADMIN_NAME()->value(), '_content' => $value]];
     $this->assertEquals($array, $acc->toArray());
 }
Esempio n. 8
0
 public function testAddAccountLoggerApi()
 {
     $category = $this->faker->word;
     $value = $this->faker->word;
     $logger = new LoggerInfo($category, LoggingLevel::ERROR());
     $account = new AccountSelector(AccountBy::NAME(), $value);
     $this->api->addAccountLogger($logger, $account);
     $client = $this->api->getClient();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:AddAccountLoggerRequest>' . '<urn1:logger category="' . $category . '" level="' . LoggingLevel::ERROR() . '" />' . '<urn1:account by="' . AccountBy::NAME() . '">' . $value . '</urn1:account>' . '</urn1:AddAccountLoggerRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 9
0
 public function testLockoutMailboxApi()
 {
     $name = $this->faker->word;
     $value = $this->faker->word;
     $ops = ['start', 'end'];
     $op = $ops[array_rand($ops)];
     $account = new AccountNameSelector(AccountBy::NAME(), $name, $value);
     $this->api->lockoutMailbox($account, LockoutOperation::START());
     $client = $this->api->getClient();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:LockoutMailboxRequest op="' . LockoutOperation::START() . '">' . '<urn1:account by="' . AccountBy::NAME() . '" name="' . $name . '">' . $value . '</urn1:account>' . '</urn1:LockoutMailboxRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 10
0
 public function testChangePasswordApi()
 {
     $value = $this->faker->word;
     $oldPassword = $this->faker->sha1;
     $password = $this->faker->sha1;
     $virtualHost = $this->faker->word;
     $account = new AccountSelector(AccountBy::NAME(), $value);
     $this->api->changePassword($account, $oldPassword, $password, $virtualHost);
     $client = $this->api->getClient();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAccount">' . '<env:Body>' . '<urn1:ChangePasswordRequest>' . '<urn1:account by="' . AccountBy::NAME() . '">' . $value . '</urn1:account>' . '<urn1:oldPassword>' . $oldPassword . '</urn1:oldPassword>' . '<urn1:password>' . $password . '</urn1:password>' . '<urn1:virtualHost>' . $virtualHost . '</urn1:virtualHost>' . '</urn1:ChangePasswordRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 11
0
 public function testGetShareInfoApi()
 {
     $value = $this->faker->word;
     $type = $this->faker->word;
     $id = $this->faker->word;
     $name = $this->faker->word;
     $owner = new AccountSelector(AccountBy::NAME(), $value);
     $grantee = new GranteeChooser($type, $id, $name);
     $this->api->getShareInfo($owner, $grantee);
     $client = $this->api->getClient();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:GetShareInfoRequest>' . '<urn1:owner by="' . AccountBy::NAME() . '">' . $value . '</urn1:owner>' . '<urn1:grantee type="' . $type . '" id="' . $id . '" name="' . $name . '" />' . '</urn1:GetShareInfoRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 12
0
 public function testTargetSpec()
 {
     $value = $this->faker->word;
     $target = new TargetSpec(TargetType::DL(), AccountBy::ID(), $value);
     $this->assertTrue($target->getTargetType()->is('dl'));
     $this->assertTrue($target->getAccountBy()->is('id'));
     $target->setTargetType(TargetType::ACCOUNT())->setAccountBy(AccountBy::NAME());
     $this->assertTrue($target->getTargetType()->is('account'));
     $this->assertTrue($target->getAccountBy()->is('name'));
     $xml = '<?xml version="1.0"?>' . "\n" . '<target type="' . TargetType::ACCOUNT() . '" by="' . AccountBy::NAME() . '">' . $value . '</target>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $target);
     $array = array('target' => array('type' => TargetType::ACCOUNT()->value(), 'by' => AccountBy::NAME()->value(), '_content' => $value));
     $this->assertEquals($array, $target->toArray());
 }
 public function testAddGalSyncDataSourceApi()
 {
     $key = $this->faker->word;
     $value = $this->faker->word;
     $name = $this->faker->word;
     $domain = $this->faker->word;
     $folder = $this->faker->word;
     $attr = new KeyValuePair($key, $value);
     $account = new AccountSelector(AccountBy::NAME(), $value);
     $this->api->addGalSyncDataSource($account, $name, $domain, GalMode::BOTH(), $folder, [$attr]);
     $client = $this->api->getClient();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:AddGalSyncDataSourceRequest name="' . $name . '" domain="' . $domain . '" type="' . GalMode::BOTH() . '" folder="' . $folder . '">' . '<urn1:account by="' . AccountBy::NAME() . '">' . $value . '</urn1:account>' . '<urn1:a n="' . $key . '">' . $value . '</urn1:a>' . '</urn1:AddGalSyncDataSourceRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 14
0
 public function testTargetSpec()
 {
     $target = new \Zimbra\Mail\Struct\TargetSpec(TargetType::ACCOUNT(), AccountBy::NAME(), 'value');
     $this->assertTrue($target->type()->is('account'));
     $this->assertTrue($target->by()->is('name'));
     $this->assertSame('value', $target->value());
     $target->type(TargetType::ACCOUNT())->by(AccountBy::NAME())->value('value');
     $this->assertTrue($target->type()->is('account'));
     $this->assertTrue($target->by()->is('name'));
     $this->assertSame('value', $target->value());
     $xml = '<?xml version="1.0"?>' . "\n" . '<target type="account" by="name">value</target>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $target);
     $array = array('target' => array('type' => 'account', 'by' => 'name', '_content' => 'value'));
     $this->assertEquals($array, $target->toArray());
 }
Esempio n. 15
0
 public function testCheckPermission()
 {
     $target = new \Zimbra\Mail\Struct\TargetSpec(TargetType::ACCOUNT(), AccountBy::NAME(), 'value');
     $this->_api->checkPermission($target, array('right'));
     $client = $this->_api->client();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraMail">' . '<env:Body>' . '<urn1:CheckPermissionRequest>' . '<urn1:target type="account" by="name">value</urn1:target>' . '<urn1:right>right</urn1:right>' . '</urn1:CheckPermissionRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 16
0
 public function testAuthByToken()
 {
     $value = $this->faker->sha1;
     $virtualHost = $this->faker->word;
     $account = new AccountSelector(AccountBy::NAME(), $value);
     $authToken = new AuthToken($value, true);
     $this->api->authByToken($account, $authToken, $virtualHost);
     $client = $this->api->getClient();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAccount">' . '<env:Body>' . '<urn1:AuthRequest>' . '<urn1:account by="' . AccountBy::NAME() . '">' . $value . '</urn1:account>' . '<urn1:authToken verifyAccount="true">' . $value . '</urn1:authToken>' . '<urn1:virtualHost>' . $virtualHost . '</urn1:virtualHost>' . '<urn1:prefs />' . '<urn1:attrs />' . '</urn1:AuthRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 17
0
 public function testUpdateDeviceStatus()
 {
     $value = self::randomName();
     $id = self::randomName();
     $status = self::randomName();
     $account = new \Zimbra\Struct\AccountSelector(AccountBy::NAME(), $value);
     $device = new \Zimbra\Admin\Struct\IdStatus($id, $status);
     $this->_api->updateDeviceStatus($account, $device);
     $client = $this->_api->client();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' . '<env:Body>' . '<urn1:UpdateDeviceStatusRequest>' . '<urn1:account by="' . AccountBy::NAME() . '">' . $value . '</urn1:account>' . '<urn1:device id="' . $id . '" status="' . $status . '" />' . '</urn1:UpdateDeviceStatusRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 18
0
 public function testGetShareInfo()
 {
     $value = md5(self::randomString());
     $name = self::randomName();
     $type = self::randomName();
     $id = self::randomName();
     $owner = new \Zimbra\Struct\AccountSelector(AccountBy::NAME(), $value);
     $grantee = new \Zimbra\Struct\GranteeChooser($type, $id, $name);
     $this->_api->getShareInfo($grantee, $owner, true, false);
     $client = $this->_api->client();
     $req = $client->lastRequest();
     $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAccount">' . '<env:Body>' . '<urn1:GetShareInfoRequest internal="true" includeSelf="false" >' . '<urn1:grantee type="' . $type . '" id="' . $id . '" name="' . $name . '" />' . '<urn1:owner by="' . AccountBy::NAME() . '">' . $value . '</urn1:owner>' . '</urn1:GetShareInfoRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Esempio n. 19
0
 public function testCheckPermission()
 {
     $target = new \Zimbra\Mail\Struct\TargetSpec(TargetType::ACCOUNT(), AccountBy::NAME(), 'value');
     $req = new \Zimbra\Mail\Request\CheckPermission($target, array('right1'));
     $this->assertInstanceOf('Zimbra\\Mail\\Request\\Base', $req);
     $this->assertSame($target, $req->target());
     $this->assertSame(array('right1'), $req->right()->all());
     $req->target($target)->addRight('right2');
     $this->assertSame($target, $req->target());
     $this->assertSame(array('right1', 'right2'), $req->right()->all());
     $xml = '<?xml version="1.0"?>' . "\n" . '<CheckPermissionRequest>' . '<target type="account" by="name">value</target>' . '<right>right1</right>' . '<right>right2</right>' . '</CheckPermissionRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = array('CheckPermissionRequest' => array('_jsns' => 'urn:zimbraMail', 'target' => array('type' => 'account', 'by' => 'name', '_content' => 'value'), 'right' => array('right1', 'right2')));
     $this->assertEquals($array, $req->toArray());
 }
Esempio n. 20
0
 public function testGetShareInfo()
 {
     $value = md5(self::randomString());
     $name = self::randomName();
     $type = self::randomName();
     $id = self::randomName();
     $owner = new \Zimbra\Struct\AccountSelector(AccountBy::NAME(), $value);
     $grantee = new \Zimbra\Struct\GranteeChooser($type, $id, $name);
     $req = new \Zimbra\Account\Request\GetShareInfo($grantee, $owner, true, false);
     $this->assertInstanceOf('Zimbra\\Account\\Request\\Base', $req);
     $this->assertSame($grantee, $req->getGrantee());
     $this->assertSame($owner, $req->getOwner());
     $this->assertTrue($req->getInternal());
     $this->assertFalse($req->getIncludeSelf());
     $req->setGrantee($grantee)->setOwner($owner)->setInternal(false)->setIncludeSelf(true);
     $this->assertSame($grantee, $req->getGrantee());
     $this->assertSame($owner, $req->getOwner());
     $this->assertFalse($req->getInternal());
     $this->assertTrue($req->getIncludeSelf());
     $xml = '<?xml version="1.0"?>' . "\n" . '<GetShareInfoRequest internal="false" includeSelf="true" >' . '<grantee type="' . $type . '" id="' . $id . '" name="' . $name . '" />' . '<owner by="' . AccountBy::NAME() . '">' . $value . '</owner>' . '</GetShareInfoRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['GetShareInfoRequest' => ['_jsns' => 'urn:zimbraAccount', 'internal' => false, 'includeSelf' => true, 'grantee' => ['type' => $type, 'id' => $id, 'name' => $name], 'owner' => ['by' => AccountBy::NAME()->value(), '_content' => $value]]];
     $this->assertEquals($array, $req->toArray());
 }
Esempio n. 21
0
 public function testUpdateDeviceStatus()
 {
     $value = self::randomName();
     $id = self::randomName();
     $status = self::randomName();
     $account = new \Zimbra\Struct\AccountSelector(AccountBy::NAME(), $value);
     $device = new \Zimbra\Admin\Struct\IdStatus($id, $status);
     $req = new \Zimbra\Admin\Request\UpdateDeviceStatus($account, $device);
     $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req);
     $this->assertSame($account, $req->getAccount());
     $this->assertSame($device, $req->getDevice());
     $req->setAccount($account)->setDevice($device);
     $this->assertSame($account, $req->getAccount());
     $this->assertSame($device, $req->getDevice());
     $xml = '<?xml version="1.0"?>' . "\n" . '<UpdateDeviceStatusRequest>' . '<account by="' . AccountBy::NAME() . '">' . $value . '</account>' . '<device id="' . $id . '" status="' . $status . '" />' . '</UpdateDeviceStatusRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['UpdateDeviceStatusRequest' => ['_jsns' => 'urn:zimbraAdmin', 'account' => ['by' => AccountBy::NAME()->value(), '_content' => $value], 'device' => ['id' => $id, 'status' => $status]]];
     $this->assertEquals($array, $req->toArray());
 }