Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F56338230
XHubSignatureTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
XHubSignatureTest.php
View Options
<?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.'
);
}
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
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 7, 04:50 (5 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4212492
Default Alt Text
XHubSignatureTest.php (2 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment