public function testAccountACEInfo()
 {
     $zid = $this->faker->uuid;
     $d = $this->faker->word;
     $key = $this->faker->word;
     $pw = $this->faker->sha256;
     $ace = new AccountACEInfo(GranteeType::USR(), AceRightType::INVITE(), $zid, $d, $key, $pw, false, true);
     $this->assertTrue($ace->getGranteeType()->is('usr'));
     $this->assertTrue($ace->getRight()->is('invite'));
     $this->assertSame($zid, $ace->getZimbraId());
     $this->assertSame($d, $ace->getDisplayName());
     $this->assertSame($key, $ace->getAccessKey());
     $this->assertSame($pw, $ace->getPassword());
     $this->assertFalse($ace->getDeny());
     $this->assertTrue($ace->getCheckGranteeType());
     $ace->setGranteeType(GranteeType::USR())->setRight(AceRightType::INVITE())->setZimbraId($zid)->setDisplayName($d)->setAccessKey($key)->setPassword($pw)->setDeny(true)->setCheckGranteeType(false);
     $this->assertTrue($ace->getGranteeType()->is('usr'));
     $this->assertTrue($ace->getRight()->is('invite'));
     $this->assertSame($zid, $ace->getZimbraId());
     $this->assertSame($d, $ace->getDisplayName());
     $this->assertSame($key, $ace->getAccessKey());
     $this->assertSame($pw, $ace->getPassword());
     $this->assertTrue($ace->getDeny());
     $this->assertFalse($ace->getCheckGranteeType());
     $xml = '<?xml version="1.0"?>' . "\n" . '<ace gt="' . GranteeType::USR() . '" right="' . AceRightType::INVITE() . '" zid="' . $zid . '" d="' . $d . '" key="' . $key . '" pw="' . $pw . '" deny="true" chkgt="false" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $ace);
     $array = ['ace' => ['gt' => GranteeType::USR()->value(), 'right' => AceRightType::INVITE()->value(), 'zid' => $zid, 'd' => $d, 'key' => $key, 'pw' => $pw, 'deny' => true, 'chkgt' => false]];
     $this->assertEquals($array, $ace->toArray());
 }
Example #2
0
 public function testAceRightType()
 {
     $values = array('viewFreeBusy', 'invite');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\AceRightType::has($value));
     }
 }
