File tree Expand file tree Collapse file tree 1 file changed +21
-8
lines changed
src/Magento/FunctionalTestingFramework/DataTransport/Auth Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -69,14 +69,8 @@ public static function getAdminToken($username = null, $password = null)
69
69
throw new FastFailException ($ message , $ context );
70
70
}
71
71
72
- if (isset (self ::$ adminAuthTokens [$ login ])) {
73
- $ tokenLifetime = getenv ('MAGENTO_ADMIN_WEBAPI_TOKEN_LIFETIME ' );
74
-
75
- $ isTokenAboutToExpire = $ tokenLifetime && time () - self ::$ adminAuthTokenTimestamps [$ login ] > $ tokenLifetime ;
76
-
77
- if (!$ isTokenAboutToExpire ) {
78
- return self ::$ adminAuthTokens [$ login ];
79
- }
72
+ if (self ::hasExistingToken ($ login )) {
73
+ return self ::$ adminAuthTokens [$ login ];
80
74
}
81
75
82
76
try {
@@ -131,4 +125,23 @@ public static function getAdminToken($username = null, $password = null)
131
125
$ context = ['url ' => $ authUrl ];
132
126
throw new FastFailException ($ message , $ context );
133
127
}
128
+
129
+ /**
130
+ * Is there an existing WebAPI admin token for this login?
131
+ *
132
+ * @param string $login
133
+ * @return bool
134
+ */
135
+ private static function hasExistingToken (string $ login )
136
+ {
137
+ if (!isset (self ::$ adminAuthTokens [$ login ])) {
138
+ return false ;
139
+ }
140
+
141
+ $ tokenLifetime = getenv ('MAGENTO_ADMIN_WEBAPI_TOKEN_LIFETIME ' );
142
+
143
+ $ isTokenExpired = $ tokenLifetime && time () - self ::$ adminAuthTokenTimestamps [$ login ] > $ tokenLifetime ;
144
+
145
+ return !$ isTokenExpired ;
146
+ }
134
147
}
You can’t perform that action at this time.
0 commit comments