Skip to content

Commit

Permalink
Dev (#5)
Browse files Browse the repository at this point in the history
* version update

* quiet docker

* quiet docker

* quiet docker

* quiet docker

* quiet docker

* quiet docker
  • Loading branch information
ewallah committed Nov 12, 2020
1 parent 4e169eb commit ab34bc6
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 98 deletions.
14 changes: 8 additions & 6 deletions .travis.yml
Expand Up @@ -27,6 +27,7 @@ env:

jobs:
include:
#- env: DB=mysqli MOODLE_BRANCH=MOODLE_38_STABLE
- env: DB=mysqli MOODLE_BRANCH=MOODLE_39_STABLE
- env: DB=mysqli MOODLE_BRANCH=MOODLE_310_STABLE

Expand All @@ -39,10 +40,8 @@ before_install:
install:
#- moodle-plugin-ci add-plugin --clone https://github.com/ewallah/moodle-local_aws.git
- moodle-plugin-ci add-plugin --clone https://github.com/catalyst/moodle-local_aws.git
- moodle-plugin-ci install
- moodle-plugin-ci install -q
- cd moodle

script:
- moodle-plugin-ci phplint
- moodle-plugin-ci phpcpd
- moodle-plugin-ci phpmd
Expand All @@ -52,14 +51,17 @@ script:
- moodle-plugin-ci savepoints
- moodle-plugin-ci mustache
- moodle-plugin-ci grunt
- moodle-plugin-ci behat -q --profile default blocks/admin_bookmarks
- moodle-plugin-ci behat -q --profile chrome blocks/admin_bookmarks
- vendor/bin/phpunit --testsuite core_privacy_testsuite,tool_dataprivacy_testsuite

script:
- moodle-plugin-ci phpunit --coverage-text --coverage-clover
- moodle-plugin-ci behat --profile chrome blocks/admin_bookmarks
- moodle-plugin-ci behat
- moodle-plugin-ci behat --profile chrome
- php admin/tool/behat/cli/init.php -a="classic"
- php admin/tool/behat/cli/init.php -a="classic" > /dev/null
- moodle-plugin-ci behat --suite="classic"
- moodle-plugin-ci behat --suite="classic" --profile chrome
- vendor/bin/phpunit --testsuite core_privacy_testsuite,tool_dataprivacy_testsuite > /dev/null

after_success:
- moodle-plugin-ci coveralls-upload
4 changes: 3 additions & 1 deletion db/access.php
Expand Up @@ -26,9 +26,11 @@
defined('MOODLE_INTERNAL') || die();

$capabilities = [
'repository/s3bucket:view' => ['captype' => 'write', 'contextlevel' => CONTEXT_MODULE,
'repository/s3bucket:view' => ['captype' => 'read', 'contextlevel' => CONTEXT_MODULE,
'archetypes' => ['editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW]],
'repository/s3bucket:addinstance' => ['captype' => 'write', 'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => ['manager' => CAP_ALLOW]],
'repository/s3bucket:addinstance' => ['captype' => 'write', 'contextlevel' => CONTEXT_USER,
'archetypes' => ['editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW]],
'repository/s3bucket:addinstance' => ['captype' => 'write', 'contextlevel' => CONTEXT_COURSE,
'archetypes' => ['editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW]]];
67 changes: 0 additions & 67 deletions tests/behat/s3bucket.feature

This file was deleted.

88 changes: 88 additions & 0 deletions tests/behat/s3bucket_course.feature
@@ -0,0 +1,88 @@
@repository @repository_s3bucket @javascript
Feature: S3 bucket repository is private in user context

Background:
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
| Course 2 | C2 | 0 |
And the following "users" exist:
| username | email | firstname | lastname |
| student | s@example.com | Student | 1 |
| teacher | t@example.com | Teacher | 1 |
| facilitator | f@example.com | Teacher | 2 |
And the following "course enrolments" exist:
| user | course | role |
| student | C1 | student |
| teacher | C1 | editingteacher |
| teacher | C2 | editingteacher |
| facilitator | C1 | editingteacher |
And I enable repository "s3bucket"
And I log in as "admin"
And I navigate to "Plugins > Repositories > Amazon S3 bucket" in site administration
And I click on "Allow users to add a repository instance into the course" "checkbox"
And I click on "Save" "button"
And I log out
And I log in as "teacher"
And I am on "Course 1" course homepage with editing mode on
And I navigate to "Repositories" in current page administration
And I follow "Create \"Amazon S3 bucket\" instance"
And I set the field "Name" to "Course 1 Bucket"
And I set the field "Bucket name" to "coursebucket"
And I set the field "Access key" to "anoTherfake@1"
And I set the field "Secret key" to "anotherFake_$2"
And I click on "Save" "button"
And I log out

Scenario: A teacher can add files from the s3 bucket repository in course context
When I log in as "teacher"
And I am on "Course 1" course homepage with editing mode on
When I add a "Folder" to section "1"
And I set the following fields to these values:
| Name | Folder name |
| Description | Folder description |
And I click on "Add..." "button" in the "Files" "form_row"
Then I should see "Course 1 Bucket"

Scenario: A teacher cannot see the s3 bucket repository in another course context
When I log in as "teacher"
And I am on "Course 2" course homepage with editing mode on
And I navigate to "Repositories" in current page administration
Then I should not see "Course 1 Bucket"

Scenario: Another teacher can see the s3 bucket repository in same course context
When I log in as "facilitator"
And I am on "Course 1" course homepage with editing mode on
When I add a "Folder" to section "1"
And I set the following fields to these values:
| Name | Folder name |
| Description | Folder description |
And I click on "Add..." "button" in the "Files" "form_row"
Then I should see "Course 1 Bucket"

Scenario: A student cannot see a s3 course bucket
When I log in as "teacher"
And I am on "Course 1" course homepage with editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
| Assignment name | Test assignment name |
| Description | Submit your online text |
| assignsubmission_onlinetext_enabled | 0 |
| assignsubmission_file_enabled | 1 |
| Maximum number of uploaded files | 2 |
And I log out
And I log in as "student"
And I am on "Course 1" course homepage
And I follow "Test assignment name"
When I press "Add submission"
And I follow "Add..."
Then I should not see "Course 1 Bucket"

Scenario: An admin can see a s3 course bucket
When I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
When I add a "Folder" to section "1"
And I set the following fields to these values:
| Name | Folder name |
| Description | Folder description |
And I click on "Add..." "button" in the "Files" "form_row"
Then I should see "Course 1 Bucket"
@@ -1,5 +1,5 @@
@repository @repository_s3bucket @_file_upload
Feature: S3 bucket repository should be seen by admins
Feature: S3 bucket global repositories should be seen by admins and teachers

Background:
Given the following "courses" exist:
Expand All @@ -17,24 +17,21 @@ Feature: S3 bucket repository should be seen by admins
And I log in as "admin"
And I navigate to "Plugins > Repositories > Amazon S3 bucket" in site administration
And I click on "Create a repository instance" "button"
And I set the following fields to these values:
| name | Testrepo |
| bucket_name | Testbucket |
And I click on "Save" "button"
Then I should see "Required"
And I set the field "Name" to "Global bucket"
And I set the field "Bucket name" to "globalbucket"
And I set the field "Access key" to "anoTherfake@1"
And I set the field "Secret key" to "anotherFake_$2"
And I click on "Save" "button"
And I log out

@javascript
Scenario: An admin can see the s3 bucket repository
Scenario: An admin can see the global s3 bucket repository
When I log in as "admin"
Then I should see "No files available" in the "Private files" "block"
And I follow "Manage private files..."
And I click on "Add..." "button" in the "Files" "form_row"
Then I should see "Testrepo"
And I follow "Testrepo"
Then I should see "Global bucket"
And I follow "Global bucket"
Then I should see "2020_dir"
And I should see "2020_f.jpg"
And I follow "2020_f.jpg"
Expand All @@ -47,12 +44,12 @@ Feature: S3 bucket repository should be seen by admins
And I should see "2020_f.jpg" in the "Private files" "block"

@javascript
Scenario: An admin can search the s3 bucket repository
Scenario: An admin can search the global s3 bucket repository
When I log in as "admin"
And I follow "Manage private files..."
And I click on "Add..." "button" in the "Files" "form_row"
Then I should see "Testrepo"
And I follow "Testrepo"
Then I should see "Global bucket"
And I follow "Global bucket"
Then I should see "2" elements in repository content area
And I click on "Display folder with file details" "link" in the ".file-picker" "css_element"
And I click on "Display folder as file tree" "link" in the ".file-picker" "css_element"
Expand All @@ -65,23 +62,23 @@ Feature: S3 bucket repository should be seen by admins
When I press enter
Then I should see "0" elements in repository content area

Scenario: A teacher cannot see the s3 bucket repository in private area
Scenario: A teacher cannot see the global s3 bucket repository in private area
When I log in as "teacher"
And I follow "Manage private files..."
And I click on "Add..." "button" in the "Files" "form_row"
Then I should not see "Testrepo"
Then I should not see "Global bucket"

@javascript
Scenario: A teacher can see the s3 bucket repository in a course module
Scenario: A teacher can see the global s3 bucket repository in a course module
When I log in as "teacher"
And I am on "Course 1" course homepage with editing mode on
When I add a "Folder" to section "1"
And I set the following fields to these values:
| Name | Folder name |
| Description | Folder description |
And I click on "Add..." "button" in the "Files" "form_row"
Then I should see "Testrepo"
And I follow "Testrepo"
Then I should see "Global bucket"
And I follow "Global bucket"
Then I should see "2020_dir"
And I should see "2020_f.jpg"
And I follow "2020_f.jpg"
Expand All @@ -93,23 +90,23 @@ Feature: S3 bucket repository should be seen by admins
And I should see "2020_f.jpg"

@javascript
Scenario: A teacher can add a s3 bucket link in a url module
Scenario: A teacher can add a global s3 bucket link in a url module
When I log in as "teacher"
And I am on "Course 1" course homepage with editing mode on
When I add a "URL" to section "1" and I fill the form with:
| Name | Url name |
And I click on "Choose a link..." "button"
Then I should see "Testrepo"
And I follow "Testrepo"
Then I should see "Global bucket"
And I follow "Global bucket"
Then I should see "2020_dir"
And I should see "2020_f.jpg"
And I follow "2020_f.jpg"
And I click on "Select this file" "button"
And I click on "Save and return to course" "button"
Then I should see "Url name"

Scenario: A student cannot see the s3 bucket repository
Scenario: A student cannot see the global s3 bucket repository
When I log in as "student"
And I follow "Manage private files..."
And I click on "Add..." "button" in the "Files" "form_row"
Then I should not see "Testrepo"
Then I should not see "Global bucket"

0 comments on commit ab34bc6

Please sign in to comment.