def test_api_key_removes_basic(self): """The api key auth replaces the basic auth. Else, we might run into troubles with what is used last. """ auth.basic("user", "pass") auth.api_key("key") self.test_no_authentication_has_no_user_name_and_password()
def authenticate(self): """Authenticate the user.""" if self._auth_type == "noauth": auth.none() elif self._auth_type == "basic": auth.basic(self._name, self._secret) elif self._auth_type == "apikey": auth.api_key(self._secret) else: raise ValueError(self._auth_type)
def authenticate(basic, apikey): """Authenticate with the parameters. Return the return code in case auf authentication failure. """ if basic is not None and apikey is not None: error(7) if basic is not None: username_and_password = basic.split(":", 1) if len(username_and_password) == 1: error(8) username, password = username_and_password auth.basic(username, password) return 3 elif apikey is not None: auth.api_key(apikey) return 4 auth.none() return 5
def test_basic_authentication_provides_username_and_password(self): for username, password in [("a", "p"), ("1", "2")]: auth.basic(username, password) self.assertIsBasic(username, password)
def test_none_deletes_user_name_and_password(self): """After having used basic authentication, credentials can be deleted.""" auth.basic("username", "password") auth.none() self.test_no_authentication_has_no_user_name_and_password()