-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from vanilla/feature/2dot0
Update jsConnect to 2.0
- Loading branch information
Showing
9 changed files
with
436 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
language: php | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- hhvm | ||
|
||
matrix: | ||
allow_failures: | ||
- php: hhvm | ||
fast_finish: true | ||
|
||
install: | ||
- composer self-update | ||
- | | ||
if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then | ||
composer require "phpunit/phpunit=~5.7" | ||
else | ||
if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.6" ]]; then | ||
composer require "phpunit/phpunit=~5" | ||
else | ||
composer require "phpunit/phpunit=~4.8" | ||
fi | ||
fi | ||
script: ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.clover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="tests/phpunit.php" | ||
> | ||
<php> | ||
<ini name="intl.default_locale" value="en"/> | ||
<ini name="intl.error_level" value="0"/> | ||
<ini name="memory_limit" value="-1"/> | ||
<ini name="date.timezone" value="America/Montreal"/> | ||
</php> | ||
|
||
<testsuites> | ||
<testsuite name="All"> | ||
<directory suffix="Test.php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="false"> | ||
<file>functions.jsconnect.php</file> | ||
<exclude> | ||
<file>index.php</file> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* @author Alexandre (DaazKu) Chouinard <alexandre.c@vanillaforums.com> | ||
* @copyright 2009-2017 Vanilla Forums Inc. | ||
* @license GNU GPLv2 http://www.opensource.org/licenses/gpl-2.0.php | ||
*/ | ||
|
||
namespace JsConnect\Tests; | ||
|
||
/** | ||
* Unit tests hashing | ||
*/ | ||
class HashTest extends \PHPUnit_Framework_TestCase { | ||
|
||
/** | ||
* Test {@link jsHash} with no $secure parameter. | ||
*/ | ||
public function testHashDefault() { | ||
$this->assertEquals(md5('hashMe'), jsHash('hashMe')); | ||
} | ||
|
||
/** | ||
* Test {@link jsHash} with true as the $secure parameter. | ||
*/ | ||
public function testHashSecureTrue() { | ||
$this->assertEquals(md5('hashMe'), jsHash('hashMe', true)); | ||
} | ||
|
||
/** | ||
* Test {@link jsHash} with 'md5' as the $secure parameter. | ||
*/ | ||
public function testHashSecureMD5() { | ||
$this->assertEquals(md5('hashMe'), jsHash('hashMe', 'md5')); | ||
} | ||
|
||
/** | ||
* Test {@link jsHash} with 'sha256' as the $secure parameter. | ||
*/ | ||
public function testHashSecureSHA256() { | ||
$this->assertEquals(hash('sha256', 'hashMe'), jsHash('hashMe', 'sha256')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?php | ||
/** | ||
* @author Alexandre (DaazKu) Chouinard <alexandre.c@vanillaforums.com> | ||
* @copyright 2009-2017 Vanilla Forums Inc. | ||
* @license GNU GPLv2 http://www.opensource.org/licenses/gpl-2.0.php | ||
*/ | ||
|
||
namespace JsConnect\Tests; | ||
|
||
/** | ||
* Unit tests signJsConnect | ||
*/ | ||
class SignJsConnectTest extends \PHPUnit_Framework_TestCase { | ||
|
||
/** | ||
* @param $data | ||
* @param $clientID | ||
* @param $secret | ||
* @param $hashType | ||
* @param $returnData | ||
* @param $expectedResult | ||
* | ||
* @dataProvider provideSignJsConnectTests | ||
*/ | ||
public function testSignJsConnect($data, $clientID, $secret, $hashType, $returnData, $expectedResult) { | ||
$this->assertEquals(signJsConnect($data, $clientID, $secret, $hashType, $returnData), $expectedResult); | ||
} | ||
|
||
|
||
/** | ||
* Provide signature to sign | ||
* | ||
* @return array Returns a test array. | ||
*/ | ||
public function provideSignJsConnectTests() { | ||
return [ | ||
'default' => [ | ||
[ | ||
'name' => 'John PHP', | ||
'email' => 'john.php@example.com', | ||
'unique_id' => '123', | ||
], | ||
'clientID', | ||
'secret', | ||
'sha256', | ||
false, | ||
'71528bfbb99aba97734f79beab6d1eca1416e05a0587e9ab55b99095753f74b6', | ||
], | ||
'unordered' => [ | ||
[ | ||
'unique_id' => '123', | ||
'email' => 'john.php@example.com', | ||
'name' => 'John PHP', | ||
], | ||
'clientID', | ||
'secret', | ||
'sha256', | ||
false, | ||
'71528bfbb99aba97734f79beab6d1eca1416e05a0587e9ab55b99095753f74b6', | ||
], | ||
'incorrectKeyCase' => [ | ||
[ | ||
'Name' => 'John PHP', | ||
'eMail' => 'john.php@example.com', | ||
'UNIQUE_id' => '123', | ||
], | ||
'clientID', | ||
'secret', | ||
'sha256', | ||
false, | ||
'71528bfbb99aba97734f79beab6d1eca1416e05a0587e9ab55b99095753f74b6', | ||
], | ||
'trueAsHashType' => [ | ||
[ | ||
'Name' => 'John PHP', | ||
'eMail' => 'john.php@example.com', | ||
'unique_id' => '123', | ||
], | ||
'clientID', | ||
'secret', | ||
true, | ||
false, | ||
'f1639a1838bd904cb967423be0567802', | ||
], | ||
'extraInfo' => [ | ||
[ | ||
'unique_id' => '123', | ||
'email' => 'john.php@example.com', | ||
'name' => 'John PHP', | ||
'custom_field' => 'custom', | ||
], | ||
'clientID', | ||
'secret', | ||
'sha256', | ||
false, | ||
'72976aaaa96cb1acc94aa8c1638a0b3e10bb638e3985e25f60f6db79f65fcefb', | ||
], | ||
'defaultReturnData' => [ | ||
[ | ||
'name' => 'John PHP', | ||
'email' => 'john.php@example.com', | ||
'unique_id' => '123', | ||
], | ||
'clientID', | ||
'secret', | ||
'sha256', | ||
true, | ||
[ | ||
'name' => 'John PHP', | ||
'email' => 'john.php@example.com', | ||
'unique_id' => '123', | ||
'client_id' => 'clientID', | ||
'sig' => '71528bfbb99aba97734f79beab6d1eca1416e05a0587e9ab55b99095753f74b6', | ||
] | ||
], | ||
]; | ||
} | ||
} |
Oops, something went wrong.