Merge lp://staging/~canonical-isd-hackers/canonical-identity-provider/bugs-632536-680256-long-query-improvements into lp://staging/canonical-identity-provider/release

Proposed by Stuart Metcalfe
Status: Merged
Approved by: Michael Nelson
Approved revision: no longer in the source branch.
Merged at revision: 119
Proposed branch: lp://staging/~canonical-isd-hackers/canonical-identity-provider/bugs-632536-680256-long-query-improvements
Merge into: lp://staging/canonical-identity-provider/release
Diff against target: 141 lines (+36/-21)
5 files modified
identityprovider/templates/consumer/index.html (+4/-0)
identityprovider/templates/post-assertion.html (+10/-20)
identityprovider/tests/test_middleware.py (+2/-0)
identityprovider/tests/test_views_consumer.py (+8/-1)
identityprovider/views/consumer.py (+12/-0)
To merge this branch: bzr merge lp://staging/~canonical-isd-hackers/canonical-identity-provider/bugs-632536-680256-long-query-improvements
Reviewer Review Type Date Requested Status
Anthony Lenton (community) Approve
Michael Nelson (community) code Approve
Review via email: mp+41537@code.staging.launchpad.net

Commit message

Simplified post redirect form and added option to test it in the test consumer

Description of the change

This branch simplifies the post redirect form on the identity provider and adds js to auto-submit where enabled (bug #632536). It also adds an associated option to the test consumer to help QA with testing (bug #680256).

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :
Download full text (7.2 KiB)

Hi Stuart!

This is my first CIP branch - so I'm sure I'm missing some context and I have asked some questions that are probably obvious. Sorry if that's painful :P I've not yet set the dev env. up, otherwise I would have tested some of the points below.

It was initially unclear to me which code was for tests only (ie. templates/consumer/* and views/consumer.py) - I'm not sure yet why these test-related code and templates are part of the normal application (rather than being a separate test app).

I've marked the MP as approved, but am keen to hear your thoughts on the points below - even if you choose to ignore them :) In retrospect, my main question is related to the only production change - the post-assertion.html template.

Finally, it might not be for this branch, but I can only see a test that verifies the post-assertion.html template is used (in test_middleware) - should there be a test somewhere verifying that the rendered response contains a form with a post action back to the consumer etc.?

Details below.

> === modified file 'identityprovider/templates/consumer/index.html'
> --- identityprovider/templates/consumer/index.html 2010-11-16 15:36:06 +0000
> +++ identityprovider/templates/consumer/index.html 2010-11-23 07:55:27 +0000
> @@ -135,6 +135,10 @@
> </table>
> </p>
>
> + <p>
> + <input type="checkbox" name="forcelongurl" id="id-forcelongurl" value="1" />
> + <label for="id-forcelongurl">Force long return URL</label>
> + </p>

I'm not sure this is the best way to test for long urls (ie. adding code
to the view that checks for this param which should only be used for testing
etc.). Could it be better to actually include a long URL here?
(rather than fabricating one inside the consumer view)?

It should be easy to do this by changing the above to be a radio option,
something like:
  <input type="radio" name="forcelongurl" id="id-forcelongurl-false" value="false">
  <label for="id-forcelongurl-false">Normal URL</label>
  <input type="radio" name="forcelongurl" id="id-forcelongurl-true"
    value="longurl-longurl-longurl-longurl-longurl-generate-me-in-code-etc">
  <label for="id-forcelongurl-true">Long URL (requiring POST back to consumer)</label>

AFAICS, the posted params are passed through during consumer_views.finishOpenID - but haven't verified.

> <input type="submit" value="Begin" />
> </form>
>
>
> === modified file 'identityprovider/templates/post-assertion.html'
> --- identityprovider/templates/post-assertion.html 2010-07-12 19:11:15 +0000
> +++ identityprovider/templates/post-assertion.html 2010-11-23 07:55:27 +0000
> @@ -1,27 +1,13 @@
> -{% extends "base.html" %}
> -{% load i18n %}
> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> {% comment %}
> Copyright 2010 Canonical Ltd. This software is licensed under the
> GNU Affero General Public License version 3 (see the file LICENSE).
> {% endcomment %}
>
> -{% block title %}
> - {% trans "Continue to 3rd-party site" %}
> -{% endblock %}
> -
> -{% block text_title %}
> - <h1 class="main">{% trans "Continue to 3rd-party site" %}</h1>
> -{% e...

Read more...

review: Approve (code)
Revision history for this message
Stuart Metcalfe (stuartmetcalfe) wrote :
Download full text (5.3 KiB)

Hi Michael

On Tue, 2010-11-23 at 10:04 +0000, Michael Nelson wrote:
> It was initially unclear to me which code was for tests only (ie.
> templates/consumer/* and views/consumer.py) - I'm not sure yet why
> these test-related code and templates are part of the normal
> application (rather than being a separate test app).

That's a good question. What you've suggested makes sense but is beyond
the scope of this branch so I've filed bug #680427 to track it.

> Finally, it might not be for this branch, but I can only see a test that
> verifies the post-assertion.html template is used (in test_middleware) -
> should there be a test somewhere verifying that the rendered response
> contains a form with a post action back to the consumer etc.?

That's a good point. I've added two new assertions to that code - one
for the form element and one for the post method. If you know a
non-fragile way of capturing both in one simple test, please let me
know.

While I was in there, I discovered openid.message.OPENID1_URL_LIMIT so
have updated my changes to use that. This helped me improve one of my
tests by explicitly testing that the return_to URL is over this length.

> Details below.
>
> > === modified file 'identityprovider/templates/consumer/index.html'
> > --- identityprovider/templates/consumer/index.html 2010-11-16 15:36:06 +0000
> > +++ identityprovider/templates/consumer/index.html 2010-11-23 07:55:27 +0000
> > @@ -135,6 +135,10 @@
> > </table>
> > </p>
> >
> > + <p>
> > + <input type="checkbox" name="forcelongurl" id="id-forcelongurl" value="1" />
> > + <label for="id-forcelongurl">Force long return URL</label>
> > + </p>
>
> I'm not sure this is the best way to test for long urls (ie. adding code
> to the view that checks for this param which should only be used for testing
> etc.). Could it be better to actually include a long URL here?
> (rather than fabricating one inside the consumer view)?
>
> It should be easy to do this by changing the above to be a radio option,
> something like:
> <input type="radio" name="forcelongurl" id="id-forcelongurl-false" value="false">
> <label for="id-forcelongurl-false">Normal URL</label>
> <input type="radio" name="forcelongurl" id="id-forcelongurl-true"
> value="longurl-longurl-longurl-longurl-longurl-generate-me-in-code-etc">
> <label for="id-forcelongurl-true">Long URL (requiring POST back to consumer)</label>
>
> AFAICS, the posted params are passed through during consumer_views.finishOpenID - but haven't verified.
>
> > <input type="submit" value="Begin" />
> > </form>

I think that passing the long URL into the template from the index view
makes it harder to understand what's going on. The only reason I'd
consider it would be if we wanted to enable editing of the long query
string, but we don't as its content has no effect on the OpenID
transaction. The purpose of this option is merely to trigger the
conditions under which the POST form is used.

> > +<html>
> > + <body onload="document.forms[0].submit()">
> > + {{ form|safe }}
> > + </body>
> > +</html>
>
> Now this is actual production code :) I see from comment
>
> https://bugs.lau...

Read more...

Revision history for this message
Michael Nelson (michael.nelson) wrote :

Nice spot with the OPENID1_URL_LIMIT, and thanks for filling me in on the background.

Revision history for this message
Anthony Lenton (elachuni) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.