public function setUp() { $this->payload = $this->getMockBuilder('Emarref\\Jwt\\Token\\Payload')->getMock(); $this->token = $this->getMockBuilder('Emarref\\Jwt\\Token')->getMock(); $this->token->expects($this->any())->method('getPayload')->will($this->returnValue($this->payload)); $this->verifier = new ExpirationVerifier(); }
public function testStringAudience() { $audienceClaim = $this->getMockBuilder('Emarref\\Jwt\\Claim\\Audience')->getMock(); $audienceClaim->expects($this->once())->method('getValue')->will($this->returnValue('urn://audienceone')); $this->payload->expects($this->once())->method('findClaimByName')->with(Claim\Audience::NAME)->will($this->returnValue($audienceClaim)); $this->token->expects($this->once())->method('getPayload')->will($this->returnValue($this->payload)); $verifier = new AudienceVerifier('urn://audienceone'); $verifier->verify($this->token); }
public function testSuccess() { $issuerClaim = $this->getMockBuilder('Emarref\\Jwt\\Claim\\Issuer')->getMock(); $issuerClaim->expects($this->once())->method('getValue')->will($this->returnValue('an_issuer')); $this->token->expects($this->once())->method('getPayload')->will($this->returnValue($this->payload)); $this->payload->expects($this->once())->method('findClaimByName')->with(Claim\Issuer::NAME)->will($this->returnValue($issuerClaim)); $verifier = new IssuerVerifier('an_issuer'); $verifier->verify($this->token); }
public function testValidSignature() { $algorithmParameter = $this->getMockBuilder('Emarref\\Jwt\\HeaderParameter\\Algorithm')->getMock(); $algorithmParameter->expects($this->once())->method('getValue')->will($this->returnValue('foo')); $this->header->expects($this->once())->method('findParameterByName')->with(HeaderParameter\Algorithm::NAME)->will($this->returnValue($algorithmParameter)); $this->encryption->expects($this->once())->method('getAlgorithmName')->will($this->returnValue('foo')); $this->encryption->expects($this->once())->method('verify')->will($this->returnValue(true)); $this->signer->expects($this->once())->method('getUnsignedValue')->will($this->returnValue('bar')); $this->token->expects($this->once())->method('getSignature')->will($this->returnValue('bar')); $verifier = new EncryptionVerifierStub($this->encryption, $this->encoder, $this->signer); $verifier->verify($this->token); }