def testValidLoginAndPermanentSession(self): self.setupUserAccounts() data = self.device_info rv = self.testclient.post('/auth/login', base_url=self.base_url, content_type='application/json', data=json.dumps(data), headers=[basic_auth_header("*****@*****.**", "never")]) assert 'token' in rv.data assert '201' in rv.data assert 'set-cookie' in rv.headers match = re.search(r'\bexpires=([^;]+)', rv.headers['set-cookie']) assert match is not None rv = self.testclient.get('/auth/supersecret', base_url=self.base_url) self.assertIn('secret', rv.data)
def testValidLoginWithoutDeviceInfo(self): self.setupUserAccounts() data = None rv = self.testclient.post('/auth/login', base_url=self.base_url, content_type='application/json', data=json.dumps(data), headers=[basic_auth_header("*****@*****.**", "never")]) assert '400' in rv.data
def testInvalidLoginWithInvalidUsername(self): self.setupUserAccounts() rv = self.testclient.post('/auth/login', base_url=self.base_url, data=dict(device_info="flask.test_client"), headers=[json_content_header, basic_auth_header("*****@*****.**", "done")]) assert '401' in rv.data