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 #2
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 #3
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 #4
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 #5
0
 public function testGranteeBy()
 {
     $values = array('id', 'name');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\GranteeBy::has($value));
     }
 }
Example #6
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());
 }