<?php

declare(strict_types=1);

/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014-2018 Spomky-Labs
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

namespace Jose\Component\KeyManagement\Tests;

use Base64Url\Base64Url;
use Jose\Component\Core\JWK;
use Jose\Component\KeyManagement\JWKFactory;
use PHPUnit\Framework\TestCase;

/**
 * @group JWKFactory
 * @group Unit
 */
class JWKFactoryTest extends TestCase
{
    /**
     * @test
     */
    public function iCanLoadAP12CertificateThatContainsARSAKey()
    {
        $result = JWKFactory::createFromPKCS12CertificateFile(__DIR__.'/P12/CertRSA.p12', 'certRSA');

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals([
            'kty' => 'RSA',
            'n' => 'acqZqFSLArU71p9yp8ZH1nDfi5g0TLgPCgAYESrfb-DB0_F89LUSSukRRkCjNCuJqp6j6jpe4VmJ2YzGiBV3eoMqORIdUmQ3XlKKX_ONM3oWhZZoFS_2s1RLFl1faXORe4JSJIN9gt_4EpXoKTjX1gftTcFOLrXPgODEwjAYll0',
            'e' => 'AQAB',
            'd' => 'F5wRgtGrXGVZ_2ICUpMbwS3blenX8i85m_-9X0d0KiG84DIKswoeFP3Czyzpv2DgDmXtKv7v4db7vsN-Iyy3RyKmX6y_1yfahMGbLqYl7pFQ2nYooZJI4XRJMDbtfX5l7QqiDDkQrHPcUNlC361WKf8rWlVlIDfwHrBkvp-UPoE',
            'p' => 'gbDt-jRqRZw1Dwg_Ckl_vBRWqCfWfem1YALgpud5FCnPtXoHHcMPayTUb8mjWioN4HIjMIJ29abtvXq3zvhYcQ',
            'q' => '0NLnRW0gajCpa0bA76AbF_MQhxGWH_ZQBfLtEq4NFGWdk_CslovUzJJ4DnW96TfthHgGQEqETtZweQd53kryrQ',
            'dp' => 'KhbWlM3v81lnqtI9S0RhLRPYr8gGB2USlO86I1CZ7d5H55iLuK_2UApq20CwP_HIASBppTOiEcU0ALtT7dqRMQ',
            'dq' => 'WOvmBV9BtVZBXmgDkkZoIxuixxFLDxMw4keeghzRfwUCQ9Pxei3TEMWyD949X0ksgAMoDkps6rFPtYnkcC8UBQ',
            'qi' => 'R-TcgNYrZs8iYmR3pI2UwFhrmJl98vzzSkI4rGTON0vPrnl_46KqzpiW04dBj3yQxhlKyPO8TO0tnA3AYnDc-Q',
        ],
            $result->all()
        );
    }

    /**
     * @test
     */
    public function createFromECCertificateFileInDERFormat()
    {
        $result = JWKFactory::createFromCertificateFile(__DIR__.'/EC/DER/prime256v1-cert.der');

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals([
            'kty' => 'EC',
            'crv' => 'P-256',
            'x' => 'xEsr_55aqgFXdrbRNz1_WSNI8UaSUxCka2kGEN1bXsI',
            'y' => 'SM45Hsr9dnUR6Ox-TpmNv2fbDX4CoVo-3patMUpXANA',
            'x5c' => ['MIIB0jCCAXegAwIBAgIJAK2o1kQ5JwpUMAoGCCqGSM49BAMCMEUxCzAJBgNVBAYT'.PHP_EOL.'AkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRn'.PHP_EOL.'aXRzIFB0eSBMdGQwHhcNMTUxMTA4MTUxMTU2WhcNMTYxMTA3MTUxMTU2WjBFMQsw'.PHP_EOL.'CQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJu'.PHP_EOL.'ZXQgV2lkZ2l0cyBQdHkgTHRkMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAExEsr'.PHP_EOL.'/55aqgFXdrbRNz1/WSNI8UaSUxCka2kGEN1bXsJIzjkeyv12dRHo7H5OmY2/Z9sN'.PHP_EOL.'fgKhWj7elq0xSlcA0KNQME4wHQYDVR0OBBYEFKIGgCZoS388STT0qjoX/swKYBXh'.PHP_EOL.'MB8GA1UdIwQYMBaAFKIGgCZoS388STT0qjoX/swKYBXhMAwGA1UdEwQFMAMBAf8w'.PHP_EOL.'CgYIKoZIzj0EAwIDSQAwRgIhAK5OqQoBGR/pj2NOb+PyRKK4k4d3Muj9z/6LsJK+'.PHP_EOL.'kkgUAiEA+FY4SWKv4mfe0gsOBId0Aah/HtVZxDBe3bCXOQM8MMM='],
            'x5t' => 'ZnnaQDssCKJQZLp6zyHssIZOa7o',
            'x5t#256' => 'v7VlokKTGL3anRk8Nl0VcqVC9u5j2Fb5tdlQntUgDT4', ],
            $result->all()
        );
    }

