def test_extra_params(self): aer = AuthorizationErrorResponse(error="access_denied", error_description="brewers has a four game series", foo="bar") assert aer["error"] == "access_denied" assert aer["error_description"] == "brewers has a four game series" assert aer["foo"] == "bar"
def authz_error(error, descr=None, status_code=400): response = AuthorizationErrorResponse(error=error) if descr: response["error_description"] = descr return Response(response.to_json(), content="application/json", status="400 Bad Request")
def test_parse_authz_access_denied(self): sid, loc = self.consumer.begin("http://localhost:8087", "http://localhost:8088/authorization") atr = AuthorizationErrorResponse(error="access_denied", state=sid) with pytest.raises(AuthzError): self.consumer.handle_authorization_response( query=atr.to_urlencoded())
def redirect_authz_error(error, redirect_uri, descr=None, state="", return_type=None): err = AuthorizationErrorResponse(error=error) if descr: err["error_description"] = descr if state: err["state"] = state if return_type is None or return_type == ["code"]: location = err.request(redirect_uri) else: location = err.request(redirect_uri, True) return SeeOther(location)
def test_consumer_parse_authz_error(): _session_db = {} cons = Consumer(_session_db, client_config=CLIENT_CONFIG, server_info=SERVER_INFO, **CONSUMER_CONFIG) cons.debug = True _ = cons.begin("http://localhost:8087", "http://localhost:8088/authorization") atr = AuthorizationErrorResponse(error="access_denied", state=cons.state) QUERY_STRING = atr.to_urlencoded() raises(AuthzError, "cons.handle_authorization_response(query=QUERY_STRING)")
def test_init(self): aer = AuthorizationErrorResponse(error="access_denied", state="xyz") assert aer["error"] == "access_denied" assert aer["state"] == "xyz"