From 1fcbcc8368296d5568fec00b508c737dd06b8586 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 24 Aug 2021 11:31:06 +1200 Subject: [PATCH 1/2] MNT Skip tests when session-manager module is installed --- tests/php/Security/MemberTest.php | 24 ++++++++++++-------- tests/php/Security/RememberLoginHashTest.php | 9 ++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/tests/php/Security/MemberTest.php b/tests/php/Security/MemberTest.php index 52f9a3c10..49d543a75 100644 --- a/tests/php/Security/MemberTest.php +++ b/tests/php/Security/MemberTest.php @@ -27,6 +27,7 @@ use SilverStripe\Security\Permission; use SilverStripe\Security\RememberLoginHash; use SilverStripe\Security\Security; use SilverStripe\Security\Tests\MemberTest\FieldsExtension; +use SilverStripe\SessionManager\Models\LoginSession; class MemberTest extends FunctionalTest { @@ -1198,18 +1199,21 @@ class MemberTest extends FunctionalTest ] ); $this->assertEquals( - RememberLoginHash::get()->filter(['MemberID'=>$m1->ID, 'DeviceID'=>$firstHash->DeviceID])->count(), - 1 + 1, + RememberLoginHash::get()->filter(['MemberID'=>$m1->ID, 'DeviceID'=>$firstHash->DeviceID])->count() ); - // Logging out from any device when all login hashes should be removed - RememberLoginHash::config()->update('logout_across_devices', true); - Injector::inst()->get(IdentityStore::class)->logIn($m1, true); - $this->get('Security/logout', $this->session()); - $this->assertEquals( - RememberLoginHash::get()->filter('MemberID', $m1->ID)->count(), - 0 - ); + // If session-manager module is installed then logout_across_devices is modified so skip + if (!class_exists(LoginSession::class)) { + // Logging out from any device when all login hashes should be removed + RememberLoginHash::config()->update('logout_across_devices', true); + Injector::inst()->get(IdentityStore::class)->logIn($m1, true); + $this->get('Security/logout', $this->session()); + $this->assertEquals( + 0, + RememberLoginHash::get()->filter('MemberID', $m1->ID)->count() + ); + } } public function testCanDelete() diff --git a/tests/php/Security/RememberLoginHashTest.php b/tests/php/Security/RememberLoginHashTest.php index ec5625304..3ef236a6b 100644 --- a/tests/php/Security/RememberLoginHashTest.php +++ b/tests/php/Security/RememberLoginHashTest.php @@ -5,6 +5,7 @@ namespace SilverStripe\Security\Tests; use SilverStripe\Dev\SapphireTest; use SilverStripe\Security\Member; use SilverStripe\Security\RememberLoginHash; +use SilverStripe\SessionManager\Models\LoginSession; class RememberLoginHashTest extends SapphireTest { @@ -49,6 +50,10 @@ class RememberLoginHashTest extends SapphireTest */ public function testClear(bool $logoutAcrossDevices, string $deviceId, array $expected, array $unexpected) { + // If session-manager module is installed then logout_across_devices is modified so skip + if (class_exists(LoginSession::class)) { + $this->markTestSkipped(); + } RememberLoginHash::config()->set('logout_across_devices', $logoutAcrossDevices); RememberLoginHash::clear( @@ -75,6 +80,10 @@ class RememberLoginHashTest extends SapphireTest public function testGetSetLogoutAcrossDevices() { + // If session-manager module is installed then logout_across_devices is modified so skip + if (class_exists(LoginSession::class)) { + $this->markTestSkipped(); + } // set config directly RememberLoginHash::config()->set('logout_across_devices', true); $this->assertTrue(RememberLoginHash::getLogoutAcrossDevices()); From 3be8b3aefaebfb22435a6353d75109e250b5aae9 Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Fri, 3 Sep 2021 11:10:30 +1200 Subject: [PATCH 2/2] MNT Install 4.9.x-dev recipe for test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ecc69a116..d51954d8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ import: env: global: - - REQUIRE_RECIPE="4.x-dev" + - REQUIRE_RECIPE="4.9.x-dev" # Using a manual matrix to exlude PHPUNIT_COVERAGE_TEST for now because it was causing some strange issues # e.g. https://travis-ci.com/github/silverstripe/silverstripe-framework/jobs/457096837