@@ -45,12 +45,6 @@ public function testShouldProcessForExpiredTokenStillInLeewayPeriod(): void
45
45
$ token = $ this ->buildToken (['exp ' => (new Carbon ($ now ))->subSeconds (SessionToken::LEEWAY_SECONDS - 2 )]);
46
46
$ st = SessionToken::fromNative ($ token );
47
47
48
- $ this ->assertInstanceOf (ShopDomainValue::class, $ st ->getShopDomain ());
49
- $ this ->assertTrue (Str::contains ($ this ->tokenDefaults ['dest ' ], $ st ->getShopDomain ()->toNative ()));
50
-
51
- $ this ->assertInstanceOf (SessionIdValue::class, $ st ->getSessionId ());
52
- $ this ->assertSame ($ this ->tokenDefaults ['sid ' ], $ st ->getSessionId ()->toNative ());
53
-
54
48
$ this ->assertInstanceOf (Carbon::class, $ st ->getLeewayExpiration ());
55
49
$ this ->assertTrue ($ now ->unix () < $ st ->getLeewayExpiration ()->unix ());
56
50
$ this ->assertTrue ($ st ->getLeewayExpiration ()->unix () - $ now ->unix () < SessionToken::LEEWAY_SECONDS );
@@ -64,6 +58,44 @@ public function testShouldThrowExceptionForExpiredTokenOutOfLeewayPeriod(): void
64
58
SessionToken::fromNative ($ token );
65
59
}
66
60
61
+ public function testShouldProcessForNotBeforeTokenStillInLeewayPeriod (): void
62
+ {
63
+ $ now = Carbon::now ();
64
+ $ token = $ this ->buildToken (['nbf ' => (new Carbon ($ now ))->addSeconds (SessionToken::LEEWAY_SECONDS - 2 )]);
65
+ $ st = SessionToken::fromNative ($ token );
66
+
67
+ $ this ->assertInstanceOf (Carbon::class, $ st ->getLeewayNotBefore ());
68
+ $ this ->assertTrue ($ now ->unix () > $ st ->getLeewayNotBefore ()->unix ());
69
+ $ this ->assertTrue ($ st ->getLeewayNotBefore ()->unix () - $ now ->unix () < SessionToken::LEEWAY_SECONDS );
70
+ }
71
+
72
+ public function testShouldThrowExceptionForNotBeforeTokenOutOfLeewayPeriod (): void
73
+ {
74
+ $ this ->expectException (AssertionFailedException::class);
75
+
76
+ $ token = $ this ->buildToken (['nbf ' => Carbon::now ()->addSeconds (SessionToken::LEEWAY_SECONDS + 2 )]);
77
+ SessionToken::fromNative ($ token );
78
+ }
79
+
80
+ public function testShouldProcessForIssuedAtTokenStillInLeewayPeriod (): void
81
+ {
82
+ $ now = Carbon::now ();
83
+ $ token = $ this ->buildToken (['iat ' => (new Carbon ($ now ))->addSeconds (SessionToken::LEEWAY_SECONDS - 2 )]);
84
+ $ st = SessionToken::fromNative ($ token );
85
+
86
+ $ this ->assertInstanceOf (Carbon::class, $ st ->getLeewayIssuedAt ());
87
+ $ this ->assertTrue ($ now ->unix () > $ st ->getLeewayIssuedAt ()->unix ());
88
+ $ this ->assertTrue ($ st ->getLeewayIssuedAt ()->unix () - $ now ->unix () < SessionToken::LEEWAY_SECONDS );
89
+ }
90
+
91
+ public function testShouldThrowExceptionForIssuedAtTokenOutOfLeewayPeriod (): void
92
+ {
93
+ $ this ->expectException (AssertionFailedException::class);
94
+
95
+ $ token = $ this ->buildToken (['iat ' => Carbon::now ()->addSeconds (SessionToken::LEEWAY_SECONDS + 2 )]);
96
+ SessionToken::fromNative ($ token );
97
+ }
98
+
67
99
public function testShouldThrowExceptionForMalformedToken (): void
68
100
{
69
101
$ this ->expectException (AssertionFailedException::class);
0 commit comments