Skip to content

Add support for MeB.org OAuth provider #564

Add support for MeB.org OAuth provider

Add support for MeB.org OAuth provider #564

GitHub Actions / Test Results failed Apr 26, 2024 in 0s

1 fail, 200 pass in 52s

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

Results for commit 1ecc1ae.

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_mock.exceptions.NoMockAddress: No mock address: POST https://test.musicbrainz.org/new-oauth2/token
self = <critiquebrainz.frontend.views.test.test_login.LoginViewsTestCase testMethod=test_login_oauth>
mock_requests = <requests_mock.mocker.Mocker object at 0x7fa53b48d490>

    @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:1160: 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:1114: in open
    response = self.run_wsgi_app(request.environ, buffered=buffered)
/usr/local/lib/python3.11/site-packages/werkzeug/test.py:986: in run_wsgi_app
    rv = run_wsgi_app(self.application, environ, buffered=buffered)
/usr/local/lib/python3.11/site-packages/werkzeug/test.py:1262: 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:589: in request
    resp = self.send(prep, **send_kwargs)
/usr/local/lib/python3.11/site-packages/requests_mock/mocker.py:144: in _fake_send
    return _original_send(session, request, **kwargs)
/usr/local/lib/python3.11/site-packages/requests/sessions.py:703: in send
    r = adapter.send(request, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <requests_mock.adapter.Adapter object at 0x7fa53b6b9690>
request = <requests_mock.request._RequestObjectProxy object at 0x7fa53b34b110>
kwargs = {'cert': None, 'proxies': OrderedDict(), 'stream': False, 'timeout': 300.0, ...}
matcher = <requests_mock.adapter._Matcher object at 0x7fa53b4740d0>, resp = None

    def send(self, request, **kwargs):
        request = _RequestObjectProxy(request,
                                      case_sensitive=self._case_sensitive,
                                      **kwargs)
        self._add_to_history(request)
    
        for matcher in reversed(self._matchers):
            try:
                resp = matcher(request)
            except Exception:
                request._matcher = weakref.ref(matcher)
                raise
    
            if resp is not None:
                request._matcher = weakref.ref(matcher)
                resp.connection = self
                logger.debug('{} {} {}'.format(request._request.method,
                                               request._request.url,
                                               resp.status_code))
                return resp
    
>       raise exceptions.NoMockAddress(request)
E       requests_mock.exceptions.NoMockAddress: No mock address: POST https://test.musicbrainz.org/new-oauth2/token

/usr/local/lib/python3.11/site-packages/requests_mock/adapter.py:261: NoMockAddress