"Fossies" - the Fresh Open Source Software Archive

Member "LinOTP-release-2.11/linotpd/src/linotp/tests/integration/linotp_selenium_helper/email_token.py" (12 Nov 2019, 2691 Bytes) of package /linux/misc/LinOTP-release-2.11.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # -*- coding: utf-8 -*-
    2 #
    3 #    LinOTP - the open source solution for two factor authentication
    4 #    Copyright (C) 2010 - 2019 KeyIdentity GmbH
    5 #
    6 #    This file is part of LinOTP server.
    7 #
    8 #    This program is free software: you can redistribute it and/or
    9 #    modify it under the terms of the GNU Affero General Public
   10 #    License, version 3, as published by the Free Software Foundation.
   11 #
   12 #    This program is distributed in the hope that it will be useful,
   13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
   14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15 #    GNU Affero General Public License for more details.
   16 #
   17 #    You should have received a copy of the
   18 #               GNU Affero General Public License
   19 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
   20 #
   21 #
   22 #    E-mail: linotp@keyidentity.com
   23 #    Contact: www.linotp.org
   24 #    Support: www.keyidentity.com
   25 #
   26 """Contains EmailToken class"""
   27 
   28 from token import Token
   29 from helper import select
   30 
   31 from selenium.webdriver.support.ui import WebDriverWait
   32 from selenium.webdriver.common.by import By
   33 from selenium.webdriver.support import expected_conditions as EC
   34 
   35 class EmailToken(Token):
   36     """Creates a e-mail token in the LinOTP WebUI"""
   37 
   38     def __init__(self, driver, base_url, pin, email="", description=""):
   39         Token.__init__(self, driver=driver, base_url=base_url)
   40         select_tag = driver.find_element_by_id("tokentype")
   41         select(driver, select_element=select_tag, option_text="E-mail token")
   42         driver.find_element_by_id("enroll_email_desc").clear()
   43         driver.find_element_by_id("enroll_email_desc").send_keys(description)
   44         driver.find_element_by_id("email_pin1").clear()
   45         driver.find_element_by_id("email_pin1").send_keys(pin)
   46         driver.find_element_by_id("email_pin2").clear()
   47         driver.find_element_by_id("email_pin2").send_keys(pin)
   48         if email:
   49             driver.find_element_by_id("email_address").clear()
   50             driver.find_element_by_id("email_address").send_keys(email)
   51         driver.find_element_by_id("button_enroll_enroll").click()
   52 
   53         # Wait for API call to complete
   54         WebDriverWait(self.driver, 10).until_not(
   55                 EC.visibility_of_element_located((By.ID, "do_waiting")))
   56 
   57         info_boxes = driver.find_elements_by_css_selector("#info_box > .info_box > span")
   58         for box in info_boxes:
   59             if box.text.startswith("created token with serial"):
   60                 self.serial = box.find_element_by_tag_name("span").text
   61         if not self.serial or not self.serial.startswith("LSEM"):
   62             raise Exception("E-mail token was not enrolled correctly.")