def setUp(self): """Create the default state. We have global state so we want to remove the side effects. """ auth.none() self.config = Configuration()
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_none_deletes_api_key(self): """Test deletion of api key.""" auth.api_key("key") auth.none() self.test_no_authentication_has_no_api_key()
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()
def api(self): """An resources api client connected to the server.""" auth.none() client = ApiClient(self.url) return ResourceApi(client)