Beispiel #1
0
    def test_logout_not_logged_in(self, request):
        """Test exc thrown when logout() but login() not called."""
        http = Http(url=get_url(request), certwarn=False)

        auth = ApiKey(http=http, **get_key_creds(request))

        with pytest.raises(NotLoggedIn):
            auth.logout()
    def test_old_version(self, request, monkeypatch):
        """Test exc thrown when login() and login() already called."""
        monkeypatch.setattr(ApiKey, "_validate_path", "api/badwolf")

        http = Http(url=get_url(request), certwarn=False)
        auth = ApiKey(http=http, **get_key_creds(request))
        with pytest.raises(AuthError):
            auth.login()
Beispiel #3
0
    def test_http_lock_fail(self, request):
        """Test using an http client from another authmethod throws exc."""
        http = Http(url=get_url(request), certwarn=False)

        auth = ApiKey(http=http, **get_key_creds(request))

        assert auth.http._auth_lock

        with pytest.raises(AuthError):
            auth = ApiKey(http=http, **get_key_creds(request))
Beispiel #4
0
    def test_invalid_creds(self, request):
        """Test str/repr has URL."""
        http = Http(url=get_url(request), certwarn=False)

        bad = "badwolf"

        auth = ApiKey(http=http, key=bad, secret=bad)

        with pytest.raises(InvalidCredentials):
            auth.login()
Beispiel #5
0
    def test_valid_creds(self, request):
        """Test str/repr has URL."""
        http = Http(url=get_url(request), certwarn=False)

        auth = ApiKey(http=http, **get_key_creds(request))

        auth.login()

        assert auth.is_logged_in
        assert "url" in format(auth)
        assert "url" in repr(auth)
Beispiel #6
0
    def test_login_already_logged_in(self, request):
        """Test exc thrown when login() and login() already called."""
        http = Http(url=get_url(request), certwarn=False)

        auth = ApiKey(http=http, **get_key_creds(request))

        auth.login()

        with pytest.raises(AlreadyLoggedIn):
            auth.login()
Beispiel #7
0
    def test_logout(self, request):
        """Test no exc when logout() after login()."""
        http = Http(url=get_url(request), certwarn=False)

        auth = ApiKey(http=http, **get_key_creds(request))

        auth.login()

        assert auth.is_logged_in

        auth.logout()

        assert not auth.is_logged_in