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)
6969 throw new FastFailException ($ message , $ context );
7070 }
7171
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 ];
8074 }
8175
8276 try {
@@ -131,4 +125,23 @@ public static function getAdminToken($username = null, $password = null)
131125 $ context = ['url ' => $ authUrl ];
132126 throw new FastFailException ($ message , $ context );
133127 }
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+ }
134147}
You can’t perform that action at this time.
0 commit comments