def test_url_securing_on_appspot_url(self): self.stub_server_name("non-default.khanacademie.appspot.com") # relative url self.assertEqual("https://non-default.khanacademie.appspot.com/foo", url_util.secure_url("/foo")) # Absolute url self.assertEqual("https://non-default.khanacademie.appspot.com/foo", url_util.secure_url("http://non-default.khanacademie.appspot.com/foo")) self.restore_server_name()
def test_url_securing_on_normal_url(self): self.stub_server_name('www.khanacademy.org') # relative url self.assertEqual("https://khan-academy.appspot.com/login", url_util.secure_url("/login")) # Absolute url (gets re-written to appspot) self.assertEqual("https://khan-academy.appspot.com/login", url_util.secure_url("http://www.khanacademy.org/login")) self.restore_server_name()
def to_secure_url(url): """ Returns the appropriate https server URL for a url somewhere on Khan Academy. Note - this is not intended for links to external sites. This abstracts away some of the difficulties and limitations of https in the current environment. """ return url_util.secure_url(url)