'Test GenericConsumer.complete()\'s handling of bad return_to
values.'

def test_completeBadReturnTo(self):

    return_to = 'http://some.url/path?foo=bar'
    bad_return_tos = ['https://some.url/path?foo=bar', 'http://some.url.invalid/path?foo=bar', 'http://some.url/path_extra?foo=bar', 'http://some.url/path?foo=bar2', 'http://some.url/path?foo2=bar']
    m = Message(OPENID1_NS)
    m.setArg(OPENID_NS, 'mode', 'cancel')
    m.setArg(BARE_NS, 'foo', 'bar')
    endpoint = None
    for bad in bad_return_tos:
        m.setArg(OPENID_NS, 'return_to', bad)
        self.failIf(self.consumer._checkReturnTo(m, return_to))
