incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#6595] Make Download Snapshot require POST
Date Fri, 23 Aug 2013 17:59:20 GMT
Updated Branches:
  refs/heads/master 0fb6390f1 -> 259ae6e90


[#6595] Make Download Snapshot require POST

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>


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

Branch: refs/heads/master
Commit: 259ae6e907107cd35687196fdb701bba807e93a3
Parents: 0fb6390
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Thu Aug 22 20:38:58 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Aug 23 17:59:04 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         |  1 +
 Allura/allura/templates/repo/tree.html          | 32 ++++++++++++++++++--
 .../tests/functional/test_controllers.py        | 17 +++++------
 .../tests/functional/test_controllers.py        | 21 ++++++-------
 4 files changed, 47 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/259ae6e9/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 36b4bdc..b1b743c 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -458,6 +458,7 @@ class CommitBrowser(BaseController):
             result.update(self._commit.context())
         return result
 
+    @require_post()
     @expose('jinja:allura:templates/repo/tarball.html')
     def tarball(self, **kw):
         path = kw.pop('path', None)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/259ae6e9/Allura/allura/templates/repo/tree.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/tree.html b/Allura/allura/templates/repo/tree.html
index b2dbcfe..851ad38 100644
--- a/Allura/allura/templates/repo/tree.html
+++ b/Allura/allura/templates/repo/tree.html
@@ -29,11 +29,37 @@ Tree <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a>
{{commit_labels(co
 {{lib.path_links(path.split('/')[1:])}}
 {% endblock %}
 
+{% block extra_css %}
+<style>
+form.tarball {
+  display: inline;
+  margin: 0;
+  padding: 0;
+}
+form.tarball button {
+    background: none;
+    border: 0;
+    box-shadow: none;
+    text-shadow: none;
+    color:  #fff;
+    font-family: "Ubuntu", sans-serif;
+    font-weight: normal;;
+    padding: 0;
+    font-size: 12px;
+    line-height: 36px;
+}
+form.tarball button:hover {
+  border: 0 !important;
+}
+</style>
+{% endblock %}
+
 {% block actions %}
 {% if tarball_url %}
-<a href="{{ tarball_url + ('?path=' + path if path else '') }}" rel="nofollow">
-    <b data-icon="{{g.icons.folder.char}}" class="ico {{g.icons.folder.css}}" title="Snapshot">
</b> Download Snapshot
-</a>
+<form class="tarball" action="{{ tarball_url }}" method="post">
+  <input type="hidden" name="path" value="{{ path or '' }}" />
+  <button><b data-icon="{{g.icons.folder.char}}" class="ico {{g.icons.folder.css}}"
title="Snapshot"></b> Download Snapshot</button>
+</form>
 {% endif %}
 
 <a href="{{commit.url()}}log/?path={{ path }}">

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/259ae6e9/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 597c5bb..4b9476b 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -294,8 +294,7 @@ class TestRootController(_TestCase):
         assert not M.Mailbox.subscribed(user_id=user._id)
         r = self.app.get(ci + 'tree/',
                 extra_environ={'username': str(user.username)})
-        header = r.html.find('h2', {'class': 'dark title'})
-        link = header.find('a', {'class': 'artifact_subscribe'})
+        link = r.html.find('a', 'artifact_subscribe')
         assert link is not None, header
 
         # subscribe
@@ -305,8 +304,7 @@ class TestRootController(_TestCase):
         assert M.Mailbox.subscribed(user_id=user._id)
         r = self.app.get(ci + 'tree/',
                 extra_environ={'username': str(user.username)})
-        header = r.html.find('h2', {'class': 'dark title'})
-        link = header.find('a', {'class': 'artifact_unsubscribe active'})
+        link = r.html.find('a', 'artifact_unsubscribe active')
         assert link is not None, header
 
         # unsubscribe
@@ -316,8 +314,7 @@ class TestRootController(_TestCase):
         assert not M.Mailbox.subscribed(user_id=user._id)
         r = self.app.get(ci + 'tree/',
                 extra_environ={'username': str(user.username)})
-        header = r.html.find('h2', {'class': 'dark title'})
-        link = header.find('a', {'class': 'artifact_subscribe'})
+        link = r.html.find('a', 'artifact_subscribe')
         assert link is not None, header
 
     def test_timezone(self):
@@ -345,7 +342,7 @@ class TestRootController(_TestCase):
         r = self.app.get(ci + 'tree/')
         assert '/p/test/src-git/ci/master/tarball' in r
         assert 'Download Snapshot' in r
-        r = self.app.get('/p/test/src-git/ci/master/tarball')
+        r = self.app.post('/p/test/src-git/ci/master/tarball')
         assert 'Generating snapshot...' in r
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
@@ -358,9 +355,9 @@ class TestRootController(_TestCase):
         '''Go to repo subdir and check 'Download Snapshot' link'''
         self.setup_testgit_index_repo()
         r = self.app.get('/p/test/testgit-index/ci/master/tree/index/')
-        links = r.html.findAll('a')
-        download_link = [a for a in links if a.text == 'Download Snapshot'][0]
-        assert_equal(download_link.get('href'), '/p/test/testgit-index/ci/master/tarball?path=/index')
+        form = r.html.find('form', 'tarball')
+        assert_equal(form.get('action'), '/p/test/testgit-index/ci/master/tarball')
+        assert_equal(form.input.get('value'), '/index')
 
     def test_default_branch(self):
         assert_equal(c.app.default_branch_name, 'master')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/259ae6e9/ForgeSVN/forgesvn/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/functional/test_controllers.py b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
index 1898435..78e7705 100644
--- a/ForgeSVN/forgesvn/tests/functional/test_controllers.py
+++ b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
@@ -193,7 +193,7 @@ class TestRootController(SVNTestController):
     def test_tarball(self):
         r = self.app.get('/src/3/tree/')
         assert 'Download Snapshot' in r
-        r = self.app.get('/src/3/tarball')
+        r = self.app.post('/src/3/tarball')
         assert 'Generating snapshot...' in r
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
@@ -205,20 +205,19 @@ class TestRootController(SVNTestController):
         h.set_context('test', 'svn-tags', neighborhood='Projects')
         shutil.rmtree(c.app.repo.tarball_path, ignore_errors=True)
         r = self.app.get('/p/test/svn-tags/19/tree/')
-        link = r.html.find('h2', attrs={'class': 'dark title'})
-        link = link.find('small').findAll('a')[0]
-        assert_equal(link.text, 'Download Snapshot')
-        assert_equal(link.get('href'), '/p/test/svn-tags/19/tarball')
+        form = r.html.find('form', 'tarball')
+        assert_equal(form.button.text, 'Download Snapshot')
+        assert_equal(form.get('action'), '/p/test/svn-tags/19/tarball')
 
         r = self.app.get('/p/test/svn-tags/19/tree/tags/tag-1.0/')
-        link = r.html.find('h2', attrs={'class': 'dark title'})
-        link = link.find('small').findAll('a')[0]
-        assert_equal(link.text, 'Download Snapshot')
-        assert_equal(link.get('href'), '/p/test/svn-tags/19/tarball?path=/tags/tag-1.0')
+        form = r.html.find('form', 'tarball')
+        assert_equal(form.button.text, 'Download Snapshot')
+        assert_equal(form.get('action'), '/p/test/svn-tags/19/tarball')
+        assert_equal(form.find('input', attrs=dict(name='path')).get('value'), '/tags/tag-1.0')
 
         r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/tags/tag-1.0')
         assert_equal(r.json['status'], None)
-        r = self.app.get(link.get('href'))
+        r = self.app.post('/p/test/svn-tags/19/tarball', dict(path='/tags/tag-1.0'))
         assert 'Generating snapshot...' in r
         M.MonQTask.run_ready()
         r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/tags/tag-1.0')
@@ -226,7 +225,7 @@ class TestRootController(SVNTestController):
 
         r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/trunk')
         assert_equal(r.json['status'], None)
-        r = self.app.get('/p/test/svn-tags/19/tarball?path=/trunk/')
+        r = self.app.post('/p/test/svn-tags/19/tarball', dict(path='/trunk/'))
         assert 'Generating snapshot...' in r
         M.MonQTask.run_ready()
         r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/trunk')


Mime
View raw message