File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
tests/Twilio/Unit/AuthStrategy Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public function __construct(TokenManager $tokenManager) {
29
29
*/
30
30
public function isTokenExpired (string $ token ): bool {
31
31
// Decode the JWT token
32
- $ decodedToken = JWT ::decode ($ token );
32
+ $ decodedToken = JWT ::decode ($ token, null , false );
33
33
34
34
// If the token doesn't have an expiration, consider it expired
35
35
if ($ decodedToken === null || $ decodedToken ->exp === null ) {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+
4
+ namespace AuthStrategy ;
5
+
6
+ use Twilio \AuthStrategy \TokenAuthStrategy ;
7
+ use Twilio \Http \BearerToken \ApiTokenManager ;
8
+ use Twilio \Jwt \ClientToken ;
9
+ use Twilio \Tests \Unit \UnitTest ;
10
+
11
+ class TokenAuthStrategyTest extends UnitTest {
12
+ private $ tokenAuthStrategy ;
13
+
14
+ public function setUp (): void {
15
+ parent ::setUp ();
16
+ $ this ->tokenAuthStrategy = new TokenAuthStrategy (new ApiTokenManager ());
17
+ }
18
+
19
+ public function testAuthType (): void {
20
+ $ this ->assertEquals ('token ' , $ this ->tokenAuthStrategy ->getAuthType ());
21
+ }
22
+
23
+ public function testIsTokenExpired (): void {
24
+ $ token = new ClientToken ('AC123 ' , 'foo ' );
25
+ $ tokenString = $ token ->generateToken ();
26
+ $ this ->assertFalse ($ this ->tokenAuthStrategy ->isTokenExpired ($ tokenString ));
27
+ }
28
+
29
+ public function testRequiresAuthentication (): void {
30
+ $ this ->assertTrue ($ this ->tokenAuthStrategy ->requiresAuthentication ());
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments