Commit 08d5eeab authored by Steven Spinelli's avatar Steven Spinelli Committed by Robert Lyon
Browse files

Behat Bug 1690291 create one file instead of 4 feature files and remove redundant code to

make the Behat code more streamline

- make the comments more sensible

Change-Id: Ie25f89abb074e7d06f2f0d60a3e36fb04fd3bee8
parent 260b9431
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@javascript @core @core_administration @core_webservices
Feature: Show better human readable tooltip for app token

Scenario: Admin set up preconditions for test and confirm that the title text is Delete "Manually created"
    Given I log in as "admin" with password "Kupuh1pa!"
    And I choose "Configuration" in "Web services" from administration menu
    And I enable the switch "Allow outgoing web service requests:"
    And I enable the switch "Accept incoming web service requests:"
    And I enable the switch "REST:"
    And I choose "Plugin administration" in "Extensions" from administration menu
    And I follow "Configuration for module mobileapi"
    And I enable the switch "Manual token generation"
    And I press "Save"
    When I choose "Connected apps" in "Settings" from user menu
    And I follow "Mahara Mobile" in the ".arrow-bar" "css_element"
    And I click on "Generate"
    # confirm that there is an element with title=Delete "Manually created"
    # This is done by pressing a button with that title as there is no definition for see element with that title attribute
    Then I press "Delete \"Manually created\""
+106 −0
Original line number Diff line number Diff line
@javascript @core @core_administration @core_webservices
Feature: To create and test a webservice service group
In order to use webservices
As an admin
So I can benefit from the cross over of Moodle/Mahara
and check correct group fields are returned

Background:
  Given the following "institutions" exist:
     | name | displayname   | authname   |
     | one  | Institution 1 | webservice |
  And the following "users" exist:
     | username     | password  | email             | firstname | lastname | institution | authname   | role   |
     | serviceadmin | Kupuh1pa! | svad@example.com  | Service   | Admin    | one         | webservice | admin  |
     | UserA        | Kupuh1pa! | UserA@example.org | Angela    | User     | mahara      | internal   | member |
  And the following "groups" exist:
     | name    | owner | description        | grouptype | open | invitefriends | editroles | submittableto | allowarchives | members | staff | institution |
     | Group A | admin | This is my group A | standard  | ON   | OFF           | all       | OFF           | OFF           | admin   |       | one         |

