def testLoginLogout(self): """ Make sure login and logout functions set things up correctly """ db = FluidDB(TEST_INSTANCE) # start from a blank slate self.assertFalse('Authorization' in db.headers) # Login db.login(TEST_USER, TEST_PASSWORD) userpass = TEST_USER + ':' + TEST_PASSWORD auth = 'Basic ' + userpass.encode('base64').strip() self.assertEquals(db.headers['Authorization'], auth) # Logout db.logout() self.assertFalse('Authorization' in db.headers)
def testLoginLogoutOAuth2(self): """ Make sure login and logout functions set things up correctly when we use OAuth2. """ token = 'kajfjowijmssafuwoisflsjlfsoieuossfh' db = FluidDB(TEST_INSTANCE) # start from a blank slate self.assertFalse('Authorization' in db.headers) self.assertFalse('X-FluidDB-Access-Token' in db.headers) # Login db.login_oauth2(token) self.assertEquals(db.headers['Authorization'], 'oauth2') self.assertEquals(db.headers['X-FluidDB-Access-Token'], token) # Logout db.logout() self.assertFalse('Authorization' in db.headers) self.assertFalse('X-FluidDB-Access-Token' in db.headers)