def test_google_get_default_certs_checks_status(app): """Get default certs should fetch the Google certificates but also check the status code of the response..""" # pylint: disable=unused-argument mock_resp = mock.MagicMock() mock_resp.status = 500 p = mock.patch( 'componentsdb.auth._cached_http.request', return_value=(mock_resp, '') ) with p, pytest.raises(HTTPException): _get_default_certs()
def test_google_get_default_certs(app): """Get default certs should fetch the Google certificates.""" # pylint: disable=unused-argument mock_resp = mock.MagicMock() mock_resp.status = 200 content = json.dumps(dict(foo='bar', buzz='quux')) p = mock.patch( 'componentsdb.auth._cached_http.request', return_value=(mock_resp, content) ) with p as o: cs = _get_default_certs() o.assert_called_with('https://www.googleapis.com/oauth2/v1/certs') assert cs == json.loads(content)