Merge lp:~cjwatson/launchpad/fix-login-discharge-macaroon into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18081
Proposed branch: lp:~cjwatson/launchpad/fix-login-discharge-macaroon
Merge into: lp:launchpad
Diff against target: 85 lines (+33/-15)
2 files modified
lib/lp/services/webapp/templates/login-discharge-macaroon.pt (+27/-15)
lib/lp/services/webapp/tests/test_login.py (+6/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/fix-login-discharge-macaroon
Reviewer Review Type Date Requested Status
Celso Providelo (community) Approve
Launchpad code reviewers Pending
Review via email: mp+295925@code.launchpad.net

Commit message

Fix the OpenID callback view to actually work properly when receiving a discharge macaroon.

Description of the change

Fix the OpenID callback view to actually work properly when receiving a discharge macaroon.

It was lacking a submit button, and the JS code to auto-submit it wasn't hooked up quite right. I've done a straight-through test with this on dogfood.

To post a comment you must log in.
Revision history for this message
Celso Providelo (cprov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/services/webapp/templates/login-discharge-macaroon.pt'
--- lib/lp/services/webapp/templates/login-discharge-macaroon.pt 2016-05-19 02:02:39 +0000
+++ lib/lp/services/webapp/templates/login-discharge-macaroon.pt 2016-05-27 10:02:12 +0000
@@ -6,7 +6,23 @@
6 metal:use-macro="view/macro:page/main_only"6 metal:use-macro="view/macro:page/main_only"
7 i18n:domain="launchpad">7 i18n:domain="launchpad">
88
9 <body onload="document.forms[0].submit();">9 <metal:block fill-slot="head_epilogue">
10 <script type="text/javascript"
11 tal:content="structure string:
12 LPJS.use('event', function(Y) {
13 Y.on('load', function(e) {
14 var form = document.getElementById('discharge-form');
15 var elements = form.elements;
16 for (var i = 0; i < elements.length; i++) {
17 elements[i].style.display = 'none';
18 }
19 form.submit();
20 });
21 });">
22 </script>
23 </metal:block>
24
25 <body>
10 <div class="top-portlet" metal:fill-slot="main">26 <div class="top-portlet" metal:fill-slot="main">
11 <h1>OpenID transaction in progress</h1>27 <h1>OpenID transaction in progress</h1>
1228
@@ -15,22 +31,18 @@
15 method="post"31 method="post"
16 enctype="application/x-www-form-urlencoded"32 enctype="application/x-www-form-urlencoded"
17 accept-charset="UTF-8">33 accept-charset="UTF-8">
18 <input type="hidden"34 <div class="actions">
19 tal:condition="view/params/discharge_macaroon_action"35 <input type="hidden"
20 tal:attributes="name view/params/discharge_macaroon_action"36 tal:condition="view/params/discharge_macaroon_action"
21 value="1" />37 tal:attributes="name view/params/discharge_macaroon_action"
22 <input type="hidden"38 value="1" />
23 tal:attributes="name view/params/discharge_macaroon_field;39 <input type="hidden"
24 value view/discharge_macaroon_raw" />40 tal:attributes="name view/params/discharge_macaroon_field;
41 value view/discharge_macaroon_raw" />
42 <input type="submit" value="Continue" />
43 </div>
25 </form>44 </form>
26 </div>45 </div>
27
28 <script>
29 var elements = document.forms[0].elements;
30 for (var i = 0; i < elements.length; i++) {
31 elements[i].style.display = "none";
32 }
33 </script>
34 </body>46 </body>
3547
36</html>48</html>
3749
=== modified file 'lib/lp/services/webapp/tests/test_login.py'
--- lib/lp/services/webapp/tests/test_login.py 2016-05-19 02:02:39 +0000
+++ lib/lp/services/webapp/tests/test_login.py 2016-05-27 10:02:12 +0000
@@ -512,13 +512,19 @@
512 [dict(tag.attrs) for tag in discharge_form.findAll('input')],512 [dict(tag.attrs) for tag in discharge_form.findAll('input')],
513 MatchesListwise([513 MatchesListwise([
514 ContainsDict({514 ContainsDict({
515 'type': Equals('hidden'),
515 'name': Equals('field.actions.complete'),516 'name': Equals('field.actions.complete'),
516 'value': Equals('1'),517 'value': Equals('1'),
517 }),518 }),
518 ContainsDict({519 ContainsDict({
520 'type': Equals('hidden'),
519 'name': Equals('field.discharge_macaroon'),521 'name': Equals('field.discharge_macaroon'),
520 'value': Equals('dummy discharge'),522 'value': Equals('dummy discharge'),
521 }),523 }),
524 ContainsDict({
525 'type': Equals('submit'),
526 'value': Equals('Continue'),
527 }),
522 ]))528 ]))
523529
524 def test_discharge_macaroon_missing(self):530 def test_discharge_macaroon_missing(self):