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

feat: return the value needed to perform the polling #97

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyeudiw/satosa/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def pre_request_endpoint(self, context, internal_request, **kwargs):
qrcode = QRCode(res_url, **self.config['qrcode'])

result = self.template.qrcode_page.render(
{"title": "Frame the qrcode", 'qrcode_base64': qrcode.to_base64()}
{"title": "Frame the qrcode", 'qrcode_base64': qrcode.to_base64(), "state": state}
)
return Response(result, content="text/html; charset=utf8", status="200")

Expand Down
1 change: 1 addition & 0 deletions pyeudiw/tests/satosa/templates/qrcode.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<h1>Inquadra il qr code con il tuo smartphone</h1>

<div id="state" value="{{ state }}"></div>
<img width="33%" src='data:image/svg+xml;base64,{{ qrcode_base64 }}'>

{% endblock body %}
5 changes: 5 additions & 0 deletions pyeudiw/tests/satosa/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ def test_pre_request_endpoint(self, context):
# decode the base64 data
decoded = base64.b64decode(data).decode("utf-8")

# get the div with id "state"
state_div = soup.find("div", {"id": "state"})
assert state_div
assert state_div["value"]

svg = BeautifulSoup(decoded, features="xml")
assert svg
assert svg.find("svg")
Expand Down