public function testIsValid_true_customValidator() { $mutableJwt = new MutableJwt($this->claims, $this->secret, $this->header); $jwt = new Jwt($mutableJwt->encode(), $this->secret); $jwt->addValidator(function () { return true; }); $this->assertTrue($jwt->isValid()); }
public function getMutable() : MutableJwt { $jwt = new MutableJwt($this->getClaims()->get(), null, $this->getHeaders()->get()); if (!is_null($this->secret)) { $jwt->setSecret($this->getSecret()->get()); } $validators = $this->getValidators(); if ($validators->isDefined()) { $jwt->addValidator(...$validators->get()); } return $jwt; }
public function testSetType_lower() { $jwt = new Jwt($this->claims, $this->secret, $this->header); $jwt->setType('jwt'); $this->assertEquals('jwt', $jwt->getHeader('typ')->get()); }