(Copied from MDL-80641 and adjusted for the new SMS gateway feature)
When it comes to testing, this resource for testing SMS sending in AWS will likely come in handy: https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html
Prerequisites
- To test this issue, you'll need a Moodle to which you have admin access.
- You will need a resource to test SMS sending in AWS.
- An admin account makes it easier to move through all the test settings. If you don't have CLI access to the instance, ensure access to two separate admin accounts. As part of the testing, it will lock out a user.
Setup
More detailed setup instructions for MFA testing can be found in MDL-78509, the following setup are just the basics and there is some assumed knowledge.
Set up your SMS Sandbox
- Access to https://signin.aws.amazon.com with your credentials.
- From your AWS Console, go to Amazon SNS > Mobile > Text messaging(SMS) and enable it.
- Include some "Sandbox destination phone numbers"
- From Security credentials: create a new Access keys for this and save the "Key", "Secret" and "Region" for the configuration in Moodle.
More information about SMS sandbox can be found at:
Test third-party libraries
- As an admin, go to Site Administration > Development > Third-party libraries.
- Verify that the library "JMESPath" is at version 2.8.0.
Test Mobile phone SMS Authentication:
- Access your Moodle as an admin user.
- Go to Site Administration > Plugins > Admin tools > Multi-factor authentication
- Enable the "MFA plugin enabled" Checkbox
- Go to Site Administration > Plugins > SMS > Manage SMS gateways
- Click "Create a new SMS gateway"
- Enter "AWS SNS" as Gateway name and enter the AWS credentials created before as Access key, Secret access key and Amazon API gateway region.
- Go to Site Administration > Plugins > Admin tools > Multi-factor authentication > Mobile phone SMS
- Select the "AWS SNS" gateway created just before, enable the factor and save the changes.
- Access to your user preferences / "Multi-factor authentication preferences"
- Set up the "Mobile phone SMS" factor with a test phone number.
- Verify you have received an SMS on your phone number
- Enter the code you received and continue.
- Open another browser and access Moodle with your user
- Enter your username and password,
- Verify that a new screen will be displayed where it will ask for the mobile phone SMS.
- Verify you have received an SMS on your mobile.
- Enter the code in the box and click on verify code
- Verify that you have been logged in successfully and you have access to Moodle.
NOTE 1: If you mess things up and lock yourself out, you can disable the whole MFA plugin from the CLI:
php admin/cli/cfg.php --component=tool_mfa --name=enabled --set=0
|
NOTE 2: Reset user authentication factors
- Access to your Moodle as an admin user
- Go to Site Administration > Plugins > Admin tools > Multi-factor authentication > Reset user authentication factors
- Search by one user with authentication factors
- Click on the button "Reset user factor"
PHP Unit tests
Please run PHPUnit for admin/tool/mfa/factor/sms/tests/factor_test.php
for the MDK can use the below command:
mdk phpunit -r -u admin/tool/mfa/factor/sms/tests/factor_test.php
|
Or
vendor/bin/phpunit admin/tool/mfa/factor/sms/tests/factor_test.php
|