From 3e5546c176a3b9a00cc96b824b1c91765bdd9e2a Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Fri, 1 Oct 2021 19:45:23 +1300 Subject: [PATCH] MNT Add behat tests --- .travis.yml | 2 +- behat.yml | 29 +++++++++++++ composer.json | 5 ++- tests/behat/_manifest_exclude | 0 tests/behat/features/securityreport.feature | 41 +++++++++++++++++++ tests/behat/files/blank.txt | 0 tests/behat/src/FeatureContext.php | 9 ++++ tests/behat/src/FixtureContext.php | 9 ++++ tests/{ => php}/MemberReportExtensionTest.php | 0 tests/{ => php}/MemberReportExtensionTest.yml | 0 tests/{ => php}/SubsitesReportTest.php | 0 tests/{ => php}/SubsitesReportTest.yml | 0 tests/{ => php}/UserSecurityReportTest.php | 0 tests/{ => php}/UserSecurityReportTest.yml | 0 14 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 behat.yml create mode 100644 tests/behat/_manifest_exclude create mode 100644 tests/behat/features/securityreport.feature create mode 100644 tests/behat/files/blank.txt create mode 100644 tests/behat/src/FeatureContext.php create mode 100644 tests/behat/src/FixtureContext.php rename tests/{ => php}/MemberReportExtensionTest.php (100%) rename tests/{ => php}/MemberReportExtensionTest.yml (100%) rename tests/{ => php}/SubsitesReportTest.php (100%) rename tests/{ => php}/SubsitesReportTest.yml (100%) rename tests/{ => php}/UserSecurityReportTest.php (100%) rename tests/{ => php}/UserSecurityReportTest.yml (100%) diff --git a/.travis.yml b/.travis.yml index ac7700c..8eabb2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ version: ~> 1.0 import: - - silverstripe/silverstripe-travis-shared:config/provision/standard-jobs-range.yml + - silverstripe/silverstripe-travis-shared:config/provision/standard-jobs-range-behat.yml env: global: diff --git a/behat.yml b/behat.yml new file mode 100644 index 0000000..48bee82 --- /dev/null +++ b/behat.yml @@ -0,0 +1,29 @@ +default: + suites: + securityreport: + paths: + - "%paths.modules.securityreport%/tests/behat/features" + contexts: + - SilverStripe\Admin\Tests\Behat\Context\AdminContext + - SilverStripe\BehatExtension\Context\BasicContext + - SilverStripe\BehatExtension\Context\EmailContext + - SilverStripe\BehatExtension\Context\LoginContext + - SilverStripe\Framework\Tests\Behaviour\CmsFormsContext + - SilverStripe\Framework\Tests\Behaviour\CmsUiContext + - SilverStripe\SecurityReport\Tests\Behat\Context\FeatureContext + - SilverStripe\SecurityReport\Tests\Behat\Context\FixtureContext + - + SilverStripe\SecurityReport\Tests\Behat\Context\FixtureContext: + - "%paths.modules.securityreport%/tests/behat/files/" + + extensions: + 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" + + SilverStripe\BehatExtension\Extension: + screenshot_path: "%paths.base%/artifacts/screenshots" + bootstrap_file: vendor/silverstripe/framework/tests/behat/serve-bootstrap.php diff --git a/composer.json b/composer.json index 4db8db0..d0e0de7 100644 --- a/composer.json +++ b/composer.json @@ -27,9 +27,10 @@ "autoload": { "psr-4": { "SilverStripe\\SecurityReport\\": "src/", - "SilverStripe\\SecurityReport\\Tests\\": "tests/" + "SilverStripe\\SecurityReport\\Tests\\": "tests/", + "SilverStripe\\SecurityReport\\Tests\\Behat\\Context\\": "tests/behat/src/" } }, "minimum-stability": "dev", "prefer-stable": true -} \ No newline at end of file +} diff --git a/tests/behat/_manifest_exclude b/tests/behat/_manifest_exclude new file mode 100644 index 0000000..e69de29 diff --git a/tests/behat/features/securityreport.feature b/tests/behat/features/securityreport.feature new file mode 100644 index 0000000..4ed925b --- /dev/null +++ b/tests/behat/features/securityreport.feature @@ -0,0 +1,41 @@ +Feature: Security report + As a website user + I want to use the security report + + Background: + Given the "group" "EDITOR group" has permissions "CMS_ACCESS_LeftAndMain" and "FILE_EDIT_ALL" + + # Login as EDITOR to create member + And I am logged in with "EDITOR" permissions + + # Logout and login again as ADMIN + And I go to "/Security/login" + And I press the "Log in as someone else" button + And I am logged in with "ADMIN" permissions + + # Create a subsite + And I go to "/admin/subsites" + And I press the "Add Subsite" button + And I fill in "Subsite Name" with "My subsite" + And I press the "Create" button + + Scenario: Operate the security report + + # Show members + When I go to "/admin/reports" + And I follow "Users, Groups and Permissions" + + # Assert firstname, surname and email + Then I should see "EDITOR" + And I should see "User" + And I should see "EDITOR@example.org" + + # Groups column + And I should see "EDITOR group (global group)" + + # Permissions column + Then I should see "Edit any file" + And I should see "Full administrative rights" + + # Subsites column + And I should see "Main site, My subsite" diff --git a/tests/behat/files/blank.txt b/tests/behat/files/blank.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/behat/src/FeatureContext.php b/tests/behat/src/FeatureContext.php new file mode 100644 index 0000000..a0b8726 --- /dev/null +++ b/tests/behat/src/FeatureContext.php @@ -0,0 +1,9 @@ +