class TestLogin(unittest.TestCase):

    def setUp(self):
        self.driver = Service.get_driver('../config/base.conf')
        Service.open_page(self.driver, '../config/base.conf')
        self.login = Login(self.driver)

    def tearDown(self):
        time.sleep(2)
        self.driver.quit()


    # 测试登录功能
    @parameterized.expand(login_data)

    def test_login(self, login_userName, login_userPASS, login_checkcode, login_expect):
        contents = {'username': login_userName, 'password': login_userPASS, 'checkcode': login_checkcode}
        self.login.excute_login(contents)
        # 断言
        if Service.is_element_present(self.driver, By.LINK_TEXT, '注销'):
            actual = 'success'
        elif self.driver.find_element_by_id('pwMsg').text == '用户名或密码错误':
            actual = 'error'
        elif self.driver.find_element_by_id('checkcodeMsg').text == '用户名或密码错误':
            actual = 'error'
        else:
            actual = 'error'
        self.assertEqual(actual, login_expect)
Пример #2
0
def login(req):
    referer = req.args.getfirst("referer", "", str)

    data = Object(referer=referer, email="")

    if req.method == "POST":
        login = Login()
        login.bind(req.form, req.cfg.login_rounds)

        ip = "ip" in req.form
        if login.find(req):
            do_login(req, login.simple(), ip)
            if referer:
                redirect(req, referer)
            if "admin" in login.rights or "super" in login.rights:
                redirect(req, "/admin")
            redirect(req, "/")

        data.ip = ip
        data.email = login.email
        data.error = BAD_LOGIN

    return generate_page(
        req, "login.html", data=data, sign_up=req.cfg.login_sign_up, password_link=req.cfg.login_forget_password_link
    )
Пример #3
0
def login_user():
    login = Login(BASE_DIR)
    found = Login.login(login)
    if not found:
        flash('Incorrect Details')
        return redirect(url_for('index'))
    else:
        return redirect(url_for('admin'))
Пример #4
0
def verify(req, servis_hash):
    login = Login()
    status = login.verify(req, servis_hash)
    if status is True:
        do_login(req, login.simple())
        redirect(req, "/")
    elif status == OK:
        return generate_page(req, "/login/email_verificated.html")
    else:
        return generate_page(req, "/login/email_verificated.html", error=status, item=login)
Пример #5
0
def admin_logins_enable(req, id):
    check_login(req, "/log_in?referer=/admin/logins")
    check_right(req, R_ADMIN)
    check_token(req, req.form.get("token"))

    login = Login(id)
    if req.login.id == login.id:  # not good idea to
        raise SERVER_RETURN(state.HTTP_FORBIDDEN)  # disable himself

    login.enabled = int(req.uri.endswith("/enable"))
    login.enable(req)
    redirect(req, "/admin/logins")
Пример #6
0
def login_step1():
    if(request.method=="POST"):
        email=""
        password=""
        try:
            email+=request.form["email"]
            password+=request.form["password"]
        except Exception as error:
            return {"erroText":error,"errorCode":"5003"}
        obj=Validation()
        if(obj.required(email)==False or obj.required(password)==False):
            return {"errorText":"All filed should be filled","errorCode":"5000"}

        if (obj.emailValidate(email) == False):
            print("email is",email)
            return {"errorText": "Email should be validated", "errorCode": "5001"}

        if(obj.passwordValidate(password)==False):
            return {"errorText": "Password should be validated", "errorCode": "5002"}

        obj = Login()
        obj.email = email
        obj.password = password
        otp_code=obj.step_one()
        msg = Message('Identify Verification', sender=json_data["mail-user"], recipients=[email])
        msg.body = "Your OTP code is here , enter it and login . OTP Code is {0}".format(otp_code["data"]["otp-code"])
        mail.send(msg)
        del otp_code["data"]
        return otp_code

    else:
        return {"errorText":"method is not post","errorCode":"5008"},
    def setUp(self):
        driver=Service.get_driver('..\\conf\\base.conf')
        login_info = {'userName': '******', 'userPass': '******', 'checkcode':'0000'}
        Login().do_login('..\\conf\\base.conf', driver, login_info)

        time.sleep(3)

        driver.find_element_by_css_selector('div.panel:nth-child(12) > div:nth-child(1) > a:nth-child(1)').click()

        time.sleep(3)
        driver.find_element_by_css_selector(
            '#list-8 > div:nth-child(1) > ul:nth-child(1) > li:nth-child(1) > a:nth-child(1)').click()
        time.sleep(3)

        number = driver.find_element_by_xpath('/html/body/div[9]/div[2]/div[2]/div[2]/div[4]/div[1]/span[1]')

        print(number.text)
        eles = driver.find_elements_by_class_name('page-number')
        print(eles)
        num = 0
        totalcount = len(eles)
        print(totalcount + 1)
        for i in range(0, totalcount + 1):
            # eles[i].find_elements_by_tag_name('a').click()
            # print(eles[i])
            driver.find_element_by_xpath("//ul[@class='pagination']/li[%d+2]/a[contains(@href,'#')]" % i).click()
            time.sleep(5)
            newnum = len(driver.find_elements_by_xpath('//*[@id="employee-table"]/tbody/tr'))
            num = num + newnum
        print(num)
        driver.quit()
def login():
    """
	session values : dbid,username,status
	"""
    code = ""
    if request.method == "POST":
        email = request.form["email"]
        password = request.form["password"]

        if (validated.checkValue(None, email, password)
                or validated.checkValue("", email, password)):
            return redirect("/")

        obj = Login(email, password)
        value = obj.check
        if (value[0] == True):
            session.permanent = True
            session["status"] = "logged"
            session["username"] = value[1]
            session["dbid"] = value[2]
            return redirect("/home/")
        else:
            code = """
<div class="alert alert-danger alert-dismissible fade show" role="alert">
  <strong>Authentication</strong> Email or password is incorrect , Try again.
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>  
			"""
            return render_template("login.html", code=code)

    return render_template("login.html", code=code)
Пример #9
0
def login_step2():
    if(request.method=="POST"):
        email=""
        password=""
        otp_code=""
        try:
            email+=request.form["email"]
            password+=request.form["password"]
            otp_code+=request.form["otp_code"]
        except Exception as error:
            return {"erroText":error,"errorCode":"5003"}
        obj=Validation()
        if(obj.required(email)==False or obj.required(password)==False or obj.required(otp_code)==False):
            return {"errorText":"All filed should be filled","errorCode":"5000"}

        if (obj.emailValidate(email) == False):
            print("email is",email)
            return {"errorText": "Email should be validated", "errorCode": "5001"}

        if(obj.passwordValidate(password)==False):
            return {"errorText": "Password should be validated", "errorCode": "5002"}

        obj = Login()
        obj.email = email
        obj.password = password
        obj.otp_code=otp_code
        return obj.step_two()

    else:
        return {"errorText":"method is not post","errorCode":"5008"},
Пример #10
0
def sign_up(req):
    if req.method == "POST":
        robot = True if req.form.getfirst("robot", "", str) else False
        qid = int(req.form.getfirst("qid", "0", str), 16)
        question, answer = robot_questions[qid]
        check = req.form.getfirst("answer", "", str) == answer

        login = Login()
        login.bind(req.form, req.cfg.login_rounds)

        if robot or not check:
            return generate_page(
                req,
                "/login/login_mod.html",
                item=login,
                question=question,
                answer=answer,
                check=check,
                qid=hex(qid),
                form=req.form,
            )

        error = login.add(req, True)
        if error:
            return generate_page(
                req,
                "/login/login_mod.html",
                item=login,
                error=error,
                question=question,
                answer=answer,
                check=check,
                qid=hex(qid),
                form=req.form,
                password_link=req.cfg.login_forget_password_link,
            )

        send_login_created(req, login)
        return generate_page(req, "/login/waiting_for_verification.html", item=login)
    # endif

    qid = randint(0, len(robot_questions) - 1)
    question, answer = robot_questions[qid]
    return generate_page(
        req, "/login/login_mod.html", item=Object(), question=question, answer=answer, qid=hex(qid), form=Object()
    )
Пример #11
0
 def setUp(self):
     self.driver = Service.get_driver('..\\conf\\base.conf')
     login_info = {
         'userName': '******',
         'userPass': '******',
         'checkcode': '0000'
     }
     Login().do_login('..\\conf\\base.conf', self.driver, login_info)
Пример #12
0
 def test_login(self,userName,userPass,checkcode,expect):
     login_info ={'userName':userName,'userPass':userPass,'checkcode':checkcode}
     Login().do_login('..\\conf\\base.conf',self.driver,login_info)
     from selenium.webdriver.common.by import By
     flag= Service.is_element_present(self.driver,By.LINK_TEXT,'[注销]')
     if flag:
         actual= 'login_pass'
     else:
         actual = 'login_fail'
     self.assertEqual(actual,expect)
Пример #13
0
class LoginTest(unittest.TestCase):
    content = Utility.get_json('../conf/yang/testinfo.conf')
    login_info = Utility.tran_tuple(content[0])

    @classmethod
    def setUpClass(cls):
        warnings.simplefilter('ignore', ResourceWarning)

    def setUp(self):
        self.driver = Service.get_driver('../conf/yang/base.conf')
        self.driver.implicitly_wait(15)
        self.driver.maximize_window()
        from lib.login import Login
        self.login = Login(self.driver)

    def tearDown(self):
        self.driver.close()

    @classmethod
    def tearDownClass(cls):
        pass

    #测试登录
    @parameterized.expand(login_info)
    def test_login(self, uname, psword, code, expect):

        self.login.do_login(uname, psword, code, '../conf/yang/base.conf')
        # time.sleep(25)
        from selenium.webdriver.common.by import By
        #如果存在注销链接
        time.sleep(3)
        if Service.is_element_present(self.driver, By.PARTIAL_LINK_TEXT,
                                      "修改密码"):
            actual = "login-success"
            #退出系统
            self.login.click_logout()
        else:
            actual = "login-fail"
            time.sleep(1)
            # Utility.get_error_png(self.driver)

        self.assertEqual(actual, expect)
Пример #14
0
def login(lang, username, password, debug=False):
    """
    Helper function that logs you in to ul server

    :param lang:
    :param username:
    :param password:
    :param debug:
    :return:
    """
    return Login.inst(lang).login(username, password, debug)
Пример #15
0
def login_mod(req):
    check_login(req)

    login = Login(req.login.id)
    token = do_create_token(req, "/login")

    state = None
    if req.method == "POST":
        check_token(req, req.form.get("token"))
        login.bind(req.form, req.cfg.login_rounds)
        email = login.email if login.email != req.login.email else None
        state = login.pref(req, email=email)

        if 0 < state < 64:
            return generate_page(req, "login/login_mod.html", token=token, item=login, error=state)

        state = 0 if state is None else state
        if email:
            host = "%s (%s)" % (req.remote_host, req.remote_addr)
            send_verify_email(req, login, req.login.email, host=host, browser=req.user_agent)
            state |= REQUEST_FOR_EMAIL
    else:
        email = None
    # endif

    login.get(req)
    req.login = login
    return generate_page(req, "login/login_mod.html", token=token, item=login, state=state, email=email)
Пример #16
0
def admin_logins(req):
    check_login(req)
    check_right(req, R_ADMIN)

    error = req.args.getfirst("error", 0, int)

    pager = Pager(sort="asc", order="email")
    pager.bind(req.args)

    rows = Login.list(req, pager)
    return generate_page(
        req, "admin/logins.html", token=do_create_token(req, "/admin/logins"), pager=pager, rows=rows, error=error
    )
Пример #17
0
def forgotten_password(req):
    if req.method == "POST":
        robot = True if req.form.getfirst("robot", "", str) else False
        qid = int(req.form.getfirst("qid", "0", str), 16)
        question, answer = robot_questions[qid]
        check = req.form.getfirst("answer", "", str) == answer

        login = Login()
        login.email = req.form.getfirst("email", "", str).strip()

        if robot or not check or not login.check_email():
            return generate_page(
                req,
                "/login/forgotten_password.html",
                ttl=req.cfg.login_ttl_of_password_link,
                form=req.form,
                question=question,
                answer=answer,
                check=check,
                qid=hex(qid),
            )

        login.log_in_link(req)
        host = "%s (%s)" % (req.remote_host, req.remote_addr)
        send_log_in_link(req, login, host=host, browser=req.user_agent)
        return generate_page(req, "/login/verify_link_send.html", item=login)

    qid = randint(0, len(robot_questions) - 1)
    question, answer = robot_questions[qid]
    return generate_page(
        req,
        "/login/forgotten_password.html",
        ttl=req.cfg.login_ttl_of_password_link,
        form=Object(),
        question=question,
        answer=answer,
        qid=hex(qid),
    )
