File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -262,4 +262,25 @@ public function testFromQueryString()
262262 $ tokenObject = Token::fromQueryString ();
263263 $ this ->assertInstanceOf (Token::class, $ tokenObject );
264264 }
265+
266+ public function testFromAuthorizationBearer ()
267+ {
268+ $ secret = new HsSecret ('secret ' );
269+ $ token = 'Bearer ' . Token::create ()
270+ ->withSigner (SignerFactory::build ('HS256 ' ))
271+ ->sign ($ secret )
272+ ->toString ();
273+
274+ //Possibility 1:
275+ $ _SERVER ['Authorization ' ] = $ token ;
276+ $ tokenObject = Token::fromAuthorizationBearer ();
277+ $ this ->assertInstanceOf (Token::class, $ tokenObject );
278+ unset($ _SERVER ['Authorization ' ]);
279+
280+ //Possibility 2:
281+ $ _SERVER ['HTTP_AUTHORIZATION ' ] = $ token ;
282+ $ tokenObject = Token::fromAuthorizationBearer ();
283+ $ this ->assertInstanceOf (Token::class, $ tokenObject );
284+ unset($ _SERVER ['HTTP_AUTHORIZATION ' ]);
285+ }
265286}
You can’t perform that action at this time.
0 commit comments