示例#1
0
 /**
  * @param Password $password
  * @param bool $allowOverwrite
  */
 public function store(Password $password, $allowOverwrite = false)
 {
     if (!$allowOverwrite && $this->get($password->getId())) {
         throw new PhPsstException('The ID already exists', PhPsstException::ID_IS_ALREADY_TAKEN);
     }
     $this->client->set($password->getId(), $password->getJson());
     $this->client->expireat($password->getId(), $password->getTtl());
 }
示例#2
0
 /**
  * @covers PhPsst\Storage\Storage::getPasswordFromJson
  */
 public function testGetPasswordFromJson()
 {
     $storage = new TestStorage();
     $password = new Password('secretId', 'password', strtotime('+1 hour'), 30);
     $jsonData = $password->getJson();
     $returnedPassword = $storage->getPasswordFromJson($jsonData);
     $this->assertEquals($password->getId(), $returnedPassword->getId());
     $this->assertEquals($password->getPassword(), $returnedPassword->getPassword());
     $this->assertEquals($password->getTtl(), $returnedPassword->getTtl());
     $this->assertEquals($password->getViews(), $returnedPassword->getViews());
 }
示例#3
0
 /**
  * @covers PhPsst\Password::getTtl
  */
 public function testGetTtl()
 {
     $this->assertEquals(123, $this->password->getTtl());
 }