Пример #18
0
def admin_login_addresses(req, id):
    check_login(req)
    check_right(req, module_right)

    login = Login(id)

    if req.method == 'GET':
        if not login.get(req):
            raise SERVER_RETURN(state.HTTP_NOT_FOUND)

        return generate_page(req, "admin/logins_addresses.html",
                             item=login,
                             cfg_region=req.cfg.addresses_region,
                             cfg_country=req.cfg.addresses_country)

    # req.method == 'PUT'       # ajax put
    addresses = Addresses.bind(req.json)
    if not addresses.mod(req, id) is None:
        raise SERVER_RETURN(state.HTTP_NOT_FOUND)

    login.get(req)
    req.content_type = 'application/json'
    return json.dumps(login.data.get('addresses', {}))
Пример #19
0
def admin_logins_mod(req, id):
    check_login(req)
    check_right(req, R_ADMIN)
    token = do_create_token(req, "/admin/logins/%d" % id)

    login = Login(id)
    if req.login.id == login.id:  # not good idea to remove
        raise SERVER_RETURN(state.HTTP_FORBIDDEN)  # rights himself

    done = None
    if req.method == "POST":
        check_token(req, req.form.get("token"))
        login.bind(req.form, req.cfg.login_rounds)
        done = login.mod(req)

        if 0 < done < 64:
            return generate_page(req, "admin/logins_mod.html", token=token, rights=rights, item=login, error=done)
        # endif
    # endif

    if not login.get(req):
        raise SERVER_RETURN(state.HTTP_NOT_FOUND)
    return generate_page(req, "admin/logins_mod.html", token=token, rights=rights, item=login, state=done)
Пример #20
0
 def test_login(self, URL, METHOD, DATA, CODE, CONTENT, expect):
     login_info = {
         'userName': DATA['userName'],
         'userPass': DATA['userPass'],
         'checkcode': DATA['checkcode']
     }
     resp = Login('..\\conf\\base.conf').do_login(URL, login_info)
     flag = uiti.assert_equal(str(resp.text), CONTENT)
     if flag:
         if str(resp.text) == 'success':
             actual = 'login_pass'
         else:
             actual = 'login_fail'
     else:
         print('响应正文不正确')
     self.assertEqual(expect, actual)
Пример #21
0
class LoginTest(unittest.TestCase):
    login_conf = Utility.get_json('..\\conf\\testinfo.conf')[0]
    login_info = Utility.trans_tuple(login_conf)

    @classmethod
    def setUpClass(cls):
        pass

    @classmethod
    def tearDownClass(cls):
        pass

    def setUp(self):
        from lib.login import Login
        from tools.service import Service
        self.login = Login(Service.get_session())

    def tearDown(self):
        pass

    @parameterized.expand(login_info)
    def test_login(self, url, method, uname, upass, vcode, expect):
        warnings.simplefilter('ignore', ResourceWarning)
        login_test_info = {
            'URL': url,
            'METHOD': method,
            'LOGINDATA': {
                'username': uname,
                'password': upass,
                'verifycode': vcode
            },
            'EXPECT': expect
        }
        login_resp = self.login.do_login(login_test_info['URL'],
                                         login_test_info['METHOD'],
                                         login_test_info['LOGINDATA'])
        result = login_resp.text
        if result == 'login-pass':
            actual = 'login-pass'
        elif result == 'login-fail':
            actual = 'login-fail'
        else:
            actual = 'vcode-error'
        self.assertEqual(actual, login_test_info['EXPECT'])
Пример #22
0
    def teststeps(self):
        STEP(1, '获取当前审批节点')
        testId = 'API-3204-01'
        response = apiCommon().check_success(testId=testId, headers=headers)
        nodeNo = response.get('data').get('nodeNo')

        STEP(2, '更新审核通过用例的审批节点')
        #获取审核通过用例的请求参数
        testId = 'API-3206-01'
        ret = mysql().getOrderUpdatedAt(testId)
        testParams = json.loads(ret[0].get('testParams'))
        testParams['nodeNo'] = nodeNo
        testParams = json.dumps(testParams)
        ret = mysql().updateSQL_interface(testId=testId, testParams=testParams)
        INFO(ret)

        STEP(3, '执行审核通过')
        apiCommon().check_data(testId=testId, headers=headers)

        STEP(4, '再次获取当前审批节点')
        testId = 'API-3204-01'
        response = apiCommon().check_success(testId=testId, headers=headers)
        nodeNo = response.get('data').get('nodeNo')

        STEP(5, '更新审核驳回用例的审批节点')
        # 获取审核通过用例的请求参数
        testId = 'API-3206-02'
        ret = mysql().getOrderUpdatedAt(testId)
        testParams = json.loads(ret[0].get('testParams'))
        testParams['nodeNo'] = nodeNo
        testParams = json.dumps(testParams)
        ret = mysql().updateSQL_interface(testId=testId, testParams=testParams)
        INFO(ret)

        STEP(6, '执行审核驳回')
        # 用于审核驳回
        headers_nixing = {
            "x-token":
            Login().login_yun(userPhone='13732237699',
                              userPasswd='123456',
                              url=Global.login_yun_url)
        }
        apiCommon().check_data(testId=testId, headers=headers_nixing)
