From 9195426608e2fa94cdbccf7591ce14226bca7457 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Mon, 9 Dec 2019 13:22:08 +0000 Subject: [PATCH] Tests/authjwtTest : add logout tests git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5816 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- Tests/authjwtTest.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Tests/authjwtTest.php b/Tests/authjwtTest.php index 2ab3a36..223348e 100644 --- a/Tests/authjwtTest.php +++ b/Tests/authjwtTest.php @@ -167,9 +167,42 @@ class authjwtTest extends PHPUnit_Framework_TestCase $authjwt->cipherKey = $this->cipherKey; $_SERVER["HTTP_AUTHENTICATION"] = "Bearer $this->token"; $res = $authjwt->logout (); + $this->assertSame ($res, true); } // }}} + /** Logout : No Auth provided + */ + public function testLogout2 () + // {{{ + { + $this->expectException ("Exception", "No Authentication available", 401); + $authjwt = new authjwt (); + $authjwt->cacheDir = $this->cacheDir; + $authjwt->serverKey = $this->serverKey; + $authjwt->cipherKey = $this->cipherKey; + unset ($_SERVER["HTTP_AUTHENTICATION"]); + $res = $authjwt->logout (); + } + // }}} + + /** Logout : No Bearer available + */ + public function testLogout3 () + // {{{ + { + $this->expectException ("Exception", "No Bearer Authentication available", + 401); + $authjwt = new authjwt (); + $authjwt->cacheDir = $this->cacheDir; + $authjwt->serverKey = $this->serverKey; + $authjwt->cipherKey = $this->cipherKey; + $_SERVER["HTTP_AUTHENTICATION"] = "Another auth"; + $res = $authjwt->logout (); + } + // }}} + + /** Not needed function connect */ public function testUnusedFunctions1 ()