You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 2, 2025. It is now read-only.
:description:Multifactor authentication allows your test to authenticate to a target page by sending it a code it receives through email.
9
9
10
10
11
-
PLACEHOLDER.
11
+
.. :note:: This authentication method applies to browser tests only.
12
+
13
+
If your test target sends a one time passcode (OTP) through email for multifactor authentication, your browser test must retrieve the OTP from the email message and enter it into the input field on the target's page. To do this, configure your browser test as follows.
14
+
15
+
16
+
Prerequisites
17
+
============================
18
+
19
+
You must have an email service that supports connecting to your email account and managing your emails through an API. The steps below feature an example using the :new-page:`Nylas service <http://nylas.com>`. For detailed information on how to retrieve messages from this service, refer to its :new-page:`API documentation https://developer.nylas.com/docs/api/v3/ecc/?redirect=api#get-/v3/grants/-grant_id-/messages`.
20
+
21
+
Additionally, the steps below demonstrate the use of http://Github.com to send an authorization email, which is essential for extracting the OTP from it.
22
+
23
+
Limitations
24
+
============================
25
+
26
+
Your email service must be accessible through an API. Some services may not be accessible during Synthetics tests due to violations of Content-Security-Policy (CSP). In such instances, a workaround is to implement third-party services on your server and provide an endpoint configured with CSP to allow connect-src.
27
+
28
+
1. On the browser test's configuration page, select the :guilabel:`Simple` toggle.
29
+
30
+
2. select :guilabel:`Edit steps or synthetic transactions`.
31
+
32
+
3. Add a step of type :guilabel:`Go to url`, and in :guilabel:`URL`, enter the URL of the target's authentication page.
33
+
34
+
4. Add a step of type :guilabel:`Save return value from JavaScript`, and in the code field, paste the following JavaScript.
35
+
This script retrieves data from a specified URL using ``XMLHttpRequest`` and extracts the OTP from that data. You configure your test to save this OTP in a custom variable named ``otp``.
36
+
.. :note:: In the script, set the variable url to the URL of your own email inbox API endpoint.
37
+
.. :note:: If you are utilizing the Nylas service, you can locate unread emails by searching for specific text in the subject line or other parameters. For more information, please refer to the :new-page:`Nylas API documentation for messages <https://developer.nylas.com/docs/api/v3/ecc/?redirect=api#get-/v3/grants/-grant_id-/messages>`.
return match[0]; // Return the first matched number
65
+
}
66
+
}
67
+
return"NO-OTP";
68
+
}
69
+
returngetOtp();
70
+
71
+
5. Add a step of type :guilabel:`Wait`:, and specify a wait time in milliseconds. This time needs to be long enough for the target to send the OTP code to your email service, and for your JavaScript to process the OTP.
72
+
73
+
6. Add a step of type :guilabel:`Fill in field`, and set it up as follows:
74
+
75
+
1. In :guilabel:Selec`tor, enter the ID of the element on the target page where the user must enter the OTP.
76
+
77
+
2. In :guilabel:`Value`, enter the name of the custom varialble your JavaScript stored the OTP in, prefixed with custom. and enclosed in double curly braces. For example, ``{{custom.otp}}``.
7. To verify that the login succeeded, add a step of type :guilabel:`Assert text present`, and set it up as follows:
84
+
85
+
1. In :guilabel:`Text`, enter a string that should be visible on the test target page only when login is successful.
86
+
87
+
2. (Optional) Set :guilabel:`Wait for up to` to a large enough value, in milliseconds, to ensure that the page loads.
88
+
89
+
8. Select :guilabel:`Submit`.
90
+
91
+
To verify that the login is working, select :guilabel:`Try now`. Results may take a while. The :guilabel:`Try now result` pane should display each screen that your test navigated to on the target page, plus the message :guilabel:`Success`.
Copy file name to clipboardExpand all lines: synthetics/test-config/auth-multifactor-sms.rst
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,15 +43,13 @@ Some services may not be accessible during Synthetics tests due to violations of
43
43
:width:70%
44
44
:alt:Screenshot showing the "Go to URL" step.
45
45
46
-
47
-
4. Add a step of type :guilabel:`Save return value from JavaScript`, and in the code field, paste the following JavaScript.
48
-
This script retrieves data from a specified URL using ``XMLHttpRequest`` and extracts the OTP from that data. You configure your test to save this OTP in a global variable named ``otp``.
46
+
4. Add a step of type :guilabel:`Save return value from JavaScript`, and in the code field, paste the following JavaScript. This script retrieves data from a specified URL using ``XMLHttpRequest`` and extracts the OTP from that data. You configure your test to save this OTP in a global variable named ``otp``.
49
47
50
48
.. :note:: In the script, set the variable url to the URL of your own virtual phone number's SMS service.
:alt:Screenshot showing the JavaScript that retrieves data from a specified URL.
55
53
56
54
.. code-block:: javascript
57
55
@@ -87,7 +85,7 @@ Some services may not be accessible during Synthetics tests due to violations of
87
85
88
86
2. In :guilabel:`Value`, enter the name of the custom varialble your JavaScript stored the OTP in, prefixed with custom. and enclosed in double curly braces. For example, ``{{custom.otp}}``.
:description:Multifactor authentication allows your test to authenticate to a target page by logging in through an SSO or Active Directory service.
9
9
10
10
11
-
PLACEHOLDER.
11
+
Authorization through Single Sign-On (SSO) is similar to :ref:`basic authentication <auth-basic-html-login>`. To create a test of that uses SSO or AD login, you must configure a series of steps that include opening the webpage, selecting the SSO authentication link, and entering the required information for SSO authentication. Additional webpages may load during this process, so it's crucial that you include steps to confirm that all the components of each webpage have fully loaded before proceeding.
12
+
13
+
SSO authentication frequently involves additional authentication factors. If the identity provider (such as Google, Microsoft, Okta, Duo, and so on) does not mandate an extra login factor, your test might only need the authentication steps that are illustrated in the example below:
:alt:Screenshot showing steps to create in a synthetic test that authenicates with SSO or Active Directory.
18
+
19
+
20
+
Limitations
21
+
======================================
22
+
23
+
Identity providers often require various additional factors for login, such as verification via email, SMS, or TOTP. In such cases, it is essential to modify or add steps to accommodate these additional login factors.
0 commit comments