-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4710b27
commit a8f7d54
Showing
10 changed files
with
153 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Run session-manager behat tests with this command | ||
# ========================================================================= # | ||
# vendor/bin/selenium-server-standalone -Dwebdriver.firefox.bin="/Applications/Firefox31.app/Contents/MacOS/firefox-bin" | ||
# vendor/bin/serve --bootstrap-file vendor/silverstripe/cms/tests/behat/serve-bootstrap.php | ||
# vendor/bin/behat @session-manager | ||
# ========================================================================= # | ||
default: | ||
suites: | ||
session-manager: | ||
paths: | ||
- "%paths.modules.session-manager%/tests/behat/features" | ||
contexts: | ||
- SilverStripe\SessionManager\Tests\Behat\Context\FeatureContext | ||
- SilverStripe\Framework\Tests\Behaviour\CmsFormsContext | ||
- SilverStripe\Framework\Tests\Behaviour\CmsUiContext | ||
- SilverStripe\BehatExtension\Context\BasicContext | ||
- SilverStripe\BehatExtension\Context\EmailContext | ||
- SilverStripe\BehatExtension\Context\LoginContext | ||
- | ||
SilverStripe\SessionManager\Tests\Behat\Context\FixtureContext: | ||
- "%paths.modules.session-manager%/tests/behat/files/" | ||
extensions: | ||
SilverStripe\BehatExtension\Extension: | ||
bootstrap_file: vendor/silverstripe/cms/tests/behat/serve-bootstrap.php | ||
screenshot_path: "%paths.base%/artifacts/screenshots" | ||
retry_seconds: 4 # default is 2 | ||
SilverStripe\BehatExtension\MinkExtension: | ||
default_session: facebook_web_driver | ||
javascript_session: facebook_web_driver | ||
facebook_web_driver: | ||
browser: chrome | ||
wd_host: "http://127.0.0.1:9515" #chromedriver port | ||
browser_name: chrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
See https://github.com/silverstripe-labs/silverstripe-behat-extension |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@retry | ||
|
||
Feature: See other devices and revoke their access | ||
As a CMS user | ||
I want to see other devices that are currently logged in | ||
So that I can revoke their access | ||
|
||
Background: | ||
Given I am logged in with "ADMIN" permissions | ||
# Create a mock login session | ||
And There is a login session for a second device | ||
|
||
Scenario: I can see other devices and revoke their access | ||
When I go to "/admin/security" | ||
# Click the ADMIN user | ||
And I click the ".col-FirstName" element | ||
# Ensure XHR loaded from endpoint | ||
And I wait for 2 seconds | ||
# Assert text for the two login sessions | ||
Then I should see the text "Current" in the ".login-session .text-success" element | ||
Then I should see the text "Log out" in the ".login-session__logout" element | ||
# Click "Log out" button | ||
When I click the ".login-session__logout" element | ||
# Wait for modal to fade in | ||
And I wait for 2 seconds | ||
# Click the green button in the modal | ||
When I click the ".modal-dialog .btn-primary" element | ||
# Assert text has changed | ||
Then I should see the text "Logging out..." in the ".login-session__logout" element | ||
# Assert hidden element is applied which fades to not visible via a css transition | ||
Then I see the ".login-session.hidden" element |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace SilverStripe\SessionManager\Tests\Behat\Context; | ||
|
||
use SilverStripe\BehatExtension\Context\SilverStripeContext; | ||
|
||
class FeatureContext extends SilverStripeContext | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace SilverStripe\SessionManager\Tests\Behat\Context; | ||
|
||
use Behat\Mink\Element\NodeElement; | ||
use SilverStripe\BehatExtension\Context\FixtureContext as BaseFixtureContext; | ||
use SilverStripe\Control\Controller; | ||
use SilverStripe\Security\Member; | ||
use SilverStripe\SessionManager\Model\LoginSession; | ||
|
||
/** | ||
* Context used to create fixtures in the SilverStripe ORM. | ||
*/ | ||
class FixtureContext extends BaseFixtureContext | ||
{ | ||
/** | ||
* @When /^I see the "([^"]+)" element$/ | ||
* @param $selector | ||
*/ | ||
public function iSeeTheElement($selector): void | ||
{ | ||
$page = $this->getMainContext()->getSession()->getPage(); | ||
$element = $page->find('css', $selector); | ||
assertNotNull($element, sprintf('Element %s not found', $selector)); | ||
} | ||
|
||
/** | ||
* @When /^I click the "([^"]+)" element$/ | ||
* @param $selector | ||
*/ | ||
public function iClickTheElement(string $selector): void | ||
{ | ||
$page = $this->getMainContext()->getSession()->getPage(); | ||
$element = $page->find('css', $selector); | ||
assertNotNull($element, sprintf('Element %s not found', $selector)); | ||
$element->click(); | ||
} | ||
|
||
/** | ||
* @When /^I should see the text "([^"]+)" in the "([^"]+)" element$/ | ||
* @param $selector | ||
*/ | ||
public function iShouldSeeTheTextInTheElement(string $text, string $selector): void | ||
{ | ||
$page = $this->getMainContext()->getSession()->getPage(); | ||
/** @var NodeElement $element */ | ||
$element = $page->find('css', $selector); | ||
assertNotNull($element, sprintf('Element %s not found', $selector)); | ||
assertSame($text, $element->getText()); | ||
} | ||
|
||
/** | ||
* @Given /^There is a login session for a second device$/ | ||
*/ | ||
public function thereIsALoginSessionForASecondDevice(): void | ||
{ | ||
$loginSession = $this->createLoginSession(); | ||
$loginSession->UserAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)'; | ||
$loginSession->write(); | ||
} | ||
|
||
private function createLoginSession(): LoginSession | ||
{ | ||
$request = Controller::curr()->getRequest(); | ||
return LoginSession::generate($this->getMember(), false, $request); | ||
} | ||
|
||
private function getMember(): Member | ||
{ | ||
/** @var Member $member */ | ||
$member = Member::get()->find('FirstName', 'ADMIN'); | ||
return $member; | ||
} | ||
} |