<?php

use nicoSWD\GPG\PublicKey;

class KeyTest extends PHPUnit_Framework_TestCase
{
    /**
     * @return string
     */
    public function getOpenPGPTestKey2()
    {
        return '-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: OpenPGP.js v.1.20140106
Comment: http://openpgpjs.org

xsBNBFLL5JEBCACFBaNfA4Iicm/MvO0sJcllB/iGc0qNgtqwpXGBydDt8Pj7
+mn0ZZ4Q1ol5wAYAxapGGaoEB1Wh5ALy2UvnrFx1/dyZEQhU3oUTRQevzhm1
/gp/0l9bNijBONir1spMuDc7okXWaR8GCW0mWwmeFgXZnjL4Dmr6dUJvZHpX
ZiekLPT3xHWQxrKdsafxmULVgd71ZdBq/6ikWQsK5XqBVykD2C/6jNDJ8Cga
wzCs8WOSQkpss7L28qQrEkL3+JaLGEe3+6UUnzs5KjwgTZvlAawDkm55corz
TistbvOotDVbs/nXyu6TnMhZXqJR2a0TEuRDXpS93qGr97flZKwVBp6vABEB
AAHNF1Rlc3QgPHRlc3RAZXhhbXBsZS5jb20+wsBcBBABCAAQBQJSy+SZCRDI
dThpeYYhmgAAVecH/R2IXW82smV41eDIwA9PzV6sKF7ywmlEl/zkZTEpTLaB
bXM3wScspVHGWV7hO+9ZQImtdcqb2AFpNpBgBtpFypM2nMGdFxTzv0m3uRUs
J8KT0lU0Uj4FEsr5YYCb1UWGgDrZP+vZFxfw8j+NWGIS5NlLHPeTTMJVRhKX
Xe0c8AaAF8qz10+JyapyDlUlFVr8+n/UjGwsUp15ODnDt0nsGTfw6jKelTU2
y/d0ckERWE0rWT2eooAxqxIoVayJkEZTzbfx/mHJXeGhOFwjg5danv7JnDI/
FHAUVqBD8zTkqmjdk9LZ6GnF6tuKRAWS59qU7y4+fchP58dhjep0mIFa6FQ=
=8aNP
-----END PGP PUBLIC KEY BLOCK-----';
    }

    /**
     * @return string
     */
    public function getGnuPGTestKey()
    {
        return '-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin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j7jeGNepS0nx+sq/kHIzk
OUHjHddEv8BX1sL+vDzYYHblujuSXWfnJ4NNUnl5NE5Lsqrz7akDbp+EknGo4oNY
AmF+55LMB5F4/dSuzO2eIxFpvGOVcZ2MsSuIMMe7eglAYMWyYbCNSW64Iik2OOmb
vqtgHQVeyBHBGFtK0qBz7H/ICTd/5vjY8OFtUdCzZkLxOq86PT0vir8k/8JHIS3w
Aw6lM44mbDdN4xabM466k9TK+L2J08RW+K4lJ21yqjFrczmWoOhgNHZsVozgj3+m
JMildhSH3/orpAvdtjw2J44NP4y4ts9bRftFhlXA4ZTb8qLnTclrayPKXYio4D8v
G+nAf4RLCP0++XPRSEm/5Rv6/MXJZ9we+7XNHNTAC2dkmU1QTlM2dttzN28Whhf5
gPLPMkHxaqGn4wygONP9T2Ehth8Fi8eo5OpkMM/uU30n5xlchqBQSPxWiJSIk1cN
rrkM+tFI6ij510nyAL0uF4l3vc3aBQ90I3iS9J51j1MQQ2pt8/3Ofq5CiHKNUGPL
0w==
=Opd1
-----END PGP PUBLIC KEY BLOCK-----';
    }

    public function test_VerifyGnuPGKey()
    {
        $this->markTestSkipped();

        // jason's public key
        $public_key_ascii = $this->getGnuPGTestKey();

        $pub_key = new PublicKey($public_key_ascii);

        $this->assertEquals(PK_TYPE_RSA, $pub_key->getKeyType(), 'OpenPGP Incorrect Key Type');
        $this->assertEquals('47009B66424E9476', $pub_key->getKeyId(), 'OpenPGP Incorrect Key ID');
        $this->assertEquals('ED4F E89E 38A3 7833 3CD4 D6FA 4700 9B66 424E 9476', $pub_key->GetFingerprint(), 'OpenPGP Incorrect Fingerprint');
    }

    public function test_VerifyOpenPGPKey2()
    {
        $this->markTestSkipped();

        // OpenPGP Test Key
        $public_key_ascii = $this->getOpenPGPTestKey2();
        $pub_key = new PublicKey($public_key_ascii);

        $this->assertEquals(PK_TYPE_RSA, $pub_key->getKeyType(), 'OpenPGP Incorrect Key Type');
        $this->assertEquals('C87538697986219A', $pub_key->getKeyId(), 'OpenPGP Incorrect Key ID');
        $this->assertEquals('3C05 9D07 C624 84A4 EF2D 3651 C875 3869 7986 219A', $pub_key->GetFingerprint(), 'OpenPGP Incorrect Fingerprint');
    }
}
