Beispiel #1
0
 def test_url_insecuring_on_appspot_url(self):
     self.stub_server_name("non-default.khanacademie.appspot.com")
     # relative url
     self.assertEqual("http://non-default.khanacademie.appspot.com/foo",
                      url_util.insecure_url("/foo"))
     # Absolute url
     self.assertEqual("http://non-default.khanacademie.appspot.com/foo",
                      url_util.insecure_url("https://non-default.khanacademie.appspot.com/foo"))
     self.restore_server_name()
Beispiel #2
0
    def test_url_insecuring_on_normal_url(self):
        self.stub_server_name('www.iktel.nl')

        # relative URL
        self.assertEqual("http://www.iktel.nl/postlogin",
                         url_util.insecure_url("/postlogin"))

        # absolute URL
        self.assertEqual("http://www.iktel.nl/postlogin",
                         url_util.insecure_url("https://www.iktel.nl/postlogin"))
        self.restore_server_name()
def to_insecure_url(url):
    """ Returns the appropriate http server URL for a url
    somewhere on Khan Academy. Note - this is not intended for links to
    external sites.

    """

    return url_util.insecure_url(url)
Beispiel #4
0
def authorize_token_redirect(oauth_map, force_http=False):
    if not oauth_map:
        raise OAuthError("Missing oauth_map while returning " "authorize_token_redirect")

    if not oauth_map.callback_url:
        raise OAuthError("Missing callback URL during " "authorize_token_redirect")

    params = {
        "oauth_token": oauth_map.request_token,
        "oauth_token_secret": oauth_map.request_token_secret,
        "oauth_callback": oauth_map.callback_url_with_request_token_params(),
    }
    url = "/api/auth/authorize"
    if force_http:
        url = url_util.insecure_url(url)
    return redirect(append_url_params(url, params))
def authorize_token_redirect(oauth_map, force_http=False):
    if not oauth_map:
        raise OAuthError("Missing oauth_map while returning "
                         "authorize_token_redirect")

    if not oauth_map.callback_url:
        raise OAuthError("Missing callback URL during "
                         "authorize_token_redirect")

    params = {
        "oauth_token": oauth_map.request_token,
        "oauth_token_secret": oauth_map.request_token_secret,
        "oauth_callback": oauth_map.callback_url_with_request_token_params(),
    }
    url = "/api/auth/authorize"
    if force_http:
        url = url_util.insecure_url(url)
    return redirect(append_url_params(url, params))