Пример #1
0
 def test_login(self):
     auth = Authentication()
     login_url = auth.login()
     print(login_url)
     match = re.search(
         r'https://slack\.com/oauth/authorize\?response_type=code&client_id=.*&state=.*',
         login_url).group()
     self.assertEqual(match, login_url)
 def test_authentication_change_password(self):
     auth = Authentication(FakePersist())
     auth.add_user('foobar', 'baz', 'student')
     auth.login('foobar', 'baz')
     self.assertDictEqual(auth.change_password('foobar', 'qux'), {})
 def test_authentication_login_unknown_user_fail(self):
     auth = Authentication(FakePersist())
     self.assertDictEqual(auth.login('foobar', 'baz'), {
         'success': False,
         'message': 'User does not exist.'
     })
 def test_authentication_login_wrong_password_fail(self):
     auth = Authentication(FakePersist())
     auth.add_user('wobble', 'spam', 'student')
     self.assertDictEqual(auth.login('wobble', 'wrong_password'), {})
 def test_authentication_login(self):
     auth = Authentication(FakePersist())
     auth.add_user('foobar', 'baz', 'professor')
     self.assertDictEqual(auth.login('foobar', 'baz'), {})
Пример #6
0
def main():
    rb = xlrd.open_workbook(r'C:\....\Modem_Master_List_Ver_13-NKV03.xls')
    rs = rb.sheet_by_index(0)
    wb = copy(rb)
    ws = wb.get_sheet(0)

    for row in range(161, rs.nrows):
        phoneNumber = ""
        esnEid = ""
        valueList = ""
        mitigated = rs.cell_value(row, 34).strip()

        if mitigated == "Yes - IMB" or mitigated == "Yes-FIELD":

            url = rs.cell_value(row, 28).strip()
            print url
            password = rs.cell_value(row, 35).strip()

            if not password == "" and not url == "":
                try:

                    browser = webdriver.Ie(
                        r"C:\....\IEDriverServer_Win32_2.39.0\IEDriverServer.exe"
                    )

                    auth = Authentication(url.strip(), password.strip())
                    auth.login(browser)
                    stspg = StatusPage()
                    stspg.status_Locater_action(browser)
                    phoneNumber = stspg.home_Locater_action(browser)
                    esnEid = stspg.wan_Locater_action(browser)
                    valueList = stspg.about_Locater_action(browser)
                    ws.write(row, 13, phoneNumber)
                    ws.write(row, 17, esnEid)
                    ws.write(row, 20, valueList[0])
                    ws.write(row, 33, valueList[1])

                except:
                    pass
                finally:
                    browser.close()

            else:
                print "Password/url fields are empty " + url

        if mitigated == "No":
            url = rs.cell_value(row, 28).strip()
            print url
            password = str(rs.cell_value(row, 31))
            '''
			Some of the passwords are in number format and excel convert numbers into float format at backend.
			'''

            if password == "****.0":
                password = password.strip('.0')
            elif password == "*****.0":
                password = password.strip('.0')
            else:
                password = password.strip()

            if not password == "" and not url == "":

                try:
                    browser = webdriver.Ie(
                        r"C:\...\IEDriverServer_Win32_2.39.0\IEDriverServer.exe"
                    )

                    auth = Authentication(url.strip(), password.strip())
                    auth.login(browser)
                    #if status:
                    stspg = StatusPage()
                    stspg.status_Locater_action(browser)
                    phoneNumber = stspg.home_Locater_action(browser)
                    esnEid = stspg.wan_Locater_action(browser)
                    valueList = stspg.about_Locater_action(browser)
                    ws.write(row, 13, phoneNumber)
                    ws.write(row, 17, esnEid)
                    ws.write(row, 20, valueList[0])
                    ws.write(row, 33, valueList[1])

                except:
                    pass
                finally:
                    browser.close()
            else:
                print "Password/url fields are empty " + url

        wb.save(r'C:\....\Modem_Master_List_Ver_13-NKV03.xls')
Пример #7
0
 def test_login(self):
     auth = Authentication()
     login_url = auth.login()
     print(login_url)
     match = re.search(r'https://slack\.com/oauth/authorize\?response_type=code&client_id=.*&state=.*', login_url).group()
     self.assertEqual(match, login_url)
Пример #8
0
class Menu:
    """
    
    """
    def __init__(self):
        self.authentication = Authentication()
        self.menu = ConsoleMenu("Library Management System", "Reception")
        self.user = None
        self.faceid = FaceID()
        function_item_login = FunctionItem("Login", self.login)
        function_item_faceid = FunctionItem("Face-ID Login", self.login_faceid)
        function_item_register = FunctionItem("Register", self.register)
        self.menu.append_item(function_item_login)
        self.menu.append_item(function_item_faceid)
        self.menu.append_item(function_item_register)

        self.menu.show()

    def register(self):
        while True:
            username = input("Username (or q! to quit): ")

            if username == 'q!':
                return

            if not self.authentication.search_user(username):
                break
            else:
                print("** Username already in use, please try again **")

        firstname = input("First name: ")
        lastname = input("Last name: ")
        email = input("Email Address: ")
        password = input("Password: "******"You have successfully registered")

        self.authentication.create_user(username, firstname, lastname, email,
                                        password)

    def login(self):
        attempts = 0
        while True:
            if attempts == 3:
                print("Too many failed attempts.")
                break
            username = input("Username: "******"Password: "******"Welcome " + self.user.getFirstname())
                    conn = ClientConnection(('127.0.0.1', 64010))
                    with conn as s:
                        #conn.__enter__() executes: connection open
                        s.send(username)

                    break
                else:
                    attempts += 1
                    print("Login Invalid!")
            else:
                print("Login Invalid!")

    def login_faceid(self):
        username = self.faceid.recognize_user()

        if username == "Unknown":
            print("Login Failed")
            return
        else:
            self.user = self.authentication.get_user(username)
            print(self.user.getFirstname())
Пример #9
0
 def test_authentication_login_unknown_user_fail(self):
     auth = Authentication(FakePersist())
     self.assertDictEqual(auth.login('foobar', 'baz'), {
         "success": False,
         "message": "User doesn't exist."
     })