Пример #1
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);
 }
 public function testGetDelegatedAdminConstraintsApi()
 {
     $name = $this->faker->word;
     $id = $this->faker->word;
     $attr = new NamedElement($name);
     $this->api->getDelegatedAdminConstraints(TargetType::DOMAIN(), $id, $name, [$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:GetDelegatedAdminConstraintsRequest type="' . TargetType::DOMAIN() . '" id="' . $id . '" name="' . $name . '">' . '<urn1:a name="' . $name . '" />' . '</urn1:GetDelegatedAdminConstraintsRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Пример #3
0
 public function testCheckRightsApi()
 {
     $key = $this->faker->word;
     $right1 = $this->faker->word;
     $right2 = $this->faker->word;
     $target = new CheckRightsTargetSpec(TargetType::DOMAIN(), TargetBy::ID(), $key, [$right1, $right2]);
     $this->api->checkRights([$target]);
     $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:CheckRightsRequest>' . '<urn1:target type="' . TargetType::DOMAIN() . '" by="' . TargetBy::ID() . '" key="' . $key . '">' . '<urn1:right>' . $right1 . '</urn1:right>' . '<urn1:right>' . $right2 . '</urn1:right>' . '</urn1:target>' . '</urn1:CheckRightsRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Пример #4
0
 public function testGetGrantsApi()
 {
     $value = $this->faker->word;
     $secret = $this->faker->sha1;
     $target = new EffectiveRightsTargetSelector(TargetType::ACCOUNT(), TargetBy::NAME(), $value);
     $grantee = new GranteeSelector($value, GranteeType::USR(), GranteeBy::ID(), $secret, true);
     $this->api->getGrants($target, $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:GetGrantsRequest>' . '<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:GetGrantsRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Пример #5
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);
 }
Пример #6
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 testEffectiveRightsTargetSelector()
 {
     $value = $this->faker->word;
     $target = new EffectiveRightsTargetSelector(TargetType::DOMAIN(), TargetBy::ID(), $value);
     $this->assertTrue($target->getType()->is('domain'));
     $this->assertSame($value, $target->getValue());
     $this->assertSame('id', $target->getBy()->value());
     $target->setType(TargetType::ACCOUNT())->setBy(TargetBy::NAME());
     $this->assertSame('account', $target->getType()->value());
     $this->assertSame('name', $target->getBy()->value());
     $xml = '<?xml version="1.0"?>' . "\n" . '<target type="' . TargetType::ACCOUNT() . '" by="' . TargetBy::NAME() . '">' . $value . '</target>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $target);
     $array = ['target' => ['type' => TargetType::ACCOUNT()->value(), '_content' => $value, 'by' => TargetBy::NAME()->value()]];
     $this->assertEquals($array, $target->toArray());
 }
 public function testModifyDelegatedAdminConstraintsApi()
 {
     $value = $this->faker->word;
     $min = $this->faker->word;
     $max = $this->faker->word;
     $name = $this->faker->word;
     $id = $this->faker->uuid;
     $values = new ConstraintInfoValues([$value]);
     $constraint = new ConstraintInfo($min, $max, $values);
     $attr = new ConstraintAttr($constraint, $name);
     $this->api->modifyDelegatedAdminConstraints(TargetType::ACCOUNT(), $id, $name, [$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:ModifyDelegatedAdminConstraintsRequest type="' . TargetType::ACCOUNT() . '" id="' . $id . '" name="' . $name . '">' . '<urn1:a name="' . $name . '">' . '<urn1:constraint>' . '<urn1:min>' . $min . '</urn1:min>' . '<urn1:max>' . $max . '</urn1:max>' . '<urn1:values>' . '<urn1:v>' . $value . '</urn1:v>' . '</urn1:values>' . '</urn1:constraint>' . '</urn1:a>' . '</urn1:ModifyDelegatedAdminConstraintsRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
 public function testCheckRightsTargetSpec()
 {
     $key = $this->faker->word;
     $right1 = $this->faker->word;
     $right2 = $this->faker->word;
     $right3 = $this->faker->word;
     $target = new CheckRightsTargetSpec(TargetType::DOMAIN(), TargetBy::ID(), $key, [$right1, $right2]);
     $this->assertTrue($target->getTargetType()->is('domain'));
     $this->assertTrue($target->getTargetBy()->is('id'));
     $this->assertSame($key, $target->getTargetKey());
     $this->assertSame([$right1, $right2], $target->getRights()->all());
     $target->setTargetType(TargetType::ACCOUNT())->setTargetBy(TargetBy::NAME())->setTargetKey($key)->addRight($right3);
     $this->assertTrue($target->getTargetType()->is('account'));
     $this->assertTrue($target->getTargetBy()->is('name'));
     $this->assertSame($key, $target->getTargetKey());
     $this->assertSame([$right1, $right2, $right3], $target->getRights()->all());
     $xml = '<?xml version="1.0"?>' . "\n" . '<target type="' . TargetType::ACCOUNT() . '" by="' . TargetBy::NAME() . '" key="' . $key . '">' . '<right>' . $right1 . '</right>' . '<right>' . $right2 . '</right>' . '<right>' . $right3 . '</right>' . '</target>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $target);
     $array = ['target' => ['type' => TargetType::ACCOUNT()->value(), 'by' => TargetBy::NAME()->value(), 'key' => $key, 'right' => [$right1, $right2, $right3]]];
     $this->assertEquals($array, $target->toArray());
 }
Пример #10
0
 public function testTargetType()
 {
     $values = array('account', 'calresource', 'cos', 'dl', 'group', 'domain', 'server', 'ucservice', 'xmppcomponent', 'zimlet', 'config', 'global');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\TargetType::has($value));
     }
 }
Пример #11
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);
 }
Пример #12
0
 public function testCheckRights()
 {
     $key = self::randomName();
     $right1 = md5(self::randomString());
     $right2 = md5(self::randomString());
     $target = new \Zimbra\Account\Struct\CheckRightsTargetSpec(TargetType::DOMAIN(), TargetBy::ID(), $key, array($right1, $right2));
     $this->_api->checkRights(array($target));
     $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:CheckRightsRequest>' . '<urn1:target type="' . TargetType::DOMAIN() . '" by="' . TargetBy::ID() . '" key="' . $key . '">' . '<urn1:right>' . $right1 . '</urn1:right>' . '<urn1:right>' . $right2 . '</urn1:right>' . '</urn1:target>' . '</urn1:CheckRightsRequest>' . '</env:Body>' . '</env:Envelope>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
 }
Пример #13
0
 public function testCheckRights()
 {
     $key = self::randomName();
     $right1 = self::randomName();
     $right2 = self::randomName();
     $target = new \Zimbra\Account\Struct\CheckRightsTargetSpec(TargetType::DOMAIN(), TargetBy::ID(), $key, [$right1, $right2]);
     $req = new \Zimbra\Account\Request\CheckRights([$target]);
     $this->assertInstanceOf('Zimbra\\Account\\Request\\Base', $req);
     $this->assertSame([$target], $req->getTargets()->all());
     $req->addTarget($target);
     $this->assertSame([$target, $target], $req->getTargets()->all());
     $req->getTargets()->remove(1);
     $xml = '<?xml version="1.0"?>' . "\n" . '<CheckRightsRequest>' . '<target type="' . TargetType::DOMAIN() . '" by="' . TargetBy::ID() . '" key="' . $key . '">' . '<right>' . $right1 . '</right>' . '<right>' . $right2 . '</right>' . '</target>' . '</CheckRightsRequest>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $req);
     $array = ['CheckRightsRequest' => ['_jsns' => 'urn:zimbraAccount', 'target' => [['type' => TargetType::DOMAIN()->value(), 'by' => TargetBy::ID()->value(), 'key' => $key, 'right' => [$right1, $right2]]]]];
     $this->assertEquals($array, $req->toArray());
 }
Пример #14
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());
 }
Пример #15
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());
 }
Пример #16
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());
 }