    /**
     * @test
     */
    public function createFromSecret()
    {
        $jwk = JWKFactory::createFromSecret('This is a very secured secret!!!!', ['kid' => 'FOO']);
        static::assertTrue($jwk->has('kty'));
        static::assertTrue($jwk->has('k'));
        static::assertTrue($jwk->has('kid'));
        static::assertEquals('oct', $jwk->get('kty'));
        static::assertEquals('This is a very secured secret!!!!', Base64Url::decode($jwk->get('k')));
        static::assertEquals('FOO', $jwk->get('kid'));
    }

    /**
     * @test
     */
    public function createFromKey()
    {
        $jwk = JWKFactory::createFromKey(\file_get_contents(__DIR__.'/Keys/EC/private.es256.encrypted.key'), 'test');
        static::assertEquals('{"kty":"EC","crv":"P-256","d":"q_VkzNnxTG39jHB0qkwA_SeVXud7yCHT7kb7kZv-0xQ","x":"vuYsP-QnrqAbM7Iyhzjt08hFSuzapyojCB_gFsBt65U","y":"oq-E2K-X0kPeqGuKnhlXkxc5fnxomRSC6KLby7Ij8AE"}', \json_encode($jwk));
    }

    /**
     * @test
     */
    public function createFromResource()
    {
        $res = \openssl_x509_read(\file_get_contents(__DIR__.'/RSA/PEM/1024b-rsa-example-cert.pem'));

        $jwk = JWKFactory::createFromX509Resource($res);

        static::assertInstanceOf(JWK::class, $jwk);
        static::assertEquals([
            'kty' => 'RSA',
            'n' => 'xgEGvHk-U_RY0j9l3MP7o-S2a6uf4XaRBhu1ztdCHz8tMG8Kj4_qJmgsSZQD17sRctHGBTUJWp4CLtBwCf0zAGVzySwUkcHSu1_2mZ_w7Nr0TQHKeWr_j8pvXH534DKEvugr21DAHbi4c654eLUL-JW_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TiDowiQbs6oGgU',
        ],
        $jwk->all());
    }

    /**
     * @test
     */
    public function createFromECCertificateFileInPEMFormat()
    {
        $result = JWKFactory::createFromCertificateFile(__DIR__.'/EC/PEM/prime256v1-cert.pem');

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals([
            'kty' => 'EC',
            'crv' => 'P-256',
            'x' => 'xEsr_55aqgFXdrbRNz1_WSNI8UaSUxCka2kGEN1bXsI',
            'y' => 'SM45Hsr9dnUR6Ox-TpmNv2fbDX4CoVo-3patMUpXANA',
            'x5c' => ['MIIB0jCCAXegAwIBAgIJAK2o1kQ5JwpUMAoGCCqGSM49BAMCMEUxCzAJBgNVBAYT'.PHP_EOL.'AkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRn'.PHP_EOL.'aXRzIFB0eSBMdGQwHhcNMTUxMTA4MTUxMTU2WhcNMTYxMTA3MTUxMTU2WjBFMQsw'.PHP_EOL.'CQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJu'.PHP_EOL.'ZXQgV2lkZ2l0cyBQdHkgTHRkMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAExEsr'.PHP_EOL.'/55aqgFXdrbRNz1/WSNI8UaSUxCka2kGEN1bXsJIzjkeyv12dRHo7H5OmY2/Z9sN'.PHP_EOL.'fgKhWj7elq0xSlcA0KNQME4wHQYDVR0OBBYEFKIGgCZoS388STT0qjoX/swKYBXh'.PHP_EOL.'MB8GA1UdIwQYMBaAFKIGgCZoS388STT0qjoX/swKYBXhMAwGA1UdEwQFMAMBAf8w'.PHP_EOL.'CgYIKoZIzj0EAwIDSQAwRgIhAK5OqQoBGR/pj2NOb+PyRKK4k4d3Muj9z/6LsJK+'.PHP_EOL.'kkgUAiEA+FY4SWKv4mfe0gsOBId0Aah/HtVZxDBe3bCXOQM8MMM='],
            'x5t' => 'ZnnaQDssCKJQZLp6zyHssIZOa7o',
            'x5t#256' => 'v7VlokKTGL3anRk8Nl0VcqVC9u5j2Fb5tdlQntUgDT4', ],
        $result->all());
    }

    /**
     * @test
     */
    public function createFrom32kRSACertificateFileInDERFormat()
    {
        $result = JWKFactory::createFromCertificateFile(__DIR__.'/RSA/DER/32k-rsa-example-cert.der');

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals([
            'kty' => 'RSA',
            'n' => ' ',
            'e' => 'AQAB',
            'x5c' => ['MIIR2jCCEUMCAg4EMA0GCSqGSIb3DQEBBQUAMIGbMQswCQYDVQQGEwJKUDEOMAwG'.PHP_EOL.'A1UECBMFVG9reW8xEDAOBgNVBAcTB0NodW8ta3UxETAPBgNVBAoTCEZyYW5rNERE'.PHP_EOL.'MRgwFgYDVQQLEw9XZWJDZXJ0IFN1cHBvcnQxGDAWBgNVBAMTD0ZyYW5rNEREIFdl'.PHP_EOL.'YiBDQTEjMCEGCSqGSIb3DQEJARYUc3VwcG9ydEBmcmFuazRkZC5jb20wHhcNMTIx'.PHP_EOL.'MDEwMTIxNzQ5WhcNMTcxMDA5MTIxNzQ5WjBKMQswCQYDVQQGDAJKUDEOMAwGA1UE'.PHP_EOL.'CAwFVG9reW8xETAPBgNVBAoMCEZyYW5rNEREMRgwFgYDVQQDDA93d3cuZXhhbXBs'.PHP_EOL.'ZS5jb20wghAiMA0GCSqGSIb3DQEBAQUAA4IQDwAwghAKAoIQAQCrM8WwUh/dxJ6z'.PHP_EOL.'bkOWhXfLd3yAoxxlUT8RD/p78xmfKoNu44Q/f3JCzdq6fNtlGg7xfDyUugk126Io'.PHP_EOL.'qxyjuh0jvneQG/PV4vKR76xYFVm21udjLP0ATdld8Bv2sdbYDGAioc2xA6wslL92'.PHP_EOL.'i4ZnDFrA10T3RYzhAbzRsOmTHEd85u2Zkhtmg4VJ6iQMcDmOiRAbMnrm3oBG1A4i'.PHP_EOL.'G3zikiUCvxE7S8JSInRHhN0B99t0i6QxxV9KhkGVkn+r7IG0+ioHU2avXH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6kc4xuh_5vEHMyyOFpGs6VqTyaKMlxg0Nt2crA', ],
        $result->all());
    }

    /**
     * @test
     */
    public function createFrom32kRSACertificateFileInPEMFormat()
    {
        $result = JWKFactory::createFromCertificateFile(__DIR__.'/RSA/PEM/32k-rsa-example-cert.pem');

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals([
            'kty' => 'RSA',
            'n' => ' ',
            'e' => 'AQAB',
            'x5c' => ['MIIR2jCCEUMCAg4EMA0GCSqGSIb3DQEBBQUAMIGbMQswCQYDVQQGEwJKUDEOMAwG'.PHP_EOL.'A1UECBMFVG9reW8xEDAOBgNVBAcTB0NodW8ta3UxETAPBgNVBAoTCEZyYW5rNERE'.PHP_EOL.'MRgwFgYDVQQLEw9XZWJDZXJ0IFN1cHBvcnQxGDAWBgNVBAMTD0ZyYW5rNEREIFdl'.PHP_EOL.'YiBDQTEjMCEGCSqGSIb3DQEJARYUc3VwcG9ydEBmcmFuazRkZC5jb20wHhcNMTIx'.PHP_EOL.'MDEwMTIxNzQ5WhcNMTcxMDA5MTIxNzQ5WjBKMQswCQYDVQQGDAJKUDEOMAwGA1UE'.PHP_EOL.'CAwFVG9reW8xETAPBgNVBAoMCEZyYW5rNEREMRgwFgYDVQQDDA93d3cuZXhhbXBs'.PHP_EOL.'ZS5jb20wghAiMA0GCSqGSIb3DQEBAQUAA4IQDwAwghAKAoIQAQCrM8WwUh/dxJ6z'.PHP_EOL.'bkOWhXfLd3yAoxxlUT8RD/p78xmfKoNu44Q/f3JCzdq6fNtlGg7xfDyUugk126Io'.PHP_EOL.'qxyjuh0jvneQG/PV4vKR76xYFVm21udjLP0ATdld8Bv2sdbYDGAioc2xA6wslL92'.PHP_EOL.'i4ZnDFrA10T3RYzhAbzRsOmTHEd85u2Zkhtmg4VJ6iQMcDmOiRAbMnrm3oBG1A4i'.PHP_EOL.'G3zikiUCvxE7S8JSInRHhN0B99t0i6QxxV9KhkGVkn+r7IG0+ioHU2avXHUWoK1H'.PHP_EOL.'zU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s6VqTyaKMlxg0Nt2crA', ],
        $result->all());
    }

    /**
     * @test
     */
    public function createFromPrivateEC256KeyFileEncrypted()
    {
        $result = JWKFactory::createFromKeyFile(__DIR__.'/Keys/EC/private.es256.encrypted.key', 'test');

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals('{"kty":"EC","crv":"P-256","d":"q_VkzNnxTG39jHB0qkwA_SeVXud7yCHT7kb7kZv-0xQ","x":"vuYsP-QnrqAbM7Iyhzjt08hFSuzapyojCB_gFsBt65U","y":"oq-E2K-X0kPeqGuKnhlXkxc5fnxomRSC6KLby7Ij8AE"}', \json_encode($result));
    }

    /**
     * @test
     */
    public function createFromPrivateEC384KeyFileEncrypted()
    {
        $result = JWKFactory::createFromKeyFile(__DIR__.'/Keys/EC/private.es384.encrypted.key', 'test');

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals('{"kty":"EC","crv":"P-384","d":"pcSSXrbeZEOaBIs7IwqcU9M_OOM81XhZuOHoGgmS_2PdECwcdQcXzv7W8-lYL0cr","x":"6f-XZsg2Tvn0EoEapQ-ylMYNtsm8CPf0cb8HI2EkfY9Bqpt3QMzwlM7mVsFRmaMZ","y":"b8nOnRwmpmEnvA2U8ydS-dbnPv7bwYl-q1qNeh8Wpjor3VO-RTt4ce0Pn25oGGWU"}', \json_encode($result));
    }

    /**
     * @test
     */
    public function createFromPrivateEC512KeyFileEncrypted()
    {
        $result = JWKFactory::createFromKeyFile(__DIR__.'/Keys/EC/private.es512.encrypted.key', 'test');

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals('{"kty":"EC","crv":"P-521","d":"Fp6KFKRiHIdR_7PP2VKxz6OkS_phyoQqwzv2I89-8zP7QScrx5r8GFLcN5mCCNJt3rN3SIgI4XoIQbNePlAj6vE","x":"AVpvo7TGpQk5P7ZLo0qkBpaT-fFDv6HQrWElBKMxcrJd_mRNapweATsVv83YON4lTIIRXzgGkmWeqbDr6RQO-1cS","y":"AIs-MoRmLaiPyG2xmPwQCHX2CGX_uCZiT3iOxTAJEZuUbeSA828K4WfAA4ODdGiB87YVShhPOkiQswV3LpbpPGhC"}', \json_encode($result));
    }

    /**
     * @test
     */
    public function createFromPublicEC256KeyFile()
    {
        $result = JWKFactory::createFromKeyFile(__DIR__.'/Keys/EC/public.es256.key');

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals('{"kty":"EC","crv":"P-256","x":"vuYsP-QnrqAbM7Iyhzjt08hFSuzapyojCB_gFsBt65U","y":"oq-E2K-X0kPeqGuKnhlXkxc5fnxomRSC6KLby7Ij8AE"}', \json_encode($result));
    }

    /**
     * @test
     */
    public function createFromPublicEC384KeyFile()
    {
        $result = JWKFactory::createFromKeyFile(__DIR__.'/Keys/EC/public.es384.key');

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals('{"kty":"EC","crv":"P-384","x":"6f-XZsg2Tvn0EoEapQ-ylMYNtsm8CPf0cb8HI2EkfY9Bqpt3QMzwlM7mVsFRmaMZ","y":"b8nOnRwmpmEnvA2U8ydS-dbnPv7bwYl-q1qNeh8Wpjor3VO-RTt4ce0Pn25oGGWU"}', \json_encode($result));
    }

    /**
     * @test
     */
    public function createFromPublicEC512KeyFile()
    {
        $result = JWKFactory::createFromKeyFile(__DIR__.'/Keys/EC/public.es512.key');

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals('{"kty":"EC","crv":"P-521","x":"AVpvo7TGpQk5P7ZLo0qkBpaT-fFDv6HQrWElBKMxcrJd_mRNapweATsVv83YON4lTIIRXzgGkmWeqbDr6RQO-1cS","y":"AIs-MoRmLaiPyG2xmPwQCHX2CGX_uCZiT3iOxTAJEZuUbeSA828K4WfAA4ODdGiB87YVShhPOkiQswV3LpbpPGhC"}', \json_encode($result));
    }

    /**
     * @test
     */
    public function createFromValues()
    {
        $result = JWKFactory::createFromValues([
            'kty' => 'EC',
            'crv' => 'P-521',
            'd' => 'Fp6KFKRiHIdR_7PP2VKxz6OkS_phyoQqwzv2I89-8zP7QScrx5r8GFLcN5mCCNJt3rN3SIgI4XoIQbNePlAj6vE',
            'x' => 'AVpvo7TGpQk5P7ZLo0qkBpaT-fFDv6HQrWElBKMxcrJd_mRNapweATsVv83YON4lTIIRXzgGkmWeqbDr6RQO-1cS',
            'y' => 'AIs-MoRmLaiPyG2xmPwQCHX2CGX_uCZiT3iOxTAJEZuUbeSA828K4WfAA4ODdGiB87YVShhPOkiQswV3LpbpPGhC',
        ]);

        static::assertInstanceOf(JWK::class, $result);
        static::assertEquals('{"kty":"EC","crv":"P-521","d":"Fp6KFKRiHIdR_7PP2VKxz6OkS_phyoQqwzv2I89-8zP7QScrx5r8GFLcN5mCCNJt3rN3SIgI4XoIQbNePlAj6vE","x":"AVpvo7TGpQk5P7ZLo0qkBpaT-fFDv6HQrWElBKMxcrJd_mRNapweATsVv83YON4lTIIRXzgGkmWeqbDr6RQO-1cS","y":"AIs-MoRmLaiPyG2xmPwQCHX2CGX_uCZiT3iOxTAJEZuUbeSA828K4WfAA4ODdGiB87YVShhPOkiQswV3LpbpPGhC"}', \json_encode($result));
    }
}