Scenario: As administrator I can
 1) Check enabling Requester and Provider master switches requires a protocol
 2) Create and verify service groups
 3) Enable Mahara mobile and set a manually created access token and confirm that the manually created token can be deleted
    Given I log in as "admin" with password "Kupuh1pa!"
    And I choose "Configuration" in "Web services" from administration menu
    And I enable the switch "Allow outgoing web service requests:"
    And I enable the switch "Accept incoming web service requests:"
    # Verify that error message is displayed if no protocols are selected
    And I should see "You need to enable at least one protocol"
    And I enable the switch "REST:"
    And I expand the section "Manage service groups"
    And I set the field "service" to "Test service"
    And I press "Add"
    And I scroll to the top
    And I wait "1" seconds
    And I click on "Edit" in "Test service" row
    And I set the field "Short name" to "testservice"
    And I enable the switch "Service"
    And I enable the switch "User token access"
    And I enable the switch in "mahara_group_get_groups_by_id" row
    And I enable the switch in "mahara_group_create_groups" row
    And I enable the switch in "mahara_group_update_groups" row
    And I press "Save"
    # Verify service group was made
    And I should see "mahara_group_create_groups"
    And I collapse "Manage service groups" node
    And I wait "1" seconds
    And I expand the section "Manage service access tokens"
    And I fill in select2 input "webservices_token_generate_userid" with "Service" and select "Service Admin (serviceadmin)"
    And I press "Generate token"
    And I select "Institution 1" from "Institution"
    And I select "Test service" from "Service"
    # Verify I should see the xmlrpc specific fields  when Enable web services security (XML-RPC Only) is toggled to yes
    When I enable the switch "Enable web services security (XML-RPC Only)"
    Then I should see "Public key expires"
    # Hide the xmlrpc specific fields when not using them In the add/edit webservice users/tokens screens
    And I disable the switch "Enable web services security (XML-RPC Only)"
    Then I should not see "Public key expires"
    And I press "Save"
    # Verify token was made and Test the token
    And I should see "Edit" in the "#webservices_token_pseudofieldset" element
    And I choose "Test client" in "Web services" from administration menu
    Then I should see "This is the interactive test client facility for web services."
    # Verify Text on Web service test client | Web services configuration page with and without a protocol
    And I should not see "The web service authentication plugin is disabled."
    And I press "Next"
    And I select "Test service (Token)" from "Service"
    And I press "Next"
    And I select "mahara_group_get_groups_by_id" from "Functions"
    And I press "Next"
    And I fill in "groupa" for "shortname"
    And I select "Institution 1" from "Institution"
    And I fill in the wstoken for "Test service" owned by "Service Admin"
    ###
    # NOTE: Pressing "Execute" here fails as behat is not set up to handle webservice calls
    ###
    And I choose "Plugin administration" in "Extensions" from administration menu
    And I follow "Configuration for module mobileapi"
    And I enable the switch "Manual token generation"
    And I press "Save"
    When I choose "Connected apps" in "Settings" from user menu
    And I follow "Mahara Mobile" in the ".arrow-bar" "css_element"
    And I click on "Generate"
    Then I should see "Manually created"
    When I press "Delete \"Manually created\""
    Then I should see "You have not granted access to any applications"

 Scenario: As a student I can
  1) Check that I can't access the webservice administration area
  2) Generate a manual token once administrator has allowed this
    Given I log in as "admin" with password "Kupuh1pa!"
    And I choose "Plugin administration" in "Extensions" from administration menu
    And I follow "Configuration for module mobileapi"
    And I enable the switch "Auto-configure mobile apps API"
    And I enable the switch "Manual token generation"
    And I press "Save"
    And I log out
    When I log in as "UserA" with password "Kupuh1pa!"
    And I go to "webservice/admin/index.php"
    Then I should see "You are forbidden from accessing the administration section."
    When I choose "Connected apps" in "Settings" from user menu
    And I follow "Mahara Mobile" in the ".arrow-bar" "css_element"
    And I click on "Generate"
    Then I should see "Manually created"
    When I press "Delete \"Manually created\""
    Then I should see "You have not granted access to any applications"
+0 −71
Original line number Diff line number Diff line
@javascript @core @core_administration @core_webservices
Feature: To create and test a webservice service group
In order to use webservices
As an admin
So I can benefit from the cross over of Moodle/Mahara
and check correct group fields are returned

Background:
  Given the following "institutions" exist:
     | name | displayname | authname |
     | one | Institution 1 | webservice |
  And the following "users" exist:
     | username | password | email | firstname | lastname | institution | authname | role |
     | serviceadmin | Kupuh1pa! | svad@example.com | Service | Admin | one | webservice | admin |
  And the following "groups" exist:
     | name | owner | description | grouptype | open | invitefriends | editroles | submittableto | allowarchives | members | staff | institution |
     | Group A | admin | This is my group A | standard | ON | OFF | all | OFF | OFF | admin |  | one |

