def test_srp(self): for instance in srp_instances: if instance["Exception"]: continue server = TestServer() server.setup(instance["Username"], bytes.fromhex(instance["Modulus"]), base64.b64decode(instance["Verifier"])) server_challenge = server.get_challenge() usr = self.user(instance["Password"], bytes.fromhex(instance["Modulus"])) client_challenge = usr.get_challenge() client_proof = usr.process_challenge( base64.b64decode(instance["Salt"]), server_challenge, PM_VERSION) server_proof = server.process_challenge( client_challenge, client_proof) usr.verify_session(server_proof) self.assertIsNotNone( client_proof, "SRP exchange failed, " "client_proof is none for instance: {}...".format( str(instance)[:30])) self.assertEqual( server.get_session_key(), usr.get_session_key(), "Secrets do not match, instance: {}...".format( str(instance)[:30])) self.assertTrue( server.get_authenticated(), "Server is not correctly authenticated, " + "instance: {}...".format(str(instance)[:30])) self.assertTrue( usr.authenticated(), "User is not correctly authenticated, " + "instance: {}...".format(str(instance)[:30]))
class TestCountResults(TestTSVResults): PATH = "/testservice/countservice" FORMAT = "count" EXPECTED_RESULTS = ['25'] EXPECTED_COUNT = 25 def testCount(self): """Should be able to get count as an integer""" attempts = 0 def do_tests(error=None): if attempts < 5: try: self.assertEqual(self.query.count(), self.EXPECTED_COUNT) self.assertEqual(self.template.count(), self.EXPECTED_COUNT) except IOError, e: do_tests(e) else: raise RuntimeError("Error connecting to " + self.query.service.root, error) do_tests() if __name__ == '__main__': server = TestServer() server.start() time.sleep(0.1) # Avoid race conditions with the server unittest.main() server.shutdown()
# use your version of this file under the terms of the MPL, indicate your # decision by deleting the provisions above and replace them with the notice # and other provisions required by the GPL or the LGPL. If you do not delete # the provisions above, a recipient may use your version of this file under # the terms of any one of the MPL, the GPL or the LGPL. # # ***** END LICENSE BLOCK ***** import threading from testserver import TestServer from marionette import Marionette, HTMLElement if __name__ == '__main__': # start the test server server = TestServer(2626) thread = threading.Thread(target=server.run) thread.daemon = True thread.start() # run some trivial unit tests which just verify the protocol m = Marionette(host='localhost', port=2626) assert(m.status()['os']['arch'] == 'x86') assert(m.start_session()) assert(m.get_session_capabilities()['javascriptEnabled'] == True) assert(m.get_window() == server.TEST_CURRENT_WINDOW) assert(m.window == server.TEST_CURRENT_WINDOW) assert(m.get_windows() == server.TEST_WINDOW_LIST) assert(m.switch_to_window('window2')) assert(m.window == 'window2') assert(m.close_window('window2'))
# elements should be a list assert(isinstance(elements, list)) # elements should match the TEST_FIND_ELEMENTS list assert(map(lambda x: x.id, elements) == TestServer.TEST_FIND_ELEMENTS) # Each member of elements should be a WebElement that has the same # method, which should in turn return a list of WebElements when called. for element in elements: assert(isinstance(element, WebElement)) children = getattr(element, fn)('foo') assert(isinstance(children, list)) assert(map(lambda x: x.id, children) == TestServer.TEST_FIND_ELEMENTS) assert(len(filter(lambda x: not isinstance(x, WebElement), children)) == 0) if __name__ == '__main__': # start the test server on port 2626 server = TestServer(2626) thread = threading.Thread(target=server.run) thread.daemon = True thread.start() # Start the selenium proxy on port 4444, connecting to the test server # on port 2626. proxy = SeleniumProxy('127.0.0.1', proxy_port=4444) proxy_thread = threading.Thread(target=proxy.start) proxy_thread.daemon = True proxy_thread.start() # invoke selenium commands as tests driver = webdriver.Remote(command_executor='http://127.0.0.1:4444', desired_capabilities=webdriver.DesiredCapabilities.FIREFOX) assert(driver)
self.assertRaises(ModelError, lambda: departments[idx].company.foo) assertEqual(len(departments), 8) self.do_unpredictable_test(logic) class TestCountResults(TestTSVResults): # pragma: no cover PATH = "/testservice/countservice" FORMAT = "count" EXPECTED_RESULTS = ['25'] EXPECTED_COUNT = 25 def testCount(self): """Should be able to get count as an integer""" def logic(): self.assertEqual(self.query.count(), self.EXPECTED_COUNT) self.assertEqual(self.template.count(), self.EXPECTED_COUNT) self.do_unpredictable_test(logic) if __name__ == '__main__': # pragma: no cover server = TestServer() server.start() time.sleep(0.1) # Avoid race conditions with the server unittest.main() server.shutdown()
# elements should match the TEST_FIND_ELEMENTS list assert (map(lambda x: x.id, elements) == TestServer.TEST_FIND_ELEMENTS) # Each member of elements should be a WebElement that has the same # method, which should in turn return a list of WebElements when called. for element in elements: assert (isinstance(element, WebElement)) children = getattr(element, fn)('foo') assert (isinstance(children, list)) assert (map(lambda x: x.id, children) == TestServer.TEST_FIND_ELEMENTS) assert (len(filter(lambda x: not isinstance(x, WebElement), children)) == 0) if __name__ == '__main__': # start the test server on port 2626 server = TestServer(2626) thread = threading.Thread(target=server.run) thread.daemon = True thread.start() # Start the selenium proxy on port 4444, connecting to the test server # on port 2626. proxy = SeleniumProxy('127.0.0.1', 2626, proxy_port=4444) proxy_thread = threading.Thread(target=proxy.start) proxy_thread.daemon = True proxy_thread.start() # invoke selenium commands as tests driver = webdriver.Remote( command_executor='http://127.0.0.1:4444', desired_capabilities=webdriver.DesiredCapabilities.FIREFOX)