Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
@core @core_admin @core_webservice
2
Feature: Manage external services tokens
3
  In order to manage external service usage
4
  As an admin
5
  I need to be able to create, filter and delete tokens
6
 
7
  Background:
8
    Given the following "users" exist:
9
      | username  | password  | firstname     | lastname    |
10
      | user1     | user1     | Firstname1    | Lastname1   |
11
      | user2     | user2     | Firstname2    | Lastname2   |
12
      | user3     | user3     | Firstname3    | Lastname3   |
13
      | user4     | user4     | Firstname4    | Lastname4   |
14
 
15
  @javascript
16
  Scenario: Add a token to user identified by name and then delete that token
17
    Given I log in as "admin"
18
    And I am on site homepage
19
    And I navigate to "Server > Web services > Manage tokens" in site administration
20
    And I press "Create token"
21
    And I set the field "Name" to "Webservice1"
22
    And I set the field "User" to "Firstname1 Lastname1"
23
    And I set the field "Service" to "Moodle mobile web service"
24
    And I set the field "IP restriction" to "127.0.0.1"
25
    When I press "Save changes"
26
    Then the following should exist in the "generaltable" table:
27
      | Name        | User                 | Service                   | IP restriction | Last access |
28
      | Webservice1 | Firstname1 Lastname1 | Moodle mobile web service | 127.0.0.1      | Never       |
29
 
30
    # Verify the message and the "Copy to clipboard" button.
31
    And I should see "Copy the token now. It won't be shown again once you leave this page."
32
    And "Copy to clipboard" "button" should exist
33
 
34
    # New token can only read once.
35
    And I reload the page
36
    And I should not see "Copy the token now. It won't be shown again once you leave this page."
37
    And "Copy to clipboard" "button" should not exist
38
 
39
    # Delete token.
40
    And I change the window size to "large"
41
    And I press "Delete" action in the "Webservice1" report row
42
    And I should see "Do you really want to delete this web service token for Firstname1 Lastname1 on the service Moodle mobile web service?"
43
    And I press "Delete"
44
    And "Webservice1" "table_row" should not exist
45
 
46
  @javascript @skip_chrome_zerosize
47
  Scenario: Tokens can be filtered by name (case-insensitive), by user and by service
48
    Given the following "core_webservice > Service" exists:
49
      | name      | Site information              |
50
      | shortname | siteinfo                      |
51
      | enabled   | 1                             |
52
    And the following "core_webservice > Service function" exists:
53
      | service   | siteinfo                      |
54
      | functions | core_webservice_get_site_info |
55
    And the following "core_webservice > Tokens" exist:
56
      | user      | service                       | name           | validuntil       |
57
      | user2     | siteinfo                      | WEBservice1    | ## yesterday ##  |
58
      | user3     | moodle_mobile_app             | webservicE3    | ## +1 year ##    |
59
      | user4     | siteinfo                      | New service2   | ## +1 year ##    |
60
    When I log in as "admin"
61
    And I navigate to "Server > Web services > Manage tokens" in site administration
62
 
63
    # All created tokens are shown by default.
64
    And "Firstname1 Lastname1" "table_row" should not exist
65
    And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
66
    And I should see "Moodle mobile web service" in the "Firstname3 Lastname3" "table_row"
67
    And I should see "Site information" in the "Firstname4 Lastname4" "table_row"
68
 
69
    # Filter tokens by by name.
70
    And I click on "Filters" "button"
71
    And I set the following fields in the "Name" "core_reportbuilder > Filter" to these values:
72
      | Name operator   | Contains    |
73
      | Name value      | webservice  |
74
    And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
75
    And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
76
    And I should see "Moodle mobile web service" in the "Firstname3 Lastname3" "table_row"
77
    And "Firstname4 Lastname4" "table_row" should not exist
78
    And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
79
 
80
    # Filter tokens by user.
81
    And I set the following fields in the "User" "core_reportbuilder > Filter" to these values:
82
      | User operator   | Contains            |
83
      | User value      | Firstname2          |
84
    And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
85
    Then "Firstname3 Lastname3" "table_row" should not exist
86
    And "Firstname4 Lastname4" "table_row" should not exist
87
    And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
88
    And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
89
 
90
    # Filter tokens by service.
91
    And I set the following fields in the "Service" "core_reportbuilder > Filter" to these values:
92
      | Service value     | Site information |
93
    And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
94
    And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
95
    And I should see "Site information" in the "Firstname4 Lastname4" "table_row"
96
    And "Firstname3 Lastname3" "table_row" should not exist
97
    And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
98
 
99
    # Filter tokens by valid date.
100
    And I set the following fields in the "Valid until" "core_reportbuilder > Filter" to these values:
101
      | Valid until operator | Last   |
102
      | Valid until value    | 2      |
103
      | Valid until unit     | day(s) |
104
    And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
105
    Then "Firstname3 Lastname3" "table_row" should not exist
106
    And "Firstname4 Lastname4" "table_row" should not exist
107
    And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
108
 
109
    # Reset the filters.
110
    And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
111
    And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
112
    And I should see "Moodle mobile web service" in the "Firstname3 Lastname3" "table_row"
113
    And I should see "Site information" in the "Firstname4 Lastname4" "table_row"
114
 
115
  @javascript
116
  Scenario: Tokens table should display missing capabilities
117
    Given the following "core_webservice > Services" exist:
118
      | name            | shortname     | enabled |
119
      | Test Service 1  | testservice1  | 1       |
120
      | Test Service 2  | testservice2  | 1       |
121
    And the following "core_webservice > Service functions" exist:
122
      | service       | functions                           |
123
      | testservice1  | block_accessreview_get_module_data  |
124
      | testservice2  | core_block_fetch_addable_blocks     |
125
    And the following "core_webservice > Tokens" exist:
126
      | user      | service       | name        |
127
      | user1     | testservice1  | Token 01    |
128
      | user2     | testservice2  | Token 02    |
129
    When I log in as "admin"
130
    And I navigate to "Server > Web services > Manage tokens" in site administration
131
    # Check the missing capabilities.
132
    Then I should see "View the accessibility review" in the "Token 01" "table_row"
133
    And I should see "block/accessreview:view" in the "Token 01" "table_row"
134
    Then I should see "Manage blocks on a page" in the "Token 02" "table_row"
135
    And I should see "moodle/site:manageblocks" in the "Token 02" "table_row"