Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test MeB OAuth provider #518

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Test MeB OAuth provider

6cadd3a
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Open

Test MeB OAuth provider #518

Test MeB OAuth provider
6cadd3a
Select commit
Loading
Failed to load commit list.
GitHub Actions / Test Results failed Sep 9, 2024 in 0s

1 fail, 200 pass in 53s

201 tests   200 ✅  53s ⏱️
  1 suites    0 💤
  1 files      1 ❌

Results for commit 6cadd3a.

Annotations

Check warning on line 0 in critiquebrainz.frontend.views.test.test_login.LoginViewsTestCase

See this annotation in the file changed.

@github-actions github-actions / Test Results

test_login_oauth (critiquebrainz.frontend.views.test.test_login.LoginViewsTestCase) failed

reports/tests.xml [took 0s]
Raw output
requests.exceptions.MissingSchema: Invalid URL '/token': No scheme supplied. Perhaps you meant https:///token?
self = <critiquebrainz.frontend.views.test.test_login.LoginViewsTestCase testMethod=test_login_oauth>
mock_requests = <requests_mock.mocker.Mocker object at 0x7f136961d2d0>

    @requests_mock.Mocker()
    def test_login_oauth(self, mock_requests):
        """ Tests that creating a new user, update MB username and login to CB updates MB username in CB db """
        row_id = 1111
    
        mock_requests.post("https://musicbrainz.org/oauth2/token", json={
          "access_token": "UF7GvG2pl70jTogIwOhD32BhI_aIevPF",
          "expires_in": 3600,
          "token_type": "Bearer",
          "refresh_token": "GjSCBBjp4fnbE0AKo3uFu9qq9K2fFm4u"
        })
    
        mock_requests.get("https://musicbrainz.org/oauth2/userinfo", json={
            "sub": "old-user-name",
            "metabrainz_user_id": row_id
        })
    
        response = self.client.get(url_for("login.musicbrainz"))
        params = parse_qs(urlparse(response.location).query)
>       response = self.client.get(
            url_for("login.musicbrainz_post", code="foobar", state=params["state"][0]),
            follow_redirects=True
        )

critiquebrainz/frontend/views/test/test_login.py:37: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/local/lib/python3.11/site-packages/werkzeug/test.py:1162: in get
    return self.open(*args, **kw)
/usr/local/lib/python3.11/site-packages/flask/testing.py:232: in open
    response = super().open(
/usr/local/lib/python3.11/site-packages/werkzeug/test.py:1116: in open
    response_parts = self.run_wsgi_app(request.environ, buffered=buffered)
/usr/local/lib/python3.11/site-packages/werkzeug/test.py:988: in run_wsgi_app
    rv = run_wsgi_app(self.application, environ, buffered=buffered)
/usr/local/lib/python3.11/site-packages/werkzeug/test.py:1264: in run_wsgi_app
    app_rv = app(environ, start_response)
/usr/local/lib/python3.11/site-packages/flask/app.py:1478: in __call__
    return self.wsgi_app(environ, start_response)
/usr/local/lib/python3.11/site-packages/flask/app.py:1458: in wsgi_app
    response = self.handle_exception(e)
/usr/local/lib/python3.11/site-packages/flask/app.py:1455: in wsgi_app
    response = self.full_dispatch_request()
/usr/local/lib/python3.11/site-packages/flask/app.py:869: in full_dispatch_request
    rv = self.handle_user_exception(e)
/usr/local/lib/python3.11/site-packages/flask/app.py:867: in full_dispatch_request
    rv = self.dispatch_request()
/usr/local/lib/python3.11/site-packages/flask/app.py:852: in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
critiquebrainz/frontend/login/__init__.py:39: in decorated
    return f(*args, **kwargs)
critiquebrainz/frontend/views/login.py:29: in musicbrainz_post
    user = mb_auth.get_user()
critiquebrainz/frontend/login/provider.py:73: in get_user
    s = self._service.get_auth_session(
/usr/local/lib/python3.11/site-packages/rauth/service.py:556: in get_auth_session
    session = self.get_session(self.get_access_token(method, **kwargs))
/usr/local/lib/python3.11/site-packages/rauth/service.py:541: in get_access_token
    r = self.get_raw_access_token(method, **kwargs)
/usr/local/lib/python3.11/site-packages/rauth/service.py:516: in get_raw_access_token
    self.access_token_response = session.request(method,
/usr/local/lib/python3.11/site-packages/rauth/session.py:358: in request
    return super(OAuth2Session, self).request(method, url, **req_kwargs)
/usr/local/lib/python3.11/site-packages/requests/sessions.py:575: in request
    prep = self.prepare_request(req)
/usr/local/lib/python3.11/site-packages/requests/sessions.py:484: in prepare_request
    p.prepare(
/usr/local/lib/python3.11/site-packages/requests/models.py:367: in prepare
    self.prepare_url(url, params)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <PreparedRequest [POST]>, url = '/token', params = OrderedDict()

    def prepare_url(self, url, params):
        """Prepares the given HTTP URL."""
        #: Accept objects that have string representations.
        #: We're unable to blindly call unicode/str functions
        #: as this will include the bytestring indicator (b'')
        #: on python 3.x.
        #: https://github.com/psf/requests/pull/2238
        if isinstance(url, bytes):
            url = url.decode("utf8")
        else:
            url = str(url)
    
        # Remove leading whitespaces from url
        url = url.lstrip()
    
        # Don't do any URL preparation for non-HTTP schemes like `mailto`,
        # `data` etc to work around exceptions from `url_parse`, which
        # handles RFC 3986 only.
        if ":" in url and not url.lower().startswith("http"):
            self.url = url
            return
    
        # Support for unicode domain names and paths.
        try:
            scheme, auth, host, port, path, query, fragment = parse_url(url)
        except LocationParseError as e:
            raise InvalidURL(*e.args)
    
        if not scheme:
>           raise MissingSchema(
                f"Invalid URL {url!r}: No scheme supplied. "
                f"Perhaps you meant https://{url}?"
            )
E           requests.exceptions.MissingSchema: Invalid URL '/token': No scheme supplied. Perhaps you meant https:///token?

/usr/local/lib/python3.11/site-packages/requests/models.py:438: MissingSchema