Page MenuHomeDevCentral

No OneTemporary

diff --git a/tests/XHubSignatureConstants.php b/tests/XHubSignatureConstants.php
index 85c7cdf..e7da00d 100644
--- a/tests/XHubSignatureConstants.php
+++ b/tests/XHubSignatureConstants.php
@@ -1,13 +1,13 @@
<?php
define('SECRET', 'secret123');
define('TIGER_ALGO', 'tiger192,4');
define('TIGER_PAYLOAD', 'lorem ipsum dolor');
define('TIGER_SIGNATURE', '7081ac97e50ad97e13b2fb9364b9df376c26b920080245ce');
// Current default algo is sha-1.
-define('DEFAULT_PAYLOAD', 'TODO: add here real GitHub payload');
-define('DEFAULT_SIGNATURE', 'ee2e24a002bcbfc4a93dc729bbbded01a9a46215');
+define('DEFAULT_PAYLOAD', file_get_contents(__DIR__ . '/payload.json'));
+define('DEFAULT_SIGNATURE', 'ab05a3aef13696b60a60a8064b9fda31a8c77582');
define('EMPTY_DEFAULT_HASH_ALGO_SIGNATURE', 'fbdb1d1b18aa6c08324b7d64b71fb76370690e1d');
diff --git a/tests/XHubSignatureTest.php b/tests/XHubSignatureTest.php
index fe74fc1..0646189 100644
--- a/tests/XHubSignatureTest.php
+++ b/tests/XHubSignatureTest.php
@@ -1,78 +1,73 @@
<?php
use Keruald\GitHub\XHubSignature;
require 'XHubSignatureConstants.php';
class XHubSignatureTest extends PHPUnit_Framework_TestCase {
protected $defaultInstance;
protected $tigerInstance;
protected function setUp() {
$this->defaultInstance = new XHubSignature(SECRET);
$this->tigerInstance = new XHubSignature(SECRET, TIGER_ALGO);
$this->defaultInstance->payload = DEFAULT_PAYLOAD;
$this->tigerInstance->payload = TIGER_PAYLOAD;
}
public function testValidate () {
$this->defaultInstance->signature = "";
$this->assertFalse($this->defaultInstance->validate());
$this->defaultInstance->signature = "bad signature";
$this->assertFalse($this->defaultInstance->validate());
- $this->markTestIncomplete(
- 'Validation test has not been implemented yet.'
- );
+ $this->defaultInstance->signature = DEFAULT_SIGNATURE;
+ $this->assertTrue($this->defaultInstance->validate());
}
public function testCompute () {
$this->assertSame(
DEFAULT_SIGNATURE,
$this->defaultInstance->compute()
);
$this->assertSame(
TIGER_SIGNATURE,
$this->tigerInstance->compute()
);
-
- $this->markTestIncomplete(
- 'Compute test for default instance should be extracted from a real GitHub payload.'
- );
}
///
/// Test static helper methods
///
/**
* @covers XHubSignature::validatePayload
*/
public function testhashPayload () {
$this->assertSame(
EMPTY_DEFAULT_HASH_ALGO_SIGNATURE,
XHubSignature::hashPayload("", "")
);
$this->assertSame(
TIGER_SIGNATURE,
XHubSignature::hashPayload(SECRET, TIGER_PAYLOAD, TIGER_ALGO)
);
}
/**
* @covers XHubSignature::validatePayload
*/
public function testValidatePayload () {
$this->assertFalse(XHubSignature::validatePayload("", "", ""));
$this->assertTrue(XHubSignature::validatePayload(
SECRET,
TIGER_PAYLOAD,
TIGER_SIGNATURE,
TIGER_ALGO
));
}
}
diff --git a/tests/payload.json b/tests/payload.json
new file mode 100644
index 0000000..0849621
--- /dev/null
+++ b/tests/payload.json
@@ -0,0 +1 @@
+{"zen":"Practicality beats purity.","hook_id":6474950,"hook":{"url":"https://api.github.com/orgs/nasqueron/hooks/6474950","ping_url":"https://api.github.com/orgs/nasqueron/hooks/6474950/pings","id":6474950,"name":"web","active":true,"events":["*"],"config":{"url":"https://notifications-dereckson.c9users.io/gate/GitHub","content_type":"json","insecure_ssl":"0","secret":"********"},"updated_at":"2015-11-22T06:25:12Z","created_at":"2015-11-22T06:25:12Z"},"organization":{"login":"nasqueron","id":5605546,"url":"https://api.github.com/orgs/nasqueron","repos_url":"https://api.github.com/orgs/nasqueron/repos","events_url":"https://api.github.com/orgs/nasqueron/events","members_url":"https://api.github.com/orgs/nasqueron/members{/member}","public_members_url":"https://api.github.com/orgs/nasqueron/public_members{/member}","avatar_url":"https://avatars.githubusercontent.com/u/5605546?v=3","description":"Central hub of a budding community of creative people, writers, developers and thinkers."},"sender":{"login":"dereckson","id":135563,"avatar_url":"https://avatars.githubusercontent.com/u/135563?v=3","gravatar_id":"","url":"https://api.github.com/users/dereckson","html_url":"https://github.com/dereckson","followers_url":"https://api.github.com/users/dereckson/followers","following_url":"https://api.github.com/users/dereckson/following{/other_user}","gists_url":"https://api.github.com/users/dereckson/gists{/gist_id}","starred_url":"https://api.github.com/users/dereckson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dereckson/subscriptions","organizations_url":"https://api.github.com/users/dereckson/orgs","repos_url":"https://api.github.com/users/dereckson/repos","events_url":"https://api.github.com/users/dereckson/events{/privacy}","received_events_url":"https://api.github.com/users/dereckson/received_events","type":"User","site_admin":false}}
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jul 29, 14:29 (3 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2850837
Default Alt Text
(5 KB)

Event Timeline