Skip to content

Commit 5b4c157

Browse files
2fa automation (#13)
* Update sms-based-two-factor-authentication-2fa.md * created new doc for email based 2-FA * created tutorials for sms and email based 2fa
1 parent 867dd3c commit 5b4c157

2 files changed

Lines changed: 163 additions & 2 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: "How to automate email based Two Factor Authentication(2FA)"
3+
metadesc: "Coming soon..."
4+
noindex: true
5+
order: 5.3
6+
page_id: "How to automate email based Two Factor Authentication(2FA)"
7+
search_keyword: "Web Application, Recorder, Testsigma Tutorials"
8+
warning: false
9+
contextual_links:
10+
- type: section
11+
- name: "Contents"
12+
- type: link
13+
name: "Prerequisites"
14+
url: "#prerequisites"
15+
- type: link
16+
name: "Steps for email-based 2FA automation"
17+
url: "#email-based-two-factor-authentication/#steps-for-email-based-2fa-automation"
18+
---
19+
---
20+
21+
## **Prerequisites**
22+
23+
<li>A Testsigma account. If you do not have one already, <a href="https://testsigma.com/signup">sign up for a free trial</a></li>
24+
<li>Understanding of creating and running test cases.</li>
25+
<li>Provisioned mailbox.</li>
26+
<li>Familiarity with regular expressions. If not, refer to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions">Regex guide - MDN Docs.</a></li>
27+
<br>
28+
29+
## **Steps for email-based 2FA automation**
30+
31+
### **Step 1: Record elements**
32+
33+
34+
Before moving on to the test case, you must capture elements on the login screen of your application. For more information on how to record elements using Testsigma chrome recorder extension, refer to
35+
<li><a href="https://testsigma.com/docs/elements/web-apps/record-multiple-elements/">Web application </a></li>
36+
<li><a href="https://testsigma.com/docs/elements/android-apps/record-multiple-elements/">Android</a> </li>
37+
<li><a href="">iOS</a></li>
38+
<br>
39+
40+
### **Step 2: Configure the mailbox**
41+
42+
Testsigma provides you with a valid mailbox on request, with which you can author any test case that requires a valid mailbox connected to an email id.
43+
44+
[[info | NOTE:]]
45+
| The 2FA testing (email and phone number) is offered as part of the enterprise plan. The feature is available for the below mentioned countries & supported for SMS OTP.<br>Australia, Canada, USA, Czech Republic, Denmark, Hungary, Indonesia, Mexico, Netherlands, Romania, Slovakia, Sweden, United Kingdom. For other regions, contact sales.
46+
47+
### **Step 3: Create a test case**
48+
49+
If you are not familiar on how to create a simple test case, refer to <a href="https://testsigma.com/docs/test-cases/manage/add-edit-delete/#creating-a-test-case">create a testcase</a>
50+
<br>
51+
52+
### **Step 4: Create a test steps to enter the email address where the OTP is to be sent**
53+
54+
We will enter the email address provided by Testsigma using the Mailbox test data type in the test step.
55+
<ol>
56+
<li>In your test case, add a test step to enter the email in the email field on your application page.</li>
57+
<li>Clear the <kbd>test data</kbd> placeholder and select the <kbd>&|Mailbox| </kbd> test data type from the suggestions list. An overlay showing the list of available Email addresses will open up.</li>
58+
<li>Next, use the NLP <em>Click on SendOTP</em>to generate the OTP.
59+
</li>
60+
</ol>
61+
<br>
62+
63+
### **Step 5: Create a test step to fetch the OTP from the mailbox**
64+
65+
We will use the test data generators available in Testsigma to fetch the OTP from the Mailbox selected in the previous step.
66+
<ol>
67+
<li>Add a test step to enter the OTP Code in the OTP Field. For this, select the NLP <em>Enter test data in the EmailOTP field</em></li>
68+
<li>Clear the <kbd>test data</kbd> placeholder and select the <kbd>!|Function|</kbd> test data type</li>
69+
<li>Search and select the Test Data generator function <kbd>!|MailboxFunctions - getOTP|</kbd></li>
70+
<li>Enter the below arguments for the function and create the test step.
71+
<ol>
72+
<li><strong>Regex</strong>: The Regex command specifies the format of the OTP i.e alphanumeric or pure number or pure alphabetical etc. For example: for an OTP which is a number with a length of 4 to 8, we can use the regular expression \d{4,8}.</li>
73+
<li><strong>Mailbox</strong>: The Mailbox is the pre-configured email ID to which the OTP is sent. In this case it is automation@testsigatech.com</li>
74+
<li><strong>Timeout</strong>: How long should be the wait time for the OTP to be generated</li>
75+
</ol></li>
76+
<li>Once these values are passed the MailBox reader will use the parameters to read the generated OTP.</li>
77+
</ol>
78+
The below GIF depicts the method to automate email based OTP verification in real time using a sample application:
79+
<img src="https://s3.amazonaws.com/static-docs.testsigma.com/new_images/advanced/sms-based-two-factor-authentication-2fa/2FA_automation.gif" alt="email 2fa automation">
80+
81+
82+
---
Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,92 @@
11
---
2-
title: "How to automate SMS based Two Factor Authentication(2FA)"
2+
title: "How to automate SMS based two factor authentication(2FA)"
33
metadesc: "Coming soon..."
44
noindex: true
55
order: 5.2
66
page_id: "How to automate SMS based Two Factor Authentication(2FA)"
77
search_keyword: "Web Application, Recorder, Testsigma Tutorials"
88
warning: false
9+
contextual_links:
10+
- type: section
11+
- name: "Contents"
12+
- type: link
13+
name: "Prerequisites"
14+
url: "#prerequisites"
15+
- type: link
16+
name: "Steps to automate SMS based OTP verification"
17+
url: "#steps-to-automate-sms-based-otp-verification"
18+
919
---
1020

1121
---
1222

13-
### Coming soon...
23+
## **Prerequisites**
24+
25+
<li>A Testsigma account. If you do not have one already, <a href="https://testsigma.com/signup">sign up for a free trial</a></li>
26+
<li>Understanding of creating and running test cases.</li>
27+
<li>Provisioned phone numbers.</li>
28+
<li>Familiarity with regular expressions. If not, refer to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions">Regex guide - MDN Docs.</a></li>
29+
<br>
30+
31+
32+
## **Steps to automate SMS based OTP verification**
33+
34+
35+
### **Step 1: Record elements**
36+
37+
<p>
38+
39+
Before moving on to the test case, you must capture elements on the login screen of your application. <em>For more information on how to record elements using Testsigma chrome recorder extension, refer to</em>
40+
<li><a href="https://testsigma.com/docs/elements/web-apps/record-multiple-elements/">Web application </a></li>
41+
<li><a href="https://testsigma.com/docs/elements/android-apps/record-multiple-elements/">Android</a> </li>
42+
<li><a href="">iOS</a></li>
43+
</p>
44+
45+
### **Step 2: Configuring your phone number**
46+
<p>
47+
Testsigma provides you with a valid mobile phone number on request, with which you can author any test case that requires a valid phone number.</p>
48+
49+
[[info | NOTE:]]
50+
| The 2FA testing (email and phone number) is offered as part of the enterprise plan. The feature is available for the below mentioned countries & supported for SMS OTP.<br>Australia, Canada, USA, Czech Republic, Denmark, Hungary, Indonesia, Mexico, Netherlands, Romania, Slovakia, Sweden, United Kingdom. For other regions, contact sales.
51+
52+
To view the phone numbers allocated to your account, navigate to **Settings> Phone numbers**.
53+
<br>
54+
55+
### **Step 3: Create a test case**
56+
57+
If you are not familiar on how to create a simple test case, refer to <a href="https://testsigma.com/docs/test-cases/manage/add-edit-delete/#creating-a-test-case">create a testcase</a>.
58+
<br>
59+
60+
### **Step 4: Create a test step to enter the phone number to which the OTP will be sent**
61+
62+
We will enter the phone number provided by Testsigma using the Phone Number test data type, using a test step.
63+
<ol>
64+
<li>In your test case, add a test step to enter the phone number in the phone number field on your application page.</li>
65+
<li>Clear the <kbd>< test data > </kbd> placeholder and select the <kbd>%|Phone Number| </kbd> test data type from the suggestions list. An overlay showing the list of available phone numbers (allocated to your account) would open up.</li>
66+
<li>Select one of the numbers from the list. This is the number where the OTP SMS will be sent.</li>
67+
<li>Next, use the NLP <em>Click on SendOTP</em></li>
68+
</ol><br>
69+
70+
71+
### **Step 5: Create a test step to fetch the OTP from the SMS received on the Phone number**
72+
73+
We will use the test data generators available in Testsigma to fetch the OTP from the phone number selected in the previous step.
74+
<ol>
75+
<li>Add a test step to enter the OTP code in the OTP Field</li>
76+
<li>Clear the <kbd>< test data > </kbd>placeholder and select the <kbd>!|Function|</kbd> test data type </li>
77+
<li>Search and select the test data generator function !|PhoneNumberFunctions - getOTP|</li>
78+
<li>Enter the following arguments for the function and create the test step.
79+
<ul>
80+
<li><strong>Regex</strong>: The Regex command specifies the format of the OTP i.e alphanumeric or pure number or pure alphabetical etc. For example: for an OTP which is a number with a length of 4 to 8, we can use the regular expression <kbd>\d{4,8}</kbd>.</li>
81+
<li><strong>Phone number</strong>: This field specifies one of the pre-configured phone numbers, in this case its +12082045810</li>
82+
<li><strong>Timeout</strong>: Duration of the wait time for the OTP to be generated</li>
83+
</ul>
84+
</li>
85+
Once these values are passed the PhoneNumberFuntion will use the parameters to read the generated OTP.
86+
The below GIF depicts the method to automate email based OTP verification in real time using a sample application:
87+
</ol>
88+
89+
90+
91+
<img src="https://s3.amazonaws.com/static-docs.testsigma.com/new_images/advanced/sms-based-two-factor-authentication-2fa/sms_automation.gif" alt="sms based 2fa automation">
92+
---

0 commit comments

Comments
 (0)