/** * @test * * @covers \Lcobucci\JWT\Signer\Ecdsa\EccAdapter::createSigningHash * @covers \Lcobucci\JWT\Signer\Ecdsa\EccAdapter::generatorPoint * * @uses \Lcobucci\JWT\Signer\Ecdsa\EccAdapter::__construct */ public function createSigningHashShouldReturnTheSignerResult() { $signingHash = gmp_init(1, 10); $generatorPoint = $this->createMock(GeneratorPoint::class); $this->nistCurve->expects($this->once())->method('generator256')->willReturn($generatorPoint); $this->signer->expects($this->once())->method('hashData')->with($generatorPoint, 'sha256', 'testing')->willReturn($signingHash); $adapter = $this->createAdapter(); self::assertSame($signingHash, $adapter->createSigningHash('testing', 'sha256')); }
/** * @test * * @uses Lcobucci\JWT\Signer\Ecdsa::__construct * @uses Lcobucci\JWT\Signer\Key * * @covers Lcobucci\JWT\Signer\Ecdsa::doVerify * @covers Lcobucci\JWT\Signer\Ecdsa::createSigningHash * @covers Lcobucci\JWT\Signer\Ecdsa::extractSignature */ public function doVerifyShouldDelegateToEcdsaSignerUsingPublicKey() { $signer = $this->getSigner(); $key = new Key('testing'); $publicKey = $this->getMock(PublicKeyInterface::class); $this->parser->expects($this->once())->method('getPublicKey')->with($key)->willReturn($publicKey); $this->adapter->expects($this->exactly(3))->method('hexDec')->willReturn('123'); $this->signer->expects($this->once())->method('verify')->with($publicKey, $this->isInstanceOf(Signature::class), $this->isType('string'))->willReturn(true); $this->assertTrue($signer->doVerify('testing', 'testing2', $key)); }