def test_req_access(self): (access_token, refresh_token) = utils.f5_login(self.bigiq_addr, self.username, self.password) auth = XF5Auth(access_token=access_token) r = requests.get(self.url, auth=auth, verify=False) self.assertEquals(r.status_code, 200)
def test_session_refresh(self): (access_token, refresh_token) = utils.f5_login(self.bigiq_addr, self.username, self.password) s = requests.Session() s.auth = XF5Auth(refresh_token=refresh_token) s.verify = False r = s.get(self.url) self.assertEquals(r.status_code, 200) self._verify_session(s)
def test_access_token(self): (access_token, refresh_token) = utils.f5_login(self.bigiq_addr, self.username, self.password) auth = XF5Auth(access_token=access_token) r = Request('GET', self.url, auth=auth).prepare() # ensure url didn't get messed up self.assertEqual(r.url, self.url) self.assertTrue(r.headers.get('X-F5-Auth-Token', '')) s = Session() resp = s.send(r, verify=False) self.assertEquals(resp.status_code, 200)
def test_session_access(self): (access_token, refresh_token) = utils.f5_login(self.bigiq_addr, self.username, self.password) s = requests.Session() s.auth = XF5Auth(access_token=access_token) s.verify = False r = s.get(self.url) self.assertEquals(r.status_code, 200) if self.is_long_test_allowed: with self.assertRaises(F5AuthenticationError) as cm: try: self._verify_session(s) except F5AuthenticationError as e: self.assertIn("username", e.args[0]) self.assertIn("password", e.args[0]) raise