Пример #23
0
def admin_logins_add(req):
    check_login(req)
    check_right(req, R_ADMIN)
    token = do_create_token(req, "/admin/logins/add")

    if req.method == "POST":
        check_token(req, req.form.get("token"))
        login = Login()
        login.bind(req.form, req.cfg.login_rounds)
        if not req.cfg.login_created_verify_link:
            login.enabled = 1
        login.rights = ["user"]
        error = login.add(req)

        if error:
            return generate_page(req, "admin/logins_mod.html", token=token, rights=rights, item=login, error=error)

        if req.cfg.login_created_verify_link:
            send_login_created(req, login)
        redirect(req, "/admin/logins/%d" % login.id)
    # endif

    return generate_page(req, "admin/logins_mod.html", token=token, rights=rights)
Пример #24
0
 def setUp(self):
     self.driver = Service.get_driver('../conf/yang/base.conf')
     self.driver.implicitly_wait(15)
     self.driver.maximize_window()
     from lib.login import Login
     self.login = Login(self.driver)
 def setUp(self):
     self.driver = Service.get_driver('../config/base.conf')
     Service.open_page(self.driver, '../config/base.conf')
     self.login = Login(self.driver)
Пример #26
0
 def setUp(self):
     from lib.login import Login
     from tools.service import Service
     self.login = Login(Service.get_session())
Пример #27
0
from ywyrobot.common import *
from tools.apiCommon import apiCommon
from tools.mysql import mysql
from tools.HttpUtil import HttpUtil
import json
from lib.goodsCommon import goodsCommon
from lib.login import Login
from cfg import Global

force_tags = ['供应商内部端', '合同列表']

#用于合同模块
headers = {
    "x-token":
    Login().login_yun(userPhone='18316321174',
                      userPasswd='123456',
                      url=Global.login_yun_url)
}


class a3101:
    # 测试用例名字
    name = '查询乙方公司列表 - API-3101'

    # 测试用例步骤
    def teststeps(self):
        STEP(1, '查询乙方公司列表')
        testId = 'API-3101-01'
        apiCommon().check_data(testId=testId, headers=headers)

Пример #28
0
if evn == 'TEST':
    host_supplier = "http://test-api-srm-supplier.ywwl.com"
    login_yun_url = 'http://test-api-auth.ywwl.com/user/login'
    login_yun_account = '18316321174'
    login_yun_password = '******'
    force_tags = ['供应商接口用例总数(TEST)']
else:
    host_supplier = "https://api-srm-supplier.ywwl.com"
    login_yun_url = 'https://api-auth.ywwl.com/user/login'
    login_yun_account = '18800000000'
    login_yun_password = '******'
    force_tags = ['供应商接口用例总数(PRD)']

tonken_yun = Login().login_yun(userPhone=login_yun_account,
                               userPasswd=login_yun_password,
                               url=login_yun_url)
print(tonken_yun)

#线上域名
# baseUrl = "https://api-srm-supplier.ywwl.com"

#获取tonken
# tonken_yun = Login().login_yun()

Headers_yun = {"x-token": tonken_yun}

# 获取当前时间
locatime = time.strftime("%Y-%m-%d", time.localtime())

Headers_yun_all = {
Пример #29
0
 def init_session(self):
     login = Login(self.driver)
     url_profile = login.login_user()
     return url_profile
Пример #30
0
#!/usr/bin/env python3
import os

from aws_cdk import core

from lib.login import Login

app = core.App()

env = {"region": "eu-west-1"}

cert_arn = os.getenv("CERT_ARN")
if cert_arn is None:
    raise RuntimeError("Please set the CERT_ARN environment variable")

domain_name = "auth.moshan.tv"

Login(app, "login", domain_name, cert_arn, env=env)

app.synth()
Пример #31
0
def jira_upload(username, ticket, file):

    jira = Login(username.rstrip("mfa"), "", "").jira_login()
    print(f"Uploading {file} to {ticket}")
    jira.add_attachment(ticket, file)