/** * @covers Jwa::getAlgorithmInstance */ public function testGetAlgorithmInstance() { $this->assertInstanceOf('iAchilles\\pjwt\\crypt\\HmacAlgo', Jwa::getAlgorithmInstance(JoseHeader::parseFromArray(['alg' => 'HS256']))); $this->assertInstanceOf('iAchilles\\pjwt\\crypt\\HmacAlgo', Jwa::getAlgorithmInstance(JoseHeader::parseFromArray(['alg' => 'HS384']))); $this->assertInstanceOf('iAchilles\\pjwt\\crypt\\HmacAlgo', Jwa::getAlgorithmInstance(JoseHeader::parseFromArray(['alg' => 'HS512']))); $this->assertInstanceOf('iAchilles\\pjwt\\crypt\\RsassaPkcsAlgo', Jwa::getAlgorithmInstance(JoseHeader::parseFromArray(['alg' => 'RS256']))); $this->assertInstanceOf('iAchilles\\pjwt\\crypt\\RsassaPkcsAlgo', Jwa::getAlgorithmInstance(JoseHeader::parseFromArray(['alg' => 'RS384']))); $this->assertInstanceOf('iAchilles\\pjwt\\crypt\\RsassaPkcsAlgo', Jwa::getAlgorithmInstance(JoseHeader::parseFromArray(['alg' => 'RS512']))); }
/** * @covers JoseHeader::toArray */ public function testToArray() { $headers = ['alg' => 'HS256', 'jku' => 'https://localhost', 'jwk' => [], 'kid' => 'a', 'x5u' => 'https://localhost', 'x5c' => 'a', 'x5t' => 'a', 'x5t#S256' => 'a', 'typ' => 'a', 'cty' => 'a', 'crit' => ['a'], 'a' => 'b']; $header = JoseHeader::parseFromArray($headers); $this->assertEquals($headers, $header->toArray()); }