Scenario: Turning master switch on
 Given I log in as "admin" with password "Kupuh1pa!"
 And I choose "Configuration" in "Web services" from administration menu
 # Turning the master switch on
 And I enable the switch "Accept incoming web service requests:"
 And I enable the switch "REST:"
 # Create a new service group
 And I expand the section "Manage service groups"
 And I set the field "service" to "Test service"
 And I press "Add"
 And I scroll to the top
 And I wait "1" seconds
 And I click on "Edit" in "Test service" row
 And I set the field "Short name" to "testservice"
 And I enable the switch "Service"
 And I enable the switch "User token access"
 And I enable the switch in "mahara_group_get_groups_by_id" row
 And I enable the switch in "mahara_group_create_groups" row
 And I enable the switch in "mahara_group_update_groups" row
 And I press "Save"
 # Verify service group was made
 And I should see "mahara_group_create_groups"
 And I collapse "Manage service groups" node
 # Create a new token
 And I wait "1" seconds
 And I expand the section "Manage service access tokens"
 And I fill in select2 input "webservices_token_generate_userid" with "Service" and select "Service Admin (serviceadmin)"
 And I press "Generate token"
 And I select "Institution 1" from "Institution"
 And I select "Test service" from "Service"
 # Hide the xmlrpc specific fields when not using them In the add/edit webservice users/tokens screens
 And  I should not see "Public key expires"
 # I should see the xmlrpc specific fields  when Enable web services security (XML-RPC Only) is toggled to yes
 When I enable the switch "Enable web services security (XML-RPC Only)"
 Then I should see "Public key expires"
 And I disable the switch "Enable web services security (XML-RPC Only)"
 And I press "Save"
 # Verify the token was made
 And I should see "Edit" in the "#webservices_token_pseudofieldset" element
 # Test the token
 And I choose "Test client" in "Web services" from administration menu
 And I press "Next"
 And I select "Test service (Token)" from "Service"
 And I press "Next"
 And I select "mahara_group_get_groups_by_id" from "Functions"
 And I press "Next"
 And I fill in "groupa" for "shortname"
 And I select "Institution 1" from "Institution"
 And I fill in the wstoken for "Test service" owned by "Service Admin"

 # For some reason the submitting this form freezes behat
 # And I press "Execute"
 # Then I should see "editroles"
+0 −26
Original line number Diff line number Diff line
@javascript @core @core_administration @core_webservices
Feature: To enable webservices via the webservices configuration form
In order to use webservices
As an admin
So I can benefit from the cross over of Moodle/Mahara


Background:
Given the following "users" exist:
     | username | password | email | firstname | lastname | institution | authname | role |
     | UserA | Kupuh1pa! | UserA@example.org | Angela | User | mahara | internal | member |

Scenario: Turning master switch on
 Given I log in as "admin" with password "Kupuh1pa!"
 And I choose "Configuration" in "Web services" from administration menu
 # Turning the master switch on
 And I enable the switch "Accept incoming web service requests:"
 And I choose "Test client" in "Web services" from administration menu
 And I should not see "The web service authentication plugin is disabled"
 And I log out
 # Logging in as student to try turn switch on
 When I log in as "UserA" with password "Kupuh1pa!"
 Then I should see "Angela User"
 # Checking the student can't access the link
 And "Administration" "link" should not be visible
 And "Web services" "link" should not be visible
+0 −37
Original line number Diff line number Diff line
@javascript @core @core_administration @core_webservices
Feature: Accessing the webservices test client page
In order to be able to access the webservies menus successfully
As an admin
So I can benefit from the mahara/moodle cross over.

Scenario: Testing web service admin page on/off switches, and checking test client page is accessible (Bug 1431540)
 Given I log in as "admin" with password "Kupuh1pa!"
 And I choose "Configuration" in "Web services" from administration menu
 # Toggle Web service requester master switch
 And I disable the switch "Allow outgoing web service requests:"
 And I enable the switch "Allow outgoing web service requests:"
 # Turning the Web service provider master switch on
 And I enable the switch "Accept incoming web service requests:"
 # Turning the Web service provider master switch off so the protocols are disabled
 And I disable the switch "Accept incoming web service requests:"
 # Turning the Web service provider master switch back on
 And I enable the switch "Accept incoming web service requests:"
 And I should see "You need to enable at least one protocol"
 # Turning a protocol on
 And I enable the switch "SOAP:"
 # Navigating to the test client page to see if it is accessible
 And I choose "Test client" in "Web services" from administration menu
 Then I should see "This is the interactive test client facility for web services."
 And I should not see "Select elements should have at least one option"
 And I should not see "The web service authentication plugin is disabled."
 # Unchecking a protocol and going to test client page to check it gives warning message
 And I am on homepage
 And I go to "webservice/admin/index.php"
 # Turning protocol off
 And I disable the switch "SOAP:"
 # Going to webservices test client page
 When I go to "webservice/testclient.php"
 # The regression error that's appearing
 Then I should not see "Call stack (most recent first):"
 # What we do want to see
 And I should see "This is the interactive test client facility for web services. This enables you to select a function and then execute it live against the current system. Please be aware that ANY function you execute will run for real."