def testOTPReuse(self): """Verify that reusing an OTP yields no cookie.""" otp._ClearUserHistory() self._SendJSONRequest('test-user', 'test-password', otp.GetOTP('test-user'), 200, True) self.wait() self._SendJSONRequest('test-user', 'test-password', otp.GetOTP('test-user'), 200, False) self.wait()
def testHTTPAdminAuthenticate(self): """Authenticate test-user admin via HTTP with a form post.""" otp._ClearUserHistory() self._SendHTTPRequest('test-user', 'test-password', otp.GetOTP('test-user'), 302, True) self.wait() otp._ClearUserHistory() self._SendHTTPRequest('test-user', 'wrong-password', otp.GetOTP('test-user'), 200, False) self.wait()
def _GetAdminOpener(self): """Gets the admin opener. Returns the opener and api_host.""" otp._ClearUserHistory() api_host = 'www.goviewfinder.com:%d' % self.get_http_port() tmp_file = tempfile.NamedTemporaryFile(delete=False) opener = otp.GetAdminOpener(api_host, 'test-user', 'test-password', otp.GetOTP('test-user'), tmp_file.name) return api_host, opener
def testBadUser(self): """Verify bad user yields no cookie.""" otp._ClearUserHistory() self._SendJSONRequest('wrong-user', 'test-password', otp.GetOTP('test-user'), 200, False) self.wait()
def testJSONAdminAuthenticate(self): """Authenticate test-user admin via JSON.""" otp._ClearUserHistory() self._SendJSONRequest('test-user', 'test-password', otp.GetOTP('test-user'), 200, True) self.wait()