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());
 }
Ejemplo n.º 2
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);
 }
 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());
 }
 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);
 }
Ejemplo n.º 5
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());
 }
 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());
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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());
 }