Example #3
0
 public function testGrantPermissionApi()
 {
     $zimbraId = $this->faker->uuid;
     $displayName = $this->faker->word;
     $accessKey = $this->faker->word;
     $password = $this->faker->sha1;
     $ace = new AccountACEinfo(GranteeType::USR(), AceRightType::INVITE(), $zimbraId, $displayName, $accessKey, $password, true);
     $this->api->grantPermission([$ace]);
     $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:GrantPermissionRequest>' . '<urn1:ace gt="' . GranteeType::USR() . '" right="' . AceRightType::INVITE() . '" zid="' . $zimbraId . '" d="' . $displayName . '" key="' . $accessKey . '" pw="' . $password . '" deny="true" />' . '</urn1:GrantPermissionRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #4
0
 public function testGrantRightsApi()
 {
     $zid = $this->faker->word;
     $dir = $this->faker->word;
     $key = $this->faker->word;
     $pw = $this->faker->word;
     $ace = new AccountACEInfo(GranteeType::ALL(), AceRightType::VIEW_FREE_BUSY(), $zid, $dir, $key, $pw, true, false);
     $this->api->grantRights([$ace]);
     $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:GrantRightsRequest>' . '<urn1:ace gt="' . GranteeType::ALL() . '" right="' . AceRightType::VIEW_FREE_BUSY() . '" zid="' . $zid . '" d="' . $dir . '" key="' . $key . '" pw="' . $pw . '" deny="true" chkgt="false" />' . '</urn1:GrantRightsRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #5
0
 public function testAccountACEinfo()
 {
     $ace = new \Zimbra\Mail\Struct\AccountACEinfo(GranteeType::USR(), AceRightType::INVITE(), 'zid', 'd', 'key', 'pw', false);
     $this->assertTrue($ace->gt()->is('usr'));
     $this->assertTrue($ace->right()->is('invite'));
     $this->assertSame('zid', $ace->zid());
     $this->assertSame('d', $ace->d());
     $this->assertSame('key', $ace->key());
     $this->assertSame('pw', $ace->pw());
     $this->assertFalse($ace->deny());
     $ace->gt(GranteeType::USR())->right(AceRightType::INVITE())->zid('zid')->d('d')->key('key')->pw('pw')->deny(true);
     $this->assertTrue($ace->gt()->is('usr'));
     $this->assertTrue($ace->right()->is('invite'));
     $this->assertSame('zid', $ace->zid());
     $this->assertSame('d', $ace->d());
     $this->assertSame('key', $ace->key());
     $this->assertSame('pw', $ace->pw());
     $this->assertTrue($ace->deny());
     $xml = '<?xml version="1.0"?>' . "\n" . '<ace gt="usr" right="invite" zid="zid" d="d" key="key" pw="pw" deny="true" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $ace);
     $array = array('ace' => array('gt' => 'usr', 'right' => 'invite', 'zid' => 'zid', 'd' => 'd', 'key' => 'key', 'pw' => 'pw', 'deny' => true));
     $this->assertEquals($array, $ace->toArray());
 }
Example #6
0
 public function testRevokePermission()
 {
     $ace = new \Zimbra\Mail\Struct\AccountACEinfo(GranteeType::USR(), AceRightType::INVITE(), 'zid', 'd', 'key', 'pw', false);
     $this->_api->revokePermission(array($ace));
     $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:RevokePermissionRequest>' . '<urn1:ace gt="usr" right="invite" zid="zid" d="d" key="key" pw="pw" deny="false" />' . '</urn1:RevokePermissionRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #7
0
 public function testRevokeRights()
 {
     $zid = md5(self::randomString());
     $dir = md5(self::randomString());
     $key = md5(self::randomString());
     $pw = md5(self::randomString());
     $ace = new \Zimbra\Account\Struct\AccountACEInfo(GranteeType::ALL(), AceRightType::VIEW_FREE_BUSY(), $zid, $dir, $key, $pw, true, false);
     $this->_api->revokeRights(array($ace));
     $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:RevokeRightsRequest>' . '<urn1:ace gt="' . GranteeType::ALL() . '" right="' . AceRightType::VIEW_FREE_BUSY() . '" zid="' . $zid . '" d="' . $dir . '" key="' . $key . '" pw="' . $pw . '" deny="true" chkgt="false" />' . '</urn1:RevokeRightsRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #8
0
 public function testRevokeRights()
 {
     $zid = md5(self::randomString());
     $dir = md5(self::randomString());
     $key = md5(self::randomString());
     $pw = md5(self::randomString());
     $ace = new \Zimbra\Account\Struct\AccountACEInfo(GranteeType::ALL(), AceRightType::VIEW_FREE_BUSY(), $zid, $dir, $key, $pw, true, false);
     $req = new \Zimbra\Account\Request\RevokeRights([$ace]);
     $this->assertInstanceOf('Zimbra\\Account\\Request\\Base', $req);
     $this->assertSame([$ace], $req->getAces()->all());
     $req->addAce($ace);
     $this->assertSame([$ace, $ace], $req->getAces()->all());
     $req->getAces()->remove(1);
     $xml = '<?xml version="1.0"?>' . "\n" . '<RevokeRightsRequest>' . '<ace gt="' . GranteeType::ALL() . '" right="' . AceRightType::VIEW_FREE_BUSY() . '" zid="' . $zid . '" d="' . $dir . '" key="' . $key . '" pw="' . $pw . '" deny="true" chkgt="false" />' . '</RevokeRightsRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['RevokeRightsRequest' => ['_jsns' => 'urn:zimbraAccount', 'ace' => [['gt' => GranteeType::ALL()->value(), 'right' => AceRightType::VIEW_FREE_BUSY()->value(), 'zid' => $zid, 'd' => $dir, 'key' => $key, 'pw' => $pw, 'deny' => true, 'chkgt' => false]]]];
     $this->assertEquals($array, $req->toArray());
 }
Example #9
0
 public function testRevokePermission()
 {
     $ace = new \Zimbra\Mail\Struct\AccountACEinfo(GranteeType::USR(), AceRightType::INVITE(), 'zid', 'd', 'key', 'pw', false);
     $req = new \Zimbra\Mail\Request\RevokePermission(array($ace));
     $this->assertInstanceOf('Zimbra\\Mail\\Request\\Base', $req);
     $this->assertSame(array($ace), $req->ace()->all());
     $req->addAce($ace);
     $this->assertSame(array($ace, $ace), $req->ace()->all());
     $req->ace()->remove(1);
     $xml = '<?xml version="1.0"?>' . "\n" . '<RevokePermissionRequest>' . '<ace gt="usr" right="invite" zid="zid" d="d" key="key" pw="pw" deny="false" />' . '</RevokePermissionRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = array('RevokePermissionRequest' => array('_jsns' => 'urn:zimbraMail', 'ace' => array(array('gt' => 'usr', 'right' => 'invite', 'zid' => 'zid', 'd' => 'd', 'key' => 'key', 'pw' => 'pw', 'deny' => false))));
     $this->assertEquals($array, $req->toArray());
 }