From dfc3e94e28323f67b356a315d208bc34b078232c Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 24 May 2019 09:09:11 +0000 Subject: [PATCH] jwt : pass the not needed method to private git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5284 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- Tests/jwtTest.php | 9 ++++++--- jwt.php | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Tests/jwtTest.php b/Tests/jwtTest.php index 6ac477b..92ab9c5 100644 --- a/Tests/jwtTest.php +++ b/Tests/jwtTest.php @@ -17,7 +17,8 @@ class test_jwt extends PHPUnit_Framework_TestCase public function test_sign_1 () { $jwt = new jwt (); - $res = $jwt->sign ("TEXT TO SIGN", "KEY TO USE", "HS384"); + $res = $this->invokeMethod ($jwt, "sign", "TEXT TO SIGN", "KEY TO USE", + "HS384"); $this->assertSame ( "cQB+yNVvIER+Nw53MZfU/PGPAJlkKUnjMikmXAwVB9tcaINQH5a88LCDi0PmI5mZ", base64_encode ($res)); @@ -26,7 +27,8 @@ class test_jwt extends PHPUnit_Framework_TestCase public function test_sign_2 () { $jwt = new jwt (); - $res = $jwt->sign ("text to sign", "KEY TO USE", "HS384"); + $res = $this->invokeMethod ($jwt, "sign", "text to sign", "KEY TO USE", + "HS384"); $this->assertSame ( "FLSkslsUGIpkP3xsJx5ephnCtH7K4jZSNxRxxCn3m7fsPK/MMfEIVr+h3heap80x", base64_encode ($res)); @@ -35,7 +37,8 @@ class test_jwt extends PHPUnit_Framework_TestCase public function test_sign_3 () { $jwt = new jwt (); - $res = $jwt->sign ("text to sign", "key to use", "HS384"); + $res = $this->invokeMethod ($jwt, "sign", "text to sign", "key to use", + "HS384"); $this->assertSame ( "lBLlXb5Xo3z9zoEuO0obZdhqGNUKr8DaEsL991TpSPWIdB2067ckR+AJ1FW6in2B", base64_encode ($res)); diff --git a/jwt.php b/jwt.php index 97daadc..eaa3136 100644 --- a/jwt.php +++ b/jwt.php @@ -104,7 +104,7 @@ class jwt * @param string $alg The algorithm to use to sign the input * @return boolean Return true if the input signed is valid */ - public function verify ($input, $sign, $key, $alg) + private function verify ($input, $sign, $key, $alg) // {{{ { $signature = $this->sign ($input, $key, $alg); @@ -137,7 +137,7 @@ class jwt * @param string $alg The algorithm to use to sign * @return string The signed string in binary */ - public function sign ($input, $key, $alg) + private function sign ($input, $key, $alg) // {{{ { if (! key_exists ($alg, $this->supportedAlgs))