X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FOStatus%2Ftests%2FMagicEnvelopeTest.php;h=fd5ad54129326a4d952cc0da12273626870f2e3a;hb=e7c6c6fc763ee94c34214f31980eabe83177a265;hp=5ee0362d287a36ac5536aa12e48f7c3fa222cb32;hpb=b7d07466943a73e1c009467c8daa6e499810080f;p=quix0rs-gnu-social.git diff --git a/plugins/OStatus/tests/MagicEnvelopeTest.php b/plugins/OStatus/tests/MagicEnvelopeTest.php index 5ee0362d28..fd5ad54129 100644 --- a/plugins/OStatus/tests/MagicEnvelopeTest.php +++ b/plugins/OStatus/tests/MagicEnvelopeTest.php @@ -6,7 +6,8 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { } define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); -define('STATUSNET', true); +define('GNUSOCIAL', true); +define('STATUSNET', true); // compatibility require_once INSTALLDIR . '/lib/common.php'; @@ -16,45 +17,28 @@ class MagicEnvelopeTest extends PHPUnit_Framework_TestCase * Test that MagicEnvelope builds the correct plaintext for signing. * @dataProvider provider */ - public function testSignatureText($env, $expected) + public function testSignatureText(MagicEnvelope $env, $expected) { - $magic = new MagicEnvelope; - $text = $magic->signingText($env); + $text = $env->signingText(); $this->assertEquals($expected, $text, "'$text' should be '$expected'"); } static public function provider() { + // Sample case given in spec: + // http://salmon-protocol.googlecode.com/svn/trunk/draft-panzer-magicsig-00.html#signing + $magic_env = new MagicEnvelope(); + $magic_env->data = 'Tm90IHJlYWxseSBBdG9t'; + $magic_env->data_type = 'application/atom+xml'; + $magic_env->encoding = 'base64url'; + $magic_env->alg = 'RSA-SHA256'; + return array( array( - // Sample case given in spec: - // http://salmon-protocol.googlecode.com/svn/trunk/draft-panzer-magicsig-00.html#signing - array( - 'data' => 'Tm90IHJlYWxseSBBdG9t', - 'data_type' => 'application/atom+xml', - 'encoding' => 'base64url', - 'alg' => 'RSA-SHA256' - ), + $magic_env, 'Tm90IHJlYWxseSBBdG9t.YXBwbGljYXRpb24vYXRvbSt4bWw=.YmFzZTY0dXJs.UlNBLVNIQTI1Ng==' ) ); } - - - /** - * Test that MagicEnvelope builds the correct plaintext for signing. - * @dataProvider provider - */ - public function testSignatureTextCompat($env, $expected) - { - // Our old code didn't add the extra fields, just used the armored text. - $alt = $env['data']; - - $magic = new MagicEnvelopeCompat; - $text = $magic->signingText($env); - - $this->assertEquals($alt, $text, "'$text' should be '$alt'"); - } - }