From 5cb9cc9dfd5d3aece907a4739ef5367824e52a32 Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Sat, 20 May 2023 02:36:45 +0530 Subject: [PATCH 1/3] fix expire field in list account sessions api --- app/controllers/api/account.php | 1 + tests/e2e/Services/Account/AccountBase.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index dd5ac4a2da..5108091b36 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1389,6 +1389,7 @@ App::get('/v1/account/sessions') $session->setAttribute('countryName', $countryName); $session->setAttribute('current', ($current == $session->getId()) ? true : false); + $session->setAttribute('expire', DateTime::addSeconds(new \DateTime($session->getCreatedAt()), $authDuration)); $sessions[$key] = $session; } diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index ba751516d3..c4401d6c6f 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -308,6 +308,8 @@ trait AccountBase $this->assertEquals(true, $response['body']['sessions'][0]['current']); + $this->assertEquals(true, $response['body']['sessions'][0]['expire']); + /** * Test for FAILURE */ From 19a3db69f8e43596257b0d11752de53f1e7357a4 Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Sat, 20 May 2023 21:09:48 +0530 Subject: [PATCH 2/3] fix updated expire format to iso format --- app/controllers/api/account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 5108091b36..a91c784df5 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1389,7 +1389,7 @@ App::get('/v1/account/sessions') $session->setAttribute('countryName', $countryName); $session->setAttribute('current', ($current == $session->getId()) ? true : false); - $session->setAttribute('expire', DateTime::addSeconds(new \DateTime($session->getCreatedAt()), $authDuration)); + $session->setAttribute('expire', DateTime::formatTz(DateTime::addSeconds(new \DateTime($session->getCreatedAt()), $authDuration))); $sessions[$key] = $session; } From 5dc65ea374bdc8f0c42bc52b1daf927c5a2bdb0a Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Fri, 2 Jun 2023 15:15:06 +0530 Subject: [PATCH 3/3] fix updated test case to check if expire is valid iso string or not --- tests/e2e/Services/Account/AccountBase.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index c4401d6c6f..b08686fa48 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -308,8 +308,7 @@ trait AccountBase $this->assertEquals(true, $response['body']['sessions'][0]['current']); - $this->assertEquals(true, $response['body']['sessions'][0]['expire']); - + $this->assertNotFalse(\DateTime::createFromFormat('Y-m-d\TH:i:s.uP', $response['body']['sessions'][0]['expire'])); /** * Test for FAILURE */