You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/07/01 23:46:52 UTC

git commit: [#6411] ticket:384 Don't restrict URL shortener urls to HTTP GET only

Updated Branches:
  refs/heads/master 733c0b228 -> 7b386c7bf


[#6411] ticket:384 Don't restrict URL shortener urls to HTTP GET only


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/7b386c7b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/7b386c7b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/7b386c7b

Branch: refs/heads/master
Commit: 7b386c7bfef275bbc90faa902c324d0094245fb4
Parents: 733c0b2
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Jun 28 09:39:29 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Jul 1 21:46:05 2013 +0000

----------------------------------------------------------------------
 ForgeShortUrl/forgeshorturl/main.py               | 18 +++++++-----------
 .../forgeshorturl/tests/functional/test.py        |  9 +++++++++
 2 files changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7b386c7b/ForgeShortUrl/forgeshorturl/main.py
----------------------------------------------------------------------
diff --git a/ForgeShortUrl/forgeshorturl/main.py b/ForgeShortUrl/forgeshorturl/main.py
index 3081e81..c8e16c0 100644
--- a/ForgeShortUrl/forgeshorturl/main.py
+++ b/ForgeShortUrl/forgeshorturl/main.py
@@ -181,17 +181,13 @@ class RootController(BaseController):
 
     @expose()
     def _lookup(self, pname, *remainder):
-        if request.method == 'GET':
-            query = {'app_config_id': c.app.config._id,
-                     'short_name': pname}
-            if not has_access(c.app, 'view_private'):
-                query['private'] = False
-            short_url = ShortUrl.query.find(query).first()
-            if short_url:
-                redirect(short_url.full_url)
-
-        flash("We're sorry but we weren't able "
-              "to process this request.", "error")
+        query = {'app_config_id': c.app.config._id,
+                 'short_name': pname}
+        if not has_access(c.app, 'view_private'):
+            query['private'] = False
+        short_url = ShortUrl.query.find(query).first()
+        if short_url:
+            redirect(short_url.full_url)
         raise exc.HTTPNotFound()
 
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7b386c7b/ForgeShortUrl/forgeshorturl/tests/functional/test.py
----------------------------------------------------------------------
diff --git a/ForgeShortUrl/forgeshorturl/tests/functional/test.py b/ForgeShortUrl/forgeshorturl/tests/functional/test.py
index 8f0fc64..997050f 100644
--- a/ForgeShortUrl/forgeshorturl/tests/functional/test.py
+++ b/ForgeShortUrl/forgeshorturl/tests/functional/test.py
@@ -44,6 +44,15 @@ class TestRootController(TestController):
         redirected = self.app.get('/url/test').follow()
         assert redirected.request.url == 'http://www.google.com/'
 
+    def test_shorturl_http_head(self):
+        response = self.app.get('/admin/url/add')
+        response.form['short_url'] = 'test'
+        response.form['full_url'] = 'http://www.google.com/'
+        response.form.submit()
+        r = self.app.head('/url/test')
+        assert r.status_int == 302
+        assert r.headers['Location'] == 'http://www.google.com/'
+
     def test_shorturl_update(self):
         response = self.app.get('/admin/url/add')
         response.form['short_url'] = 'g'