Esempio n. 1
0
 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());
 }
Esempio n. 2
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);
 }
Esempio n. 3
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());
 }
Esempio n. 4
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);
 }
Esempio n. 5
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());
 }