コード例 #1
0
    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()
コード例 #2
0
 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)
コード例 #3
0
ファイル: cli.py プロジェクト: hpi-schul-cloud/url-crawler
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
コード例 #4
0
 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)
コード例 #5
0
 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()