public function testDistributionListAction()
 {
     $name = $this->faker->word;
     $value = $this->faker->word;
     $member = $this->faker->word;
     $subsReq = new DistributionListSubscribeReq(DLSubscribeOp::SUBSCRIBE(), $value, true);
     $owner = new DistributionListGranteeSelector(GranteeType::USR(), DLGranteeBy::ID(), $value);
     $grantee = new DistributionListGranteeSelector(GranteeType::ALL(), DLGranteeBy::NAME(), $value);
     $right = new DistributionListRightSpec($name, [$grantee]);
     $attr = new KeyValuePair($name, $value);
     $dl = new DistributionListAction(Operation::MODIFY(), $name, $subsReq, [$member], [$owner], [$right]);
     $this->assertTrue($dl->getOp()->is('modify'));
     $this->assertSame($name, $dl->getNewName());
     $this->assertSame($subsReq, $dl->getSubsReq());
     $this->assertSame([$member], $dl->getMembers()->all());
     $this->assertSame([$owner], $dl->getOwners()->all());
     $this->assertSame([$right], $dl->getRights()->all());
     $dl = new DistributionListAction(Operation::MODIFY());
     $dl->setOp(Operation::DELETE())->setNewName($name)->setSubsReq($subsReq)->addMember($member)->addOwner($owner)->addRight($right)->addAttr($attr);
     $this->assertTrue($dl->getOp()->is('delete'));
     $this->assertSame($name, $dl->getNewName());
     $this->assertSame($subsReq, $dl->getSubsReq());
     $this->assertSame([$member], $dl->getMembers()->all());
     $this->assertSame([$owner], $dl->getOwners()->all());
     $this->assertSame([$right], $dl->getRights()->all());
     $xml = '<?xml version="1.0"?>' . "\n" . '<action op="' . Operation::DELETE() . '">' . '<newName>' . $name . '</newName>' . '<subsReq op="' . DLSubscribeOp::SUBSCRIBE() . '" bccOwners="true">' . $value . '</subsReq>' . '<a n="' . $name . '">' . $value . '</a>' . '<dlm>' . $member . '</dlm>' . '<owner type="' . GranteeType::USR() . '" by="' . DLGranteeBy::ID() . '">' . $value . '</owner>' . '<right right="' . $name . '">' . '<grantee type="' . GranteeType::ALL() . '" by="' . DLGranteeBy::NAME() . '">' . $value . '</grantee>' . '</right>' . '</action>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $dl);
     $array = ['action' => ['op' => Operation::DELETE()->value(), 'newName' => $name, 'subsReq' => ['op' => DLSubscribeOp::SUBSCRIBE()->value(), '_content' => $value, 'bccOwners' => true], 'dlm' => [$member], 'owner' => [['type' => GranteeType::USR()->value(), '_content' => $value, 'by' => DLGranteeBy::ID()->value()]], 'right' => [['right' => $name, 'grantee' => [['type' => GranteeType::ALL()->value(), '_content' => $value, 'by' => DLGranteeBy::NAME()->value()]]]], 'a' => [['n' => $name, '_content' => $value]]]];
     $this->assertEquals($array, $dl->toArray());
 }
 public function testActionGrantSelector()
 {
     $rights = $this->faker->word;
     $zimbraId = $this->faker->uuid;
     $displayName = $this->faker->word;
     $args = $this->faker->word;
     $password = $this->faker->word;
     $accessKey = $this->faker->word;
     $grant = new ActionGrantSelector($rights, GranteeType::USR(), $zimbraId, $displayName, $args, $password, $accessKey);
     $this->assertSame($rights, $grant->getRights());
     $this->assertTrue($grant->getGranteeType()->is('usr'));
     $this->assertSame($zimbraId, $grant->getZimbraId());
     $this->assertSame($displayName, $grant->getDisplayName());
     $this->assertSame($args, $grant->getArgs());
     $this->assertSame($password, $grant->getPassword());
     $this->assertSame($accessKey, $grant->getAccessKey());
     $grant->setRights($rights)->setGranteeType(GranteeType::USR())->setZimbraId($zimbraId)->setDisplayName($displayName)->setArgs($args)->setPassword($password)->setAccessKey($accessKey);
     $this->assertSame($rights, $grant->getRights());
     $this->assertTrue($grant->getGranteeType()->is('usr'));
     $this->assertSame($zimbraId, $grant->getZimbraId());
     $this->assertSame($displayName, $grant->getDisplayName());
     $this->assertSame($args, $grant->getArgs());
     $this->assertSame($password, $grant->getPassword());
     $this->assertSame($accessKey, $grant->getAccessKey());
     $xml = '<?xml version="1.0"?>' . "\n" . '<grant perm="' . $rights . '" gt="' . GranteeType::USR() . '" zid="' . $zimbraId . '" d="' . $displayName . '" args="' . $args . '" pw="' . $password . '" key="' . $accessKey . '" />';
     $this->assertXmlStringEqualsXmlString($xml, (string) $grant);
     $array = array('grant' => array('perm' => $rights, 'gt' => GranteeType::USR()->value(), 'zid' => $zimbraId, 'd' => $displayName, 'args' => $args, 'pw' => $password, 'key' => $accessKey));
     $this->assertEquals($array, $grant->toArray());
 }
 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());
 }
 public function testFolderActionSelector()
 {
     $id = $this->faker->uuid;
     $name = $this->faker->word;
     $lifetime = $this->faker->word;
     $policy = new Policy(Type::SYSTEM(), $id, $name, $lifetime);
     $keep = new RetentionPolicyKeep([$policy]);
     $policy = new Policy(Type::USER(), $id, $name, $lifetime);
     $purge = new RetentionPolicyPurge([$policy]);
     $retentionPolicy = new RetentionPolicy($keep, $purge);
     $perm = $this->faker->word;
     $zid = $this->faker->uuid;
     $display = $this->faker->word;
     $args = $this->faker->word;
     $pw = $this->faker->word;
     $key = $this->faker->word;
     $grant = new ActionGrantSelector($perm, GranteeType::USR(), $zid, $display, $args, $pw, $key);
     $acl = new FolderActionSelectorAcl([$grant]);
     $tcon = $this->faker->word;
     $tag = mt_rand(1, 100);
     $folder = $this->faker->word;
     $rgb = $this->faker->hexcolor;
     $color = mt_rand(1, 127);
     $flags = $this->faker->word;
     $tags = $this->faker->word;
     $tagNames = $this->faker->word;
     $url = $this->faker->word;
     $gt = $this->faker->word;
     $view = $this->faker->word;
     $numDays = mt_rand(1, 100);
     $action = new FolderActionSelector(FolderActionOp::READ(), $id, $tcon, $tag, $folder, $rgb, $color, $name, $flags, $tags, $tagNames, $grant, $acl, $retentionPolicy, true, $url, true, $zid, $gt, $view, $numDays);
     $this->assertTrue($action->getOperation()->is('read'));
     $this->assertSame($grant, $action->getGrant());
     $this->assertSame($acl, $action->getAcl());
     $this->assertSame($retentionPolicy, $action->getRetentionPolicy());
     $this->assertTrue($action->getRecursive());
     $this->assertSame($url, $action->getUrl());
     $this->assertTrue($action->getExcludeFreeBusy());
     $this->assertSame($zid, $action->getZimbraId());
     $this->assertSame($gt, $action->getGrantType());
     $this->assertSame($view, $action->getView());
     $this->assertSame($numDays, $action->getNumDays());
     $action->setOperation(FolderActionOp::READ())->setGrant($grant)->setAcl($acl)->setRetentionPolicy($retentionPolicy)->setRecursive(true)->setUrl($url)->setExcludeFreeBusy(true)->setZimbraId($zid)->setGrantType($gt)->setView($view)->setNumDays($numDays);
     $this->assertTrue($action->getOperation()->is('read'));
     $this->assertSame($grant, $action->getGrant());
     $this->assertSame($acl, $action->getAcl());
     $this->assertSame($retentionPolicy, $action->getRetentionPolicy());
     $this->assertTrue($action->getRecursive());
     $this->assertSame($url, $action->getUrl());
     $this->assertTrue($action->getExcludeFreeBusy());
     $this->assertSame($zid, $action->getZimbraId());
     $this->assertSame($gt, $action->getGrantType());
     $this->assertSame($view, $action->getView());
     $this->assertSame($numDays, $action->getNumDays());
     $xml = '<?xml version="1.0"?>' . "\n" . '<action op="' . FolderActionOp::READ() . '" id="' . $id . '" tcon="' . $tcon . '" tag="' . $tag . '" l="' . $folder . '" rgb="' . $rgb . '" color="' . $color . '" name="' . $name . '" f="' . $flags . '" t="' . $tags . '" tn="' . $tagNames . '" recursive="true" url="' . $url . '" excludeFreeBusy="true" zid="' . $zid . '" gt="' . $gt . '" view="' . $view . '" numDays="' . $numDays . '">' . '<grant perm="' . $perm . '" gt="' . GranteeType::USR() . '" zid="' . $zid . '" d="' . $display . '" args="' . $args . '" pw="' . $pw . '" key="' . $key . '" />' . '<acl>' . '<grant perm="' . $perm . '" gt="' . GranteeType::USR() . '" zid="' . $zid . '" d="' . $display . '" args="' . $args . '" pw="' . $pw . '" key="' . $key . '" />' . '</acl>' . '<retentionPolicy>' . '<keep>' . '<policy type="' . Type::SYSTEM() . '" id="' . $id . '" name="' . $name . '" lifetime="' . $lifetime . '" />' . '</keep>' . '<purge>' . '<policy type="' . Type::USER() . '" id="' . $id . '" name="' . $name . '" lifetime="' . $lifetime . '" />' . '</purge>' . '</retentionPolicy>' . '</action>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $action);
     $array = array('action' => array('op' => FolderActionOp::READ()->value(), 'id' => $id, 'tcon' => $tcon, 'tag' => $tag, 'l' => $folder, 'rgb' => $rgb, 'color' => $color, 'name' => $name, 'f' => $flags, 't' => $tags, 'tn' => $tagNames, 'recursive' => true, 'url' => $url, 'excludeFreeBusy' => true, 'zid' => $zid, 'gt' => $gt, 'view' => $view, 'numDays' => $numDays, 'grant' => array('perm' => $perm, 'gt' => GranteeType::USR()->value(), 'zid' => $zid, 'd' => $display, 'args' => $args, 'pw' => $pw, 'key' => $key), 'acl' => array('grant' => array(array('perm' => $perm, 'gt' => GranteeType::USR()->value(), 'zid' => $zid, 'd' => $display, 'args' => $args, 'pw' => $pw, 'key' => $key))), 'retentionPolicy' => array('keep' => array('policy' => array(array('type' => Type::SYSTEM()->value(), 'id' => $id, 'name' => $name, 'lifetime' => $lifetime))), 'purge' => array('policy' => array(array('type' => Type::USER()->value(), 'id' => $id, 'name' => $name, 'lifetime' => $lifetime))))));
     $this->assertEquals($array, $action->toArray());
 }
 public function testGetAllEffectiveRightsApi()
 {
     $value = $this->faker->word;
     $secret = $this->faker->word;
     $grantee = new GranteeSelector($value, GranteeType::USR(), GranteeBy::ID(), $secret, true);
     $this->api->getAllEffectiveRights($grantee, true);
     $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:GetAllEffectiveRightsRequest expandAllAttrs="true">' . '<urn1:grantee type="' . GranteeType::USR() . '" by="' . GranteeBy::ID() . '" secret="' . $secret . '" all="true">' . $value . '</urn1:grantee>' . '</urn1:GetAllEffectiveRightsRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #6
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 #7
0
 public function testRevokeRightApi()
 {
     $value = $this->faker->word;
     $secret = $this->faker->word;
     $target = new EffectiveRightsTargetSelector(TargetType::ACCOUNT(), TargetBy::NAME(), $value);
     $grantee = new GranteeSelector($value, GranteeType::USR(), GranteeBy::ID(), $secret, true);
     $right = new RightModifierInfo($value, true, false, false, true);
     $this->api->revokeRight($target, $grantee, $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:zimbraAdmin">' . '<env:Body>' . '<urn1:RevokeRightRequest>' . '<urn1:target type="' . TargetType::ACCOUNT() . '" by="' . TargetBy::NAME() . '">' . $value . '</urn1:target>' . '<urn1:grantee type="' . GranteeType::USR() . '" by="' . GranteeBy::ID() . '" secret="' . $secret . '" all="true">' . $value . '</urn1:grantee>' . '<urn1:right deny="true" canDelegate="false" disinheritSubGroups="false" subDomain="true">' . $value . '</urn1:right>' . '</urn1:RevokeRightRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #8
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);
 }
 public function testDistributionListGranteeSelector()
 {
     $value = $this->faker->word;
     $grantee = new DistributionListGranteeSelector(GranteeType::ALL(), DLGranteeBy::ID(), $value);
     $this->assertTrue($grantee->getType()->is('all'));
     $this->assertTrue($grantee->getBy()->is('id'));
     $this->assertSame($value, $grantee->getValue());
     $grantee->setType(GranteeType::USR())->setBy(DLGranteeBy::NAME());
     $this->assertTrue($grantee->getType()->is('usr'));
     $this->assertTrue($grantee->getBy()->is('name'));
     $xml = '<?xml version="1.0"?>' . "\n" . '<grantee type="' . GranteeType::USR() . '" by="' . DLGranteeBy::NAME() . '">' . $value . '</grantee>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $grantee);
     $array = ['grantee' => ['type' => GranteeType::USR()->value(), '_content' => $value, 'by' => DLGranteeBy::NAME()->value()]];
     $this->assertEquals($array, $grantee->toArray());
 }
Example #10
0
 public function testCheckRightApi()
 {
     $key = $this->faker->word;
     $value = $this->faker->word;
     $secret = $this->faker->word;
     $right = $this->faker->word;
     $attr = new KeyValuePair($key, $value);
     $target = new EffectiveRightsTargetSelector(TargetType::ACCOUNT(), TargetBy::NAME(), $value);
     $grantee = new GranteeSelector($value, GranteeType::USR(), GranteeBy::ID(), $secret, true);
     $this->api->checkRight($target, $grantee, $right, [$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:CheckRightRequest>' . '<urn1:target type="' . TargetType::ACCOUNT() . '" by="' . TargetBy::NAME() . '">' . $value . '</urn1:target>' . '<urn1:grantee type="' . GranteeType::USR() . '" by="' . GranteeBy::ID() . '" secret="' . $secret . '" all="true">' . $value . '</urn1:grantee>' . '<urn1:right>' . $right . '</urn1:right>' . '<urn1:a n="' . $key . '">' . $value . '</urn1:a>' . '</urn1:CheckRightRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #11
0
 public function testNewFolderSpec()
 {
     $rights = $this->faker->word;
     $zimbraId = $this->faker->uuid;
     $displayName = $this->faker->word;
     $args = $this->faker->word;
     $password = $this->faker->word;
     $accessKey = $this->faker->word;
     $name = $this->faker->word;
     $f = $this->faker->word;
     $rgb = $this->faker->hexcolor;
     $url = $this->faker->word;
     $l = $this->faker->word;
     $color = mt_rand(1, 127);
     $grant = new ActionGrantSelector($rights, GranteeType::USR(), $zimbraId, $displayName, $args, $password, $accessKey);
     $acl = new NewFolderSpecAcl([$grant]);
     $folder = new NewFolderSpec($name, SearchType::TASK(), $f, $color, $rgb, $url, $l, true, true, $acl);
     $this->assertSame($name, $folder->getName());
     $this->assertSame($acl, $folder->getGrants());
     $this->assertTrue($folder->getView()->is('task'));
     $this->assertSame($f, $folder->getFlags());
     $this->assertSame($color, $folder->getColor());
     $this->assertSame($rgb, $folder->getRgb());
     $this->assertSame($url, $folder->getUrl());
     $this->assertSame($l, $folder->getParentFolderId());
     $this->assertTrue($folder->getFetchIfExists());
     $this->assertTrue($folder->getSyncToUrl());
     $folder = new NewFolderSpec('name');
     $folder->setName($name)->setGrants($acl)->setView(SearchType::TASK())->setFlags($f)->setColor($color)->setRgb($rgb)->setUrl($url)->setParentFolderId($l)->setFetchIfExists(true)->setSyncToUrl(true);
     $this->assertSame($name, $folder->getName());
     $this->assertSame($acl, $folder->getGrants());
     $this->assertTrue($folder->getView()->is('task'));
     $this->assertSame($f, $folder->getFlags());
     $this->assertSame($color, $folder->getColor());
     $this->assertSame($rgb, $folder->getRgb());
     $this->assertSame($url, $folder->getUrl());
     $this->assertSame($l, $folder->getParentFolderId());
     $this->assertTrue($folder->getFetchIfExists());
     $this->assertTrue($folder->getSyncToUrl());
     $xml = '<?xml version="1.0"?>' . "\n" . '<folder name="' . $name . '" view="' . SearchType::TASK() . '" f="' . $f . '" color="' . $color . '" rgb="' . $rgb . '" url="' . $url . '" l="' . $l . '" fie="true" sync="true">' . '<acl>' . '<grant perm="' . $rights . '" gt="' . GranteeType::USR() . '" zid="' . $zimbraId . '" d="' . $displayName . '" args="' . $args . '" pw="' . $password . '" key="' . $accessKey . '" />' . '</acl>' . '</folder>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $folder);
     $array = array('folder' => array('name' => $name, 'view' => SearchType::TASK()->value(), 'f' => $f, 'color' => $color, 'rgb' => $rgb, 'url' => $url, 'l' => $l, 'fie' => true, 'sync' => true, 'acl' => array('grant' => array(array('perm' => $rights, 'gt' => GranteeType::USR()->value(), 'zid' => $zimbraId, 'd' => $displayName, 'args' => $args, 'pw' => $password, 'key' => $accessKey)))));
     $this->assertEquals($array, $folder->toArray());
 }
Example #12
0
 public function testActionGrantSelector()
 {
     $rights = $this->faker->word;
     $zimbraId = $this->faker->uuid;
     $displayName = $this->faker->word;
     $args = $this->faker->word;
     $password = $this->faker->word;
     $accessKey = $this->faker->word;
     $grant = new ActionGrantSelector($rights, GranteeType::USR(), $zimbraId, $displayName, $args, $password, $accessKey);
     $acl = new NewFolderSpecAcl(array($grant));
     $this->assertSame([$grant], $acl->getGrants()->all());
     $acl->addGrant($grant);
     $this->assertSame([$grant, $grant], $acl->getGrants()->all());
     $acl->getGrants()->remove(1);
     $xml = '<?xml version="1.0"?>' . "\n" . '<acl>' . '<grant perm="' . $rights . '" gt="' . GranteeType::USR() . '" zid="' . $zimbraId . '" d="' . $displayName . '" args="' . $args . '" pw="' . $password . '" key="' . $accessKey . '" />' . '</acl>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $acl);
     $array = array('acl' => array('grant' => array(array('perm' => $rights, 'gt' => GranteeType::USR()->value(), 'zid' => $zimbraId, 'd' => $displayName, 'args' => $args, 'pw' => $password, 'key' => $accessKey))));
     $this->assertEquals($array, $acl->toArray());
 }
 public function testFolderActionSelectorAcl()
 {
     $perm = $this->faker->word;
     $zid = $this->faker->word;
     $display = $this->faker->word;
     $args = $this->faker->word;
     $pw = $this->faker->word;
     $key = $this->faker->word;
     $grant = new ActionGrantSelector($perm, GranteeType::USR(), $zid, $display, $args, $pw, $key);
     $acl = new FolderActionSelectorAcl([$grant]);
     $this->assertSame([$grant], $acl->getGrants()->all());
     $acl->addGrant($grant);
     $this->assertSame([$grant, $grant], $acl->getGrants()->all());
     $acl->getGrants()->remove(1);
     $xml = '<?xml version="1.0"?>' . "\n" . '<acl>' . '<grant perm="' . $perm . '" gt="' . GranteeType::USR() . '" zid="' . $zid . '" d="' . $display . '" args="' . $args . '" pw="' . $pw . '" key="' . $key . '" />' . '</acl>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $acl);
     $array = array('acl' => array('grant' => array(array('perm' => $perm, 'gt' => GranteeType::USR()->value(), 'zid' => $zid, 'd' => $display, 'args' => $args, 'pw' => $pw, 'key' => $key))));
     $this->assertEquals($array, $acl->toArray());
 }
 public function testDistributionListActionApi()
 {
     $name = $this->faker->word;
     $value = $this->faker->word;
     $member = $this->faker->word;
     $subsReq = new DistributionListSubscribeReq(DLSubscribeOp::SUBSCRIBE(), $value, true);
     $owner = new DistributionListGranteeSelector(GranteeType::USR(), DLGranteeBy::ID(), $value);
     $grantee = new DistributionListGranteeSelector(GranteeType::ALL(), DLGranteeBy::NAME(), $value);
     $right = new DistributionListRightSpec($name, [$grantee]);
     $a = new KeyValuePair($name, $value);
     $action = new DLAction(Operation::MODIFY(), $name, $subsReq, [$member], [$owner], [$right], [$a]);
     $dl = new DistributionListSelector(DLBy::NAME(), $value);
     $attr = new Attr($name, $value, true);
     $this->api->distributionListAction($dl, $action, [$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:zimbraAccount">' . '<env:Body>' . '<urn1:DistributionListActionRequest>' . '<urn1:dl by="' . DLBy::NAME() . '">' . $value . '</urn1:dl>' . '<urn1:action op="' . Operation::MODIFY() . '">' . '<urn1:newName>' . $name . '</urn1:newName>' . '<urn1:subsReq op="' . DLSubscribeOp::SUBSCRIBE() . '" bccOwners="true">' . $value . '</urn1:subsReq>' . '<urn1:a n="' . $name . '">' . $value . '</urn1:a>' . '<urn1:dlm>' . $member . '</urn1:dlm>' . '<urn1:owner type="' . GranteeType::USR() . '" by="' . DLGranteeBy::ID() . '">' . $value . '</urn1:owner>' . '<urn1:right right="' . $name . '">' . '<urn1:grantee type="' . GranteeType::ALL() . '" by="' . DLGranteeBy::NAME() . '">' . $value . '</urn1:grantee>' . '</urn1:right>' . '</urn1:action>' . '<urn1:a name="' . $name . '" pd="true">' . $value . '</urn1:a>' . '</urn1:DistributionListActionRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testDistributionListRightSpec()
 {
     $name = $this->faker->word;
     $value1 = $this->faker->word;
     $value2 = $this->faker->word;
     $value3 = $this->faker->word;
     $grantee1 = new DistributionListGranteeSelector(GranteeType::ALL(), DLGranteeBy::NAME(), $value1);
     $grantee2 = new DistributionListGranteeSelector(GranteeType::USR(), DLGranteeBy::ID(), $value2);
     $grantee3 = new DistributionListGranteeSelector(GranteeType::GRP(), DLGranteeBy::NAME(), $value3);
     $right = new DistributionListRightSpec($name, [$grantee1, $grantee2]);
     $this->assertSame($name, $right->getRight());
     $this->assertSame([$grantee1, $grantee2], $right->getGrantees()->all());
     $right->setRight($name)->addGrantee($grantee3);
     $this->assertSame($name, $right->getRight());
     $this->assertSame([$grantee1, $grantee2, $grantee3], $right->getGrantees()->all());
     $xml = '<?xml version="1.0"?>' . "\n" . '<right right="' . $name . '">' . '<grantee type="' . GranteeType::ALL() . '" by="' . DLGranteeBy::NAME() . '">' . $value1 . '</grantee>' . '<grantee type="' . GranteeType::USR() . '" by="' . DLGranteeBy::ID() . '">' . $value2 . '</grantee>' . '<grantee type="' . GranteeType::GRP() . '" by="' . DLGranteeBy::NAME() . '">' . $value3 . '</grantee>' . '</right>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $right);
     $array = ['right' => ['right' => $name, 'grantee' => [['type' => GranteeType::ALL()->value(), '_content' => $value1, 'by' => DLGranteeBy::NAME()->value()], ['type' => GranteeType::USR()->value(), '_content' => $value2, 'by' => DLGranteeBy::ID()->value()], ['type' => GranteeType::GRP()->value(), '_content' => $value3, 'by' => DLGranteeBy::NAME()->value()]]]];
     $this->assertEquals($array, $right->toArray());
 }
Example #16
0
 public function testGranteeSelector()
 {
     $value = $this->faker->word;
     $secret = $this->faker->word;
     $grantee = new GranteeSelector($value, GranteeType::ALL(), GranteeBy::NAME(), $secret, false);
     $this->assertSame('all', $grantee->getType()->value());
     $this->assertSame('name', $grantee->getBy()->value());
     $this->assertSame($value, $grantee->getValue());
     $this->assertSame($secret, $grantee->getSecret());
     $this->assertFalse($grantee->getAll());
     $grantee->setType(GranteeType::USR())->setBy(GranteeBy::ID())->setSecret($secret)->setAll(true);
     $this->assertSame('usr', $grantee->getType()->value());
     $this->assertSame('id', $grantee->getBy()->value());
     $this->assertSame($secret, $grantee->getSecret());
     $this->assertTrue($grantee->getAll());
     $xml = '<?xml version="1.0"?>' . "\n" . '<grantee type="' . GranteeType::USR() . '" by="' . GranteeBy::ID() . '" secret="' . $secret . '" all="true">' . $value . '</grantee>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $grantee);
     $array = ['grantee' => ['_content' => $value, 'type' => GranteeType::USR()->value(), 'by' => GranteeBy::ID()->value(), 'secret' => $secret, 'all' => true]];
     $this->assertEquals($array, $grantee->toArray());
 }
Example #17
0
 public function testCreateFolderApi()
 {
     $rights = $this->faker->word;
     $zimbraId = $this->faker->uuid;
     $displayName = $this->faker->word;
     $args = $this->faker->word;
     $password = $this->faker->word;
     $accessKey = $this->faker->word;
     $name = $this->faker->word;
     $f = $this->faker->word;
     $rgb = $this->faker->hexcolor;
     $url = $this->faker->word;
     $l = $this->faker->word;
     $color = mt_rand(1, 127);
     $grant = new ActionGrantSelector($rights, GranteeType::USR(), $zimbraId, $displayName, $args, $password, $accessKey);
     $acl = new NewFolderSpecAcl([$grant]);
     $folder = new NewFolderSpec($name, SearchType::TASK(), $f, $color, $rgb, $url, $l, true, true, $acl);
     $this->api->createFolder($folder);
     $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:CreateFolderRequest>' . '<urn1:folder name="' . $name . '" view="' . SearchType::TASK() . '" f="' . $f . '" color="' . $color . '" rgb="' . $rgb . '" url="' . $url . '" l="' . $l . '" fie="true" sync="true">' . '<urn1:acl>' . '<urn1:grant perm="' . $rights . '" gt="' . GranteeType::USR() . '" zid="' . $zimbraId . '" d="' . $displayName . '" args="' . $args . '" pw="' . $password . '" key="' . $accessKey . '" />' . '</urn1:acl>' . '</urn1:folder>' . '</urn1:CreateFolderRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #18
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());
 }
Example #19
0
 public function testNewFolderSpecAcl()
 {
     $grant = new \Zimbra\Mail\Struct\ActionGrantSelector('perm', GranteeType::USR(), 'zid', 'd', 'args', 'pw', 'key');
     $acl = new \Zimbra\Mail\Struct\NewFolderSpecAcl(array($grant));
     $this->assertSame(array($grant), $acl->grant()->all());
     $acl->addGrant($grant);
     $this->assertSame(array($grant, $grant), $acl->grant()->all());
     $acl->grant()->remove(1);
     $xml = '<?xml version="1.0"?>' . "\n" . '<acl>' . '<grant perm="perm" gt="usr" zid="zid" d="d" args="args" pw="pw" key="key" />' . '</acl>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $acl);
     $array = array('acl' => array('grant' => array(array('perm' => 'perm', 'gt' => 'usr', 'zid' => 'zid', 'd' => 'd', 'args' => 'args', 'pw' => 'pw', 'key' => 'key'))));
     $this->assertEquals($array, $acl->toArray());
 }
Example #20
0
 public function testRevokeRight()
 {
     $value = self::randomName();
     $secret = self::randomName();
     $target = new \Zimbra\Admin\Struct\EffectiveRightsTargetSelector(TargetType::ACCOUNT(), TargetBy::NAME(), $value);
     $grantee = new \Zimbra\Admin\Struct\GranteeSelector($value, GranteeType::USR(), GranteeBy::ID(), $secret, true);
     $right = new \Zimbra\Admin\Struct\RightModifierInfo($value, true, false, false, true);
     $req = new \Zimbra\Admin\Request\RevokeRight($target, $grantee, $right);
     $this->assertInstanceOf('Zimbra\\Admin\\Request\\Base', $req);
     $this->assertSame($target, $req->getTarget());
     $this->assertSame($grantee, $req->getGrantee());
     $this->assertSame($right, $req->getRight());
     $req->setTarget($target)->setGrantee($grantee)->setRight($right);
     $this->assertSame($target, $req->getTarget());
     $this->assertSame($grantee, $req->getGrantee());
     $this->assertSame($right, $req->getRight());
     $xml = '<?xml version="1.0"?>' . "\n" . '<RevokeRightRequest>' . '<target type="' . TargetType::ACCOUNT() . '" by="' . TargetBy::NAME() . '">' . $value . '</target>' . '<grantee type="' . GranteeType::USR() . '" by="' . GranteeBy::ID() . '" secret="' . $secret . '" all="true">' . $value . '</grantee>' . '<right deny="true" canDelegate="false" disinheritSubGroups="false" subDomain="true">' . $value . '</right>' . '</RevokeRightRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['RevokeRightRequest' => ['_jsns' => 'urn:zimbraAdmin', 'target' => ['type' => TargetType::ACCOUNT()->value(), '_content' => $value, 'by' => TargetBy::NAME()->value()], 'grantee' => ['_content' => $value, 'type' => GranteeType::USR()->value(), 'by' => GranteeBy::ID()->value(), 'secret' => $secret, 'all' => true], 'right' => ['deny' => true, 'canDelegate' => false, 'disinheritSubGroups' => false, 'subDomain' => true, '_content' => $value]]];
     $this->assertEquals($array, $req->toArray());
 }
Example #21
0
 public function testGranteeType()
 {
     $values = array('usr', 'grp', 'egp', 'all', 'dom', 'gst', 'key', 'pub', 'email');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\GranteeType::has($value));
     }
 }
Example #22
0
 public function testFolderActionApi()
 {
     $id = $this->faker->uuid;
     $name = $this->faker->word;
     $lifetime = $this->faker->word;
     $policy = new Policy(Type::SYSTEM(), $id, $name, $lifetime);
     $keep = new RetentionPolicyKeep([$policy]);
     $policy = new Policy(Type::USER(), $id, $name, $lifetime);
     $purge = new RetentionPolicyPurge([$policy]);
     $retentionPolicy = new RetentionPolicy($keep, $purge);
     $perm = $this->faker->word;
     $zid = $this->faker->uuid;
     $display = $this->faker->word;
     $args = $this->faker->word;
     $pw = $this->faker->word;
     $key = $this->faker->word;
     $grant = new ActionGrantSelector($perm, GranteeType::USR(), $zid, $display, $args, $pw, $key);
     $acl = new FolderActionSelectorAcl([$grant]);
     $tcon = $this->faker->word;
     $tag = mt_rand(1, 100);
     $folder = $this->faker->word;
     $rgb = $this->faker->hexcolor;
     $color = mt_rand(1, 127);
     $flags = $this->faker->word;
     $tags = $this->faker->word;
     $tagNames = $this->faker->word;
     $url = $this->faker->word;
     $gt = $this->faker->word;
     $view = $this->faker->word;
     $numDays = mt_rand(1, 100);
     $action = new FolderActionSelector(FolderActionOp::READ(), $id, $tcon, $tag, $folder, $rgb, $color, $name, $flags, $tags, $tagNames, $grant, $acl, $retentionPolicy, true, $url, true, $zid, $gt, $view, $numDays);
     $this->api->folderAction($action);
     $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:FolderActionRequest>' . '<urn1:action op="' . FolderActionOp::READ() . '" id="' . $id . '" tcon="' . $tcon . '" tag="' . $tag . '" l="' . $folder . '" rgb="' . $rgb . '" color="' . $color . '" name="' . $name . '" f="' . $flags . '" t="' . $tags . '" tn="' . $tagNames . '" recursive="true" url="' . $url . '" excludeFreeBusy="true" zid="' . $zid . '" gt="' . $gt . '" view="' . $view . '" numDays="' . $numDays . '">' . '<urn1:grant perm="' . $perm . '" gt="' . GranteeType::USR() . '" zid="' . $zid . '" d="' . $display . '" args="' . $args . '" pw="' . $pw . '" key="' . $key . '" />' . '<urn1:acl>' . '<urn1:grant perm="' . $perm . '" gt="' . GranteeType::USR() . '" zid="' . $zid . '" d="' . $display . '" args="' . $args . '" pw="' . $pw . '" key="' . $key . '" />' . '</urn1:acl>' . '<urn1:retentionPolicy>' . '<urn1:keep>' . '<urn1:policy type="' . Type::SYSTEM() . '" id="' . $id . '" name="' . $name . '" lifetime="' . $lifetime . '" />' . '</urn1:keep>' . '<urn1:purge>' . '<urn1:policy type="' . Type::USER() . '" id="' . $id . '" name="' . $name . '" lifetime="' . $lifetime . '" />' . '</urn1:purge>' . '</urn1:retentionPolicy>' . '</urn1:action>' . '</urn1:FolderActionRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Example #23
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 #24
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 #25
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());
 }