> Now how do I test an action that must use SSL? (I want a 304 bounce
> message if the user tries to use plain text.)

This looks promising!

class SSLAwareClient(Client):
    def __init__(self, *args, **kwargs):
        super(SSLAwareClient, self).__init__(*args, **kwargs)
        self.ssl = False

    def request(self, **request):
        path = request.get('PATH_INFO', '/')
        if path.startswith('http://'):
            self.ssl = False
            path = path[path.find('/', 7):]
        elif path.startswith('https://'):
            self.ssl = True
            path = path[path.find('/', 8):]
        request['PATH_INFO'] = path
        if self.ssl:
            request['HTTP_X_FORWARDED_SSL'] = 'on'
        ret = super(SSLAwareClient, self).request(**request)
        if ret.status_code in (301, 302):
            assert request['REQUEST_METHOD'] != 'POST', 'Cannot
redirect posts: %s' % path
            if '?' in ret['Location']:
                path, querystring = ret['Location'].split('?')
                return self.get(path, QUERY_STRING=querystring)
            return self.get(ret['Location'])
        return ret

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to