You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/03/27 20:28:27 UTC

[01/14] git commit: [#7287] add a few pointers and text tweaks; move ssh/ldap auth to its own page

Repository: allura
Updated Branches:
  refs/heads/cj/7134 1c2ed49b5 -> 2fe81357b (forced update)


[#7287] add a few pointers and text tweaks; move ssh/ldap auth to its own page


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

Branch: refs/heads/cj/7134
Commit: 829f9675c8c97931a335fdae7419f72c25b4ecbf
Parents: f396835
Author: Dave Brondsema <da...@brondsema.net>
Authored: Wed Mar 26 15:50:28 2014 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Wed Mar 26 15:51:11 2014 -0400

----------------------------------------------------------------------
 Allura/docs/scm_host.rst     | 200 +++-----------------------------------
 Allura/docs/scm_host_ssh.rst | 197 +++++++++++++++++++++++++++++++++++++
 2 files changed, 211 insertions(+), 186 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/829f9675/Allura/docs/scm_host.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/scm_host.rst b/Allura/docs/scm_host.rst
index 82bb6a7..3a80490 100644
--- a/Allura/docs/scm_host.rst
+++ b/Allura/docs/scm_host.rst
@@ -70,7 +70,7 @@ If there is no output, that is fine (it's an empty repo).
 
 .. warning::
 
-    This configuration has no authentication and is suitable for development only.
+    This configuration has no authentication and is suitable for development only.  See :ref:`below <auth_apache>` for auth config.
 
 Now you will want to change the :samp:`scm.host.{*}.git`
 settings in :file:`development.ini`, so that the proper commands are shown to your visitors
@@ -110,6 +110,7 @@ run :command:`killall svnserve`  More info at http://svnbook.red-bean.com/en/1.8
 .. warning::
 
     This configuration has no authentication and is suitable for development only.
+    (Maybe Allura could gain SASL support someday and use `svnserve with SASL <http://svnbook.red-bean.com/en/1.7/svn.serverconfig.svnserve.html#svn.serverconfig.svnserve.sasl>`_)
 
 Now you will want to change the :samp:`scm.host.{*}.svn`
 settings in :file:`development.ini`, so that the proper commands are shown to your visitors
@@ -166,15 +167,16 @@ Then Apache SVN will serve repositories for all Allura projects and subprojects.
 
 .. warning::
 
-    This configuration has no authentication and is suitable for development only.
+    This configuration has no authentication and is suitable for development only.  See :ref:`the next section <auth_apache>` for auth config.
 
 
+.. _auth_apache:
 
-Configuring Git/SVN/Hg to use Allura auth via mod_python and ApacheAccessHandler.py
-===================================================================================
+Configuring Auth with Apache
+-----------------------------------------------
 
-This is the easiest way to integrate authentication for SCM access with Allura.  It uses
-mod_python and the handler in `scripts/ApacheAccessHandler.py` to query Allura directly
+This is the easiest way to integrate authentication and authorization for SCM access with Allura.  It uses
+mod_python and the handler in :file:`scripts/ApacheAccessHandler.py` to query Allura directly
 for auth and permissions before allowing access to the SCM.  Of course, this only works
 for SCM access over HTTP(S).
 
@@ -191,11 +193,11 @@ access handler, e.g.:
 
     <LocationMatch "^/(git|svn|hg)/">
         AddHandler mod_python .py
-        PythonAccessHandler /var/local/allura/scripts/ApacheAccessHandler.py
+        PythonAccessHandler /PATH/TO/allura/scripts/ApacheAccessHandler.py
         AuthType Basic
         AuthName "SCM Access"
         AuthBasicAuthoritative off
-        PythonOption ALLURA_VIRTUALENV /var/local/env-allura
+        PythonOption ALLURA_VIRTUALENV /PATH/TO/env-allura
         PythonOption ALLURA_AUTH_URL https://127.0.0.1/auth/do_login
         PythonOption ALLURA_PERM_URL https://127.0.0.1/auth/repo_permissions
     </LocationMatch>
@@ -208,184 +210,10 @@ and password will be otherwise be sent in the clear to Allura.
 
     Currently, for Mercurial, the handler doesn't correctly distinguish read
     and write requests and thus requires WRITE permission for every request.
+    See ticket #7288
 
 
+Advanced Alternative
+-----------------------------------------------
 
-Configuring Git/SVN/Hg to use Allura auth via LDAP and ssh
-============================================================
-
-The following instructions will use a chroot, a custom FUSE driver, and LDAP.
-Once completed, an ssh-based configuration of Git, SVN, or Hg that has repos in
-the chroot directory will authenticate the users against LDAP and authorize via an Allura API.
-Allura will be configured to authenticate against LDAP as well.
-
-.. note::
-
-    The previous git & svn configuration instructions are not ssh-based, so will not work with this configuration.
-    You'll have to reconfigure git & svn to use ssh:// instead of http or svn protocols.
-
-We assume you are using a version of Ubuntu with
-support for schroot and debootstrap.  We will use a chroot jail to allow users to
-access their repositories via ssh.
-
-Install a chroot environment
--------------------------------------------
-
-These instructions are based on the documentation in `Debootstrap Chroot`_.  and `OpenLDAPServer`_.
-
-Install debootstrap and schroot: :program:`aptitude install debootstrap schroot`
-
-Append the following text to the file :file:`/etc/schroot/schroot.conf`
-
-.. code-block:: ini
-
-    [scm]
-    description=Ubuntu Chroot for SCM Hosting
-    type=directory
-    directory=/var/chroots/scm
-    script-config=scm/config
-
-Create a directory :file:`/etc/schroot/scm` and populate it with some files:
-
-.. code-block:: console
-
-    # mkdir /etc/schroot/scm
-    # cat > /etc/schroot/scm/config <<EOF
-    FSTAB="/etc/schroot/scm/fstab"
-    COPYFILES="/etc/schroot/scm/copyfiles"
-    NSSDATABASES="/etc/schroot/scm/nssdatabases"
-    EOF
-    # cat > /etc/schroot/scm/fstab <<EOF
-    /proc		/proc		none    rw,rbind        0       0
-    /sys		/sys		none    rw,rbind        0       0
-    /dev            /dev            none    rw,rbind        0       0
-    /tmp		/tmp		none	rw,bind		0	0
-    EOF
-    # cat > /etc/schroot/scm/copyfiles <<EOF
-    /etc/resolv.conf
-    EOF
-    # cat > /etc/schroot/scm/nssdatabases <<EOF
-    services
-    protocols
-    networks
-    hosts
-    EOF
-
-Create a directory :file:`/var/chroots/scm` and create the bootstrap environment.  (You may substitute a mirror from the  `ubuntu mirror list`_ for archive.ubuntu.com)
-
-.. code-block:: console
-
-    $ sudo mkdir -p /var/chroots/scm
-    $ sudo debootstrap --variant=buildd --arch amd64 --components=main,universe --include=git,mercurial,subversion,openssh-server,slapd,ldap-utils,ldap-auth-client,curl maverick /var/chroots/scm http://archive.ubuntu.com/ubuntu/
-
-Test that the chroot is installed by entering it:
-
-.. code-block:: console
-
-    # schroot -c scm -u root
-    (scm) # logout
-
-Configure OpenLDAP in the Chroot
---------------------------------------------------------------
-
-Copy the ldap-setup script into the chroot environment:
-
-.. code-block:: console
-
-    $ sudo cp Allura/ldap-setup.py Allura/ldap-userconfig.py /var/chroots/scm
-    $ sudo chmod +x /var/chroots/scm/ldap-*.py
-
-Log in to the chroot environment:
-
-.. code-block:: console
-
-    # schroot -c scm -u root
-
-Run the setup script, following the prompts:
-
-.. code-block:: console
-
-    (scm) # python /ldap-setup.py
-
-In particular, you will need to answer the following questions (substitute your custom suffix if you are not using dc=localdomain):
-
-* Should debconf manage LDAP configuration? **yes**
-* LDAP server Uniform Resource Identifier: **ldapi:///**
-* Distinguished name of the search base: **dc=localdomain**
-* LDAP version to use: **1** (version 3)
-* Make local root Database admin: **yes**
-* Does the LDAP database require login? **no**
-* LDAP account for root: **cn=admin,dc=localdomain**
-* LDAP root account password: *empty*
-* Local crypt to use when changing passwords: **2** (crypt)
-* PAM profiles to enable: **2**
-
-Update the chroot ssh configuration
--------------------------------------------------
-
-Update the file :file:`/var/chroot/scm/etc/ssh/sshd_config`, changing the port directive:
-
-.. code-block:: guess
-
-    # Port 22
-    Port 8022
-
-Setup the Custom FUSE Driver
--------------------------------------
-
-Copy the accessfs script into the chroot environment:
-
-.. code-block:: console
-
-    $ sudo cp fuse/accessfs.py /var/chroots/scm
-
-Configure allura to point to the chrooted scm environment:
-
-.. code-block:: console
-
-    $ sudo ln -s /var/chroots/scm /srv/git
-    $ sudo ln -s /var/chroots/scm /srv/hg
-    $ sudo ln -s /var/chroots/scm /srv/svn
-
-Log in to the chroot environment & install packages:
-
-.. code-block:: console
-
-    # schroot -c scm -u root
-    (scm) # apt-get install python-fuse
-
-Create the SCM directories:
-
-.. code-block:: console
-
-    (scm) # mkdir /scm /scm-repo
-
-Mount the FUSE filesystem:
-
-.. code-block:: console
-
-    (scm) # python /accessfs.py /scm-repo -o allow_other -s -o root=/scm
-
-Start the SSH daemon:
-
-.. code-block:: console
-
-    (scm) # /etc/init.d/ssh start
-
-Configure Allura to Use the LDAP Server
-------------------------------------------------
-
-Set the following values in your .ini file:
-
-.. code-block:: ini
-
-    auth.method = ldap
-
-    auth.ldap.server = ldap://localhost
-    auth.ldap.suffix = ou=people,dc=localdomain
-    auth.ldap.admin_dn = cn=admin,dc=localdomain
-    auth.ldap.admin_password = secret
-
-.. _Debootstrap Chroot: https://help.ubuntu.com/community/DebootstrapChroot
-.. _OpenLDAPServer: https://help.ubuntu.com/10.10/serverguide/C/openldap-server.html
-.. _ubuntu mirror list: https://launchpad.net/ubuntu/+archivemirrors
+An advanced alternative for SCM hosting using :ref:`SSH, LDAP, and a FUSE driver <scm_hosting_ssh>` is available.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/829f9675/Allura/docs/scm_host_ssh.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/scm_host_ssh.rst b/Allura/docs/scm_host_ssh.rst
new file mode 100644
index 0000000..fee11f6
--- /dev/null
+++ b/Allura/docs/scm_host_ssh.rst
@@ -0,0 +1,197 @@
+..     Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+
+.. _scm_hosting_ssh:
+
+Configuring Git/SVN/Hg to use Allura auth via LDAP and ssh
+============================================================
+
+The following instructions will use a chroot, a custom FUSE driver, and LDAP.
+Once completed, an ssh-based configuration of Git, SVN, or Hg that has repos in
+the chroot directory will authenticate the users against LDAP and authorize via an Allura API.
+Allura will be configured to authenticate against LDAP as well.
+
+.. note::
+
+    The previous git & svn configuration instructions are not ssh-based, so will not work with this configuration.
+    You'll have to reconfigure git & svn to use ssh:// instead of http or svn protocols.
+
+We assume you are using a version of Ubuntu with
+support for schroot and debootstrap.  We will use a chroot jail to allow users to
+access their repositories via ssh.
+
+Install a chroot environment
+-------------------------------------------
+
+These instructions are based on the documentation in `Debootstrap Chroot`_.  and `OpenLDAPServer`_.
+
+Install debootstrap and schroot: :program:`aptitude install debootstrap schroot`
+
+Append the following text to the file :file:`/etc/schroot/schroot.conf`
+
+.. code-block:: ini
+
+    [scm]
+    description=Ubuntu Chroot for SCM Hosting
+    type=directory
+    directory=/var/chroots/scm
+    script-config=scm/config
+
+Create a directory :file:`/etc/schroot/scm` and populate it with some files:
+
+.. code-block:: console
+
+    # mkdir /etc/schroot/scm
+    # cat > /etc/schroot/scm/config <<EOF
+    FSTAB="/etc/schroot/scm/fstab"
+    COPYFILES="/etc/schroot/scm/copyfiles"
+    NSSDATABASES="/etc/schroot/scm/nssdatabases"
+    EOF
+    # cat > /etc/schroot/scm/fstab <<EOF
+    /proc		/proc		none    rw,rbind        0       0
+    /sys		/sys		none    rw,rbind        0       0
+    /dev            /dev            none    rw,rbind        0       0
+    /tmp		/tmp		none	rw,bind		0	0
+    EOF
+    # cat > /etc/schroot/scm/copyfiles <<EOF
+    /etc/resolv.conf
+    EOF
+    # cat > /etc/schroot/scm/nssdatabases <<EOF
+    services
+    protocols
+    networks
+    hosts
+    EOF
+
+Create a directory :file:`/var/chroots/scm` and create the bootstrap environment.  (You may substitute a mirror from the  `ubuntu mirror list`_ for archive.ubuntu.com)
+
+.. code-block:: console
+
+    $ sudo mkdir -p /var/chroots/scm
+    $ sudo debootstrap --variant=buildd --arch amd64 --components=main,universe --include=git,mercurial,subversion,openssh-server,slapd,ldap-utils,ldap-auth-client,curl maverick /var/chroots/scm http://archive.ubuntu.com/ubuntu/
+
+Test that the chroot is installed by entering it:
+
+.. code-block:: console
+
+    # schroot -c scm -u root
+    (scm) # logout
+
+Configure OpenLDAP in the Chroot
+--------------------------------------------------------------
+
+Copy the ldap-setup script into the chroot environment:
+
+.. code-block:: console
+
+    $ sudo cp Allura/ldap-setup.py Allura/ldap-userconfig.py /var/chroots/scm
+    $ sudo chmod +x /var/chroots/scm/ldap-*.py
+
+Log in to the chroot environment:
+
+.. code-block:: console
+
+    # schroot -c scm -u root
+
+Run the setup script, following the prompts:
+
+.. code-block:: console
+
+    (scm) # python /ldap-setup.py
+
+In particular, you will need to answer the following questions (substitute your custom suffix if you are not using dc=localdomain):
+
+* Should debconf manage LDAP configuration? **yes**
+* LDAP server Uniform Resource Identifier: **ldapi:///**
+* Distinguished name of the search base: **dc=localdomain**
+* LDAP version to use: **1** (version 3)
+* Make local root Database admin: **yes**
+* Does the LDAP database require login? **no**
+* LDAP account for root: **cn=admin,dc=localdomain**
+* LDAP root account password: *empty*
+* Local crypt to use when changing passwords: **2** (crypt)
+* PAM profiles to enable: **2**
+
+Update the chroot ssh configuration
+-------------------------------------------------
+
+Update the file :file:`/var/chroot/scm/etc/ssh/sshd_config`, changing the port directive:
+
+.. code-block:: guess
+
+    # Port 22
+    Port 8022
+
+Setup the Custom FUSE Driver
+-------------------------------------
+
+Copy the accessfs script into the chroot environment:
+
+.. code-block:: console
+
+    $ sudo cp fuse/accessfs.py /var/chroots/scm
+
+Configure allura to point to the chrooted scm environment:
+
+.. code-block:: console
+
+    $ sudo ln -s /var/chroots/scm /srv/git
+    $ sudo ln -s /var/chroots/scm /srv/hg
+    $ sudo ln -s /var/chroots/scm /srv/svn
+
+Log in to the chroot environment & install packages:
+
+.. code-block:: console
+
+    # schroot -c scm -u root
+    (scm) # apt-get install python-fuse
+
+Create the SCM directories:
+
+.. code-block:: console
+
+    (scm) # mkdir /scm /scm-repo
+
+Mount the FUSE filesystem:
+
+.. code-block:: console
+
+    (scm) # python /accessfs.py /scm-repo -o allow_other -s -o root=/scm
+
+Start the SSH daemon:
+
+.. code-block:: console
+
+    (scm) # /etc/init.d/ssh start
+
+Configure Allura to Use the LDAP Server
+------------------------------------------------
+
+Set the following values in your .ini file:
+
+.. code-block:: ini
+
+    auth.method = ldap
+
+    auth.ldap.server = ldap://localhost
+    auth.ldap.suffix = ou=people,dc=localdomain
+    auth.ldap.admin_dn = cn=admin,dc=localdomain
+    auth.ldap.admin_password = secret
+
+.. _Debootstrap Chroot: https://help.ubuntu.com/community/DebootstrapChroot
+.. _OpenLDAPServer: https://help.ubuntu.com/10.10/serverguide/C/openldap-server.html
+.. _ubuntu mirror list: https://launchpad.net/ubuntu/+archivemirrors


[06/14] git commit: [#7160] ticket:546 Allow IP addresses in URLs

Posted by jo...@apache.org.
[#7160] ticket:546 Allow IP addresses in URLs


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

Branch: refs/heads/cj/7134
Commit: fd618a7e4539fad714612506629a8c38d2f30d1b
Parents: efc7937
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Feb 27 12:40:52 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Mar 27 16:12:14 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/validators.py                | 5 +++++
 ForgeImporters/forgeimporters/trac/__init__.py | 4 +++-
 ForgeSVN/forgesvn/widgets.py                   | 8 +++++---
 3 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/fd618a7e/Allura/allura/lib/validators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index f23a951..964160d 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -25,6 +25,11 @@ from . import helpers as h
 from datetime import datetime
 
 
+class URL(fev.URL):
+    # allows use of IP address instead of domain name
+    require_tld = False
+
+
 class Ming(fev.FancyValidator):
 
     def __init__(self, cls, **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/fd618a7e/ForgeImporters/forgeimporters/trac/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/__init__.py b/ForgeImporters/forgeimporters/trac/__init__.py
index a1fbceb..12e677a 100644
--- a/ForgeImporters/forgeimporters/trac/__init__.py
+++ b/ForgeImporters/forgeimporters/trac/__init__.py
@@ -18,8 +18,10 @@
 from formencode import validators as fev
 import requests
 
+from allura.lib import validators
 
-class TracURLValidator(fev.URL):
+
+class TracURLValidator(validators.URL):
     not_empty = True
     messages = {
         'unavailable': 'This project is unavailable for import'

http://git-wip-us.apache.org/repos/asf/allura/blob/fd618a7e/ForgeSVN/forgesvn/widgets.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/widgets.py b/ForgeSVN/forgesvn/widgets.py
index d138cfd..c0c880f 100644
--- a/ForgeSVN/forgesvn/widgets.py
+++ b/ForgeSVN/forgesvn/widgets.py
@@ -17,20 +17,22 @@
 
 import re
 
-from formencode import validators as fev
-
 import ew as ew_core
 import ew.jinja2_ew as ew
 
+from allura.lib import validators
 from allura.lib.widgets.forms import ForgeForm
 
 
-class ValidateSvnUrl(fev.URL):
+class ValidateSvnUrl(validators.URL):
     url_re = re.compile(r'''
         ^(http|https|svn)://
         (?:[%:\w]*@)?                              # authenticator
+        (?:                                        # ip or domain
+        (?P<ip>(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|
         (?P<domain>[a-z0-9][a-z0-9\-]{,62}\.)*     # subdomain
         (?P<tld>[a-z]{2,63}|xn--[a-z0-9\-]{2,59})  # top level domain
+        )
         (?::[0-9]{1,5})?                           # port
         # files/delims/etc
         (?P<path>/[a-z0-9\-\._~:/\?#\[\]@!%\$&\'\(\)\*\+,;=]*)?


[10/14] git commit: [#7199] ticket:555 fixed help, and prefix for sitemap script

Posted by jo...@apache.org.
[#7199] ticket:555 fixed help, and prefix for  sitemap script


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

Branch: refs/heads/cj/7134
Commit: b82eb5ee3fe8392a2f5b8f8f0cbd8b71e57408be
Parents: 0c5a5fd
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Wed Mar 12 01:06:05 2014 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Mar 27 16:15:58 2014 +0000

----------------------------------------------------------------------
 scripts/create-allura-sitemap.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b82eb5ee/scripts/create-allura-sitemap.py
----------------------------------------------------------------------
diff --git a/scripts/create-allura-sitemap.py b/scripts/create-allura-sitemap.py
index 60deeb4..f39b2a6 100644
--- a/scripts/create-allura-sitemap.py
+++ b/scripts/create-allura-sitemap.py
@@ -102,7 +102,8 @@ def main(options):
 
     nbhd_id = []
     if options.neighborhood:
-        nbhd_id = [nbhd._id for nbhd in M.Neighborhood.query.find({'url_prefix': {'$in': options.neighborhood}})]
+        prefix = ['/%s/' % n for n in options.neighborhood]
+        nbhd_id = [nbhd._id for nbhd in M.Neighborhood.query.find({'url_prefix': {'$in': prefix}})]
 
     # write sitemap files, MAX_SITEMAP_URLS per file
     for chunk in utils.chunked_find(M.Project, {'deleted': False, 'neighborhood_id': {'$nin': nbhd_id}}):
@@ -154,11 +155,11 @@ def parse_options():
                         dest='output_dir',
                         default='/tmp/allura_sitemap',
                         help='Output directory (absolute path).'
-                              '[default: %default]')
+                              '[default: %(default)s]')
     parser.add_argument('-u', '--urls-per-file', dest='urls_per_file',
                          default=10000, type=int,
                          help='Number of URLs per sitemap file. '
-                         '[default: %default, max: ' +
+                         '[default: %(default)s, max: ' +
                          str(MAX_SITEMAP_URLS) + ']',
                          action=Validate)
     parser.add_argument('-n', '--neighborhood', dest='neighborhood',


[12/14] git commit: [#7134] Added option to allow overriding repo clone URL

Posted by jo...@apache.org.
[#7134] Added option to allow overriding repo clone URL

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/7134
Commit: d59c3dcbff4681049980ceb700b1540482003fc2
Parents: b82eb5e
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Mar 20 21:27:05 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Mar 27 17:42:35 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/repository.py                 | 19 ++++++++++--
 Allura/allura/model/repository.py               |  7 +++--
 Allura/allura/templates/repo/admin_options.html | 32 ++++++++++++++++++++
 ForgeGit/forgegit/model/git_repo.py             |  5 ++-
 .../forgegit/tests/model/test_repository.py     | 12 ++++++++
 ForgeGit/forgegit/tests/test_git_app.py         |  2 +-
 .../forgesvn/tests/model/test_repository.py     |  4 +++
 ForgeSVN/forgesvn/tests/test_svn_app.py         |  2 +-
 8 files changed, 75 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d59c3dcb/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 6e073d9..4e956bf 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -20,7 +20,7 @@ from urllib import quote
 
 from pylons import tmpl_context as c, app_globals as g
 from pylons import request
-from tg import expose, redirect
+from tg import expose, redirect, flash
 from tg.decorators import with_trailing_slash, without_trailing_slash
 from bson import ObjectId
 
@@ -54,7 +54,8 @@ class RepositoryApp(Application):
     config_options = Application.config_options + [
         ConfigOption('cloned_from_project_id', ObjectId, None),
         ConfigOption('cloned_from_repo_id', ObjectId, None),
-        ConfigOption('init_from_url', str, None)
+        ConfigOption('init_from_url', str, None),
+        ConfigOption('clone_url', str, None)
     ]
     tool_label = 'Repository'
     default_mount_label = 'Code'
@@ -101,7 +102,6 @@ class RepositoryApp(Application):
                                   '/refresh',
                                   ))
         links += super(RepositoryApp, self).admin_menu()
-        [links.remove(l) for l in links[:] if l.label == 'Options']
         return links
 
     @h.exceptionless([], log)
@@ -246,3 +246,16 @@ class RepoAdminController(DefaultAdminController):
         else:
             return dict(app=self.app,
                         default_branch_name=self.app.default_branch_name)
+
+    @without_trailing_slash
+    @expose('jinja:allura:templates/repo/admin_options.html')
+    def options(self):
+        return dict(app=self.app)
+
+    @without_trailing_slash
+    @expose()
+    @require_post()
+    def set_options(self, clone_url=None, **kw):
+        self.app.config.options.clone_url = clone_url or None
+        flash('Repo options updated')
+        redirect(c.project.url() + 'admin/tools')

http://git-wip-us.apache.org/repos/asf/allura/blob/d59c3dcb/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 2c08017..12661a9 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -555,8 +555,11 @@ class Repository(Artifact, ActivityObject):
         '''Return a URL string suitable for copy/paste that describes _this_ repo,
            e.g., for use in a clone/checkout command
         '''
-        tpl = string.Template(
-            tg.config.get('scm.host.%s.%s' % (category, self.tool)))
+        if self.app.config.options.clone_url:
+            tpl = string.Template(self.app.config.options.clone_url)
+        else:
+            tpl = string.Template(
+                tg.config.get('scm.host.%s.%s' % (category, self.tool)))
         return tpl.substitute(dict(username=username, path=self.url_path + self.name))
 
     def clone_command(self, category, username=''):

http://git-wip-us.apache.org/repos/asf/allura/blob/d59c3dcb/Allura/allura/templates/repo/admin_options.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/admin_options.html b/Allura/allura/templates/repo/admin_options.html
new file mode 100644
index 0000000..2b2c0b7
--- /dev/null
+++ b/Allura/allura/templates/repo/admin_options.html
@@ -0,0 +1,32 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+<!DOCTYPE html>
+<form action="{{c.project.url()}}admin/{{app.config.options.mount_point}}/set_options" method="post">
+    <label class="grid-4">Clone / checkout URL:</label>
+    <div class="grid-9">
+        <input type="text" name="clone_url" id="clone_url" value="{{app.config.options.clone_url or ''}}"/>
+    </div>
+    <div class="grid-13">&nbsp;</div>
+    <hr>
+    <div class="grid-13">&nbsp;</div>
+    <div class="grid-13">
+	<input type="submit" value="Save"/>
+        <a href="#" class="close">Cancel</a>
+    </div>
+</form>

http://git-wip-us.apache.org/repos/asf/allura/blob/d59c3dcb/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 8b9d1f8..1cb771b 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -71,7 +71,10 @@ class Repository(M.Repository):
         return super(Repository, self).suggested_clone_dest_path()[:-4]
 
     def clone_url(self, category, username=''):
-        return super(Repository, self).clone_url(category, username)[:-4]
+        clone_url = super(Repository, self).clone_url(category, username)
+        if clone_url.endswith('.git'):
+            clone_url = clone_url[:-4]
+        return clone_url
 
     def merge_command(self, merge_request):
         '''Return the command to merge a given commit to a given target branch'''

http://git-wip-us.apache.org/repos/asf/allura/blob/d59c3dcb/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 215ba0b..106c63e 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -470,6 +470,18 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             ThreadLocalORMSession.flush_all()
             assert repo2.is_empty()
 
+    def test_clone_url(self):
+        assert_equal(
+            self.repo.clone_url('rw', 'nobody'),
+            'ssh://nobody@localhost:8022/scm-repo/test/testgit')
+        assert_equal(
+            self.repo.clone_url('https', 'nobody'),
+            'https://nobody@localhost:8022/scm-repo/test/testgit')
+        with h.push_config(self.repo.app.config.options, clone_url='https://$username@foo.com/'):
+            assert_equal(
+                self.repo.clone_url('https', 'user'),
+                'https://user@foo.com/')
+
 
 class TestGitImplementation(unittest.TestCase):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/d59c3dcb/ForgeGit/forgegit/tests/test_git_app.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/test_git_app.py b/ForgeGit/forgegit/tests/test_git_app.py
index 0b59396..44ce991 100644
--- a/ForgeGit/forgegit/tests/test_git_app.py
+++ b/ForgeGit/forgegit/tests/test_git_app.py
@@ -40,7 +40,7 @@ class TestGitApp(unittest.TestCase):
         ThreadLocalORMSession.close_all()
 
     def test_admin_menu(self):
-        assert_equals(len(c.app.admin_menu()), 5)
+        assert_equals(len(c.app.admin_menu()), 6)
 
     def test_default_branch(self):
         assert c.app.default_branch_name == 'master'

http://git-wip-us.apache.org/repos/asf/allura/blob/d59c3dcb/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 7dc2177..2fb7207 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -784,6 +784,10 @@ class TestRepo(_TestWithRepo):
             self.repo.clone_url('https', 'nobody')
             == 'https://nobody@localhost:8022/scm-repo/p/test/test1/'),\
             self.repo.clone_url('https', 'nobody')
+        with h.push_config(self.repo.app.config.options, clone_url='https://$username@foo.com/'):
+            assert_equal(
+                self.repo.clone_url('https', 'user'),
+                'https://user@foo.com/')
 
     def test_merge_request(self):
         M.MergeRequest.upsert(app_config_id=c.app.config._id, status='open')

http://git-wip-us.apache.org/repos/asf/allura/blob/d59c3dcb/ForgeSVN/forgesvn/tests/test_svn_app.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/test_svn_app.py b/ForgeSVN/forgesvn/tests/test_svn_app.py
index 7fd8545..6ea576a 100644
--- a/ForgeSVN/forgesvn/tests/test_svn_app.py
+++ b/ForgeSVN/forgesvn/tests/test_svn_app.py
@@ -40,7 +40,7 @@ class TestSVNApp(unittest.TestCase):
         ThreadLocalORMSession.close_all()
 
     def test_admin_menu(self):
-        assert_equals(len(c.app.admin_menu()), 6)
+        assert_equals(len(c.app.admin_menu()), 7)
         assert_equals(c.app.admin_menu()[0].label, 'Checkout URL')
 
     def test_uninstall(self):


[09/14] git commit: [#7199] ticket:547 filter deleted projects in create-allura-sitemap.py

Posted by jo...@apache.org.
[#7199] ticket:547 filter deleted projects in create-allura-sitemap.py


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

Branch: refs/heads/cj/7134
Commit: a5a48ba265c0c259af6c7cf94868ce5283a979b4
Parents: ac7bf98
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Fri Feb 28 13:12:27 2014 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Mar 27 16:15:58 2014 +0000

----------------------------------------------------------------------
 scripts/create-allura-sitemap.py | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/a5a48ba2/scripts/create-allura-sitemap.py
----------------------------------------------------------------------
diff --git a/scripts/create-allura-sitemap.py b/scripts/create-allura-sitemap.py
index e3f08bc..50cfba3 100644
--- a/scripts/create-allura-sitemap.py
+++ b/scripts/create-allura-sitemap.py
@@ -61,8 +61,8 @@ SITEMAP_TEMPLATE = """\
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
     {% for loc in locs -%}
     <url>
-        <loc>{{ loc }}</loc>
-        <lastmod>{{ now }}</lastmod>
+        <loc>{{ loc.url }}</loc>
+        <lastmod>{{ loc.date }}</lastmod>
         <changefreq>daily</changefreq>
     </url>
     {% endfor %}
@@ -99,13 +99,21 @@ def main(options, args):
     creds = security.Credentials.get()
     locs = []
     file_count = 0
+
+    nbhd_id = []
+    if options.neighborhood:
+        nbhd_id = [nbhd._id for nbhd in M.Neighborhood.query.find({'name': {'$in': options.neighborhood}})]
+
     # write sitemap files, MAX_SITEMAP_URLS per file
-    for chunk in utils.chunked_find(M.Project):
+    for chunk in utils.chunked_find(M.Project, {'deleted': False, 'neighborhood_id': {'$nin': nbhd_id}}):
         for p in chunk:
             c.project = p
             try:
-                locs += [BASE_URL + s.url if s.url[0] == '/' else s.url
-                         for s in p.sitemap(excluded_tools=['git', 'hg', 'svn'])]
+                for s in p.sitemap(excluded_tools=['git', 'hg', 'svn']):
+                    url = BASE_URL + s.url if s.url[0] == '/' else s.url
+                    locs.append({'url': url,
+                                 'date': p.last_updated.strftime("%Y-%m-%d")})
+
             except Exception, e:
                 print "Error creating sitemap for project '%s': %s" %\
                     (p.shortname, e)
@@ -132,8 +140,20 @@ def main(options, args):
         with open(os.path.join(output_path, 'sitemap.xml'), 'w') as f:
             f.write(sitemap_index_content)
 
+def callback(option, opt_str, value, parser):
+    args=[]
+    for arg in parser.rargs:
+        if arg[0] != "-":
+            args.append(arg)
+        else:
+            del parser.rargs[:len(args)]
+            break
+    if getattr(parser.values, option.dest):
+        args.extend(getattr(parser.values, option.dest))
+    setattr(parser.values, option.dest, args)
 
 def parse_options():
+
     def validate(option, opt_str, value, parser):
         parser.values.urls_per_file = min(value, MAX_SITEMAP_URLS)
 
@@ -151,6 +171,9 @@ def parse_options():
                          '[default: %default, max: ' +
                          str(MAX_SITEMAP_URLS) + ']',
                          action='callback', callback=validate)
+    optparser.add_option('-n', '--neighborhood', dest='neighborhood', action="callback", callback=callback,
+                         help="URL prefix of excluded neighborhood(s)",
+                         default=None, nargs='*')
     options, args = optparser.parse_args()
     return options, args
 


[14/14] git commit: [#7134] Added validation for external checkout URLs

Posted by jo...@apache.org.
[#7134] Added validation for external checkout URLs

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/7134
Commit: 2fe81357b581ba60ad94f5eb05091b44e46f4fff
Parents: 4c30636
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Mar 27 19:28:06 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Mar 27 19:28:06 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/repository.py                 | 13 +++++++---
 Allura/allura/lib/validators.py                 | 21 +++++++++++++++
 Allura/allura/tests/test_validators.py          | 19 ++++++++++++++
 ForgeSVN/forgesvn/svn_main.py                   | 27 ++++++++++++--------
 .../forgesvn/templates/svn/checkout_url.html    |  1 +
 5 files changed, 68 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/2fe81357/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 0dda832..f155f7f 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -20,7 +20,7 @@ from urllib import quote
 
 from pylons import tmpl_context as c, app_globals as g
 from pylons import request
-from tg import expose, redirect, flash
+from tg import expose, redirect, flash, validate
 from tg.decorators import with_trailing_slash, without_trailing_slash
 from bson import ObjectId
 
@@ -33,6 +33,7 @@ from allura import model as M
 from allura.lib import security
 from allura.lib.decorators import require_post
 from allura.lib.security import has_access
+from allura.lib import validators as v
 from allura.app import Application, SitemapEntry, DefaultAdminController, ConfigOption
 
 log = logging.getLogger(__name__)
@@ -266,7 +267,13 @@ class RepoAdminController(DefaultAdminController):
     @without_trailing_slash
     @expose()
     @require_post()
+    @validate({'external_checkout_url': v.NonHttpUrl})
     def set_checkout_url(self, **post_data):
-        self.app.config.options.external_checkout_url = post_data.get('external_checkout_url') or None
-        flash('Repo options updated')
+        external_checkout_url = (post_data.get('external_checkout_url') or '').strip()
+        if 'external_checkout_url' not in c.form_errors:
+            if self.app.config.options.external_checkout_url != external_checkout_url:
+                self.app.config.options.external_checkout_url = external_checkout_url
+                flash("External checkout URL successfully changed")
+        else:
+            flash("Invalid external checkout URL: %s" % c.form_errors['external_checkout_url'], "error")
         redirect(c.project.url() + 'admin/tools')

http://git-wip-us.apache.org/repos/asf/allura/blob/2fe81357/Allura/allura/lib/validators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index bfb87a8..805bf31 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -44,6 +44,27 @@ class URL(fev.URL):
     ''', re.I | re.VERBOSE)
 
 
+class NonHttpUrl(URL):
+    messages = {
+        'noScheme': 'You must start your URL with a scheme',
+    }
+    add_http = False
+    scheme_re = re.compile(r'^[a-z][a-z0-9.+-]*:', re.I)
+    url_re = re.compile(r'''
+        ^([a-z][a-z0-9.+-]*)://
+        (?:[%:\w]*@)?                              # authenticator
+        (?:                                        # ip or domain
+        (?P<ip>(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|
+        (?P<domain>[a-z0-9][a-z0-9\-]{,62}\.)*     # subdomain
+        (?P<tld>[a-z]{2,63}|xn--[a-z0-9\-]{2,59})  # top level domain
+        )
+        (?::[0-9]{1,5})?                           # port
+        # files/delims/etc
+        (?P<path>/[a-z0-9\-\._~:/\?#\[\]@!%\$&\'\(\)\*\+,;=]*)?
+        $
+    ''', re.I | re.VERBOSE)
+
+
 class Ming(fev.FancyValidator):
 
     def __init__(self, cls, **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/2fe81357/Allura/allura/tests/test_validators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_validators.py b/Allura/allura/tests/test_validators.py
index eacd286..e0b4f2c 100644
--- a/Allura/allura/tests/test_validators.py
+++ b/Allura/allura/tests/test_validators.py
@@ -237,6 +237,7 @@ class TestPathValidator(unittest.TestCase):
 
 class TestUrlValidator(unittest.TestCase):
     val = v.URL
+
     def test_valid(self):
         self.assertEqual('http://192.168.0.1', self.val.to_python('192.168.0.1'))
         self.assertEqual('http://url', self.val.to_python('url'))
@@ -250,3 +251,21 @@ class TestUrlValidator(unittest.TestCase):
         with self.assertRaises(fe.Invalid) as cm:
             self.val.to_python('u"rl')
         self.assertEqual(str(cm.exception), 'That is not a valid URL')
+
+
+class TestNonHttpUrlValidator(unittest.TestCase):
+    val = v.NonHttpUrl
+
+    def test_valid(self):
+        self.assertEqual('svn://192.168.0.1', self.val.to_python('svn://192.168.0.1'))
+        self.assertEqual('ssh+git://url', self.val.to_python('ssh+git://url'))
+
+    def test_invalid(self):
+        with self.assertRaises(fe.Invalid) as cm:
+            self.val.to_python('http://u"rl')
+        self.assertEqual(str(cm.exception), 'That is not a valid URL')
+
+    def test_no_scheme(self):
+        with self.assertRaises(fe.Invalid) as cm:
+            self.val.to_python('url')
+        self.assertEqual(str(cm.exception), 'You must start your URL with a scheme')

http://git-wip-us.apache.org/repos/asf/allura/blob/2fe81357/ForgeSVN/forgesvn/svn_main.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index e1cf7f7..7d7a2f5 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -35,6 +35,7 @@ from allura.lib.decorators import require_post
 from allura.lib.repository import RepositoryApp, RepoAdminController
 from allura.app import SitemapEntry, ConfigOption
 from allura.lib import helpers as h
+from allura.lib import validators as v
 from allura import model as M
 
 # Local imports
@@ -121,20 +122,26 @@ class SVNRepoAdminController(RepoAdminController):
     @without_trailing_slash
     @expose()
     @require_post()
+    @validate({'external_checkout_url': v.NonHttpUrl})
     def set_checkout_url(self, **post_data):
-        checkout_url = post_data.get('checkout_url')
-        external_checkout_url = post_data.get('external_checkout_url')
-        if checkout_url and svn_path_exists("file://%s%s/%s" %
-                                            (self.app.repo.fs_path,
-                                             self.app.repo.name,
-                                             checkout_url)):
-            self.app.config.options['checkout_url'] = checkout_url
-            flash("Checkout URL successfully changed")
+        checkout_url = (post_data.get('checkout_url') or '').strip()
+        external_checkout_url = (post_data.get('external_checkout_url') or '').strip()
+        if not checkout_url or svn_path_exists("file://%s%s/%s" %
+                                               (self.app.repo.fs_path,
+                                                self.app.repo.name,
+                                                checkout_url)):
+            if self.app.config.options.checkout_url != checkout_url:
+                self.app.config.options.checkout_url = checkout_url
+                flash("Checkout URL successfully changed")
         else:
             flash("%s is not a valid path for this repository" %
                   checkout_url, "error")
-        self.app.config.options.external_checkout_url = external_checkout_url
-        flash("External checkout URL successfully changed")
+        if 'external_checkout_url' not in c.form_errors:
+            if self.app.config.options.external_checkout_url != external_checkout_url:
+                self.app.config.options.external_checkout_url = external_checkout_url
+                flash("External checkout URL successfully changed")
+        else:
+            flash("Invalid external checkout URL: %s" % c.form_errors['external_checkout_url'], "error")
 
 
 class SVNImportController(BaseController):

http://git-wip-us.apache.org/repos/asf/allura/blob/2fe81357/ForgeSVN/forgesvn/templates/svn/checkout_url.html
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/templates/svn/checkout_url.html b/ForgeSVN/forgesvn/templates/svn/checkout_url.html
index 9931d0c..3790b46 100644
--- a/ForgeSVN/forgesvn/templates/svn/checkout_url.html
+++ b/ForgeSVN/forgesvn/templates/svn/checkout_url.html
@@ -48,6 +48,7 @@
   <div class="grid-13">&nbsp;</div>
   <div class="grid-13">
     <input type="button" onclick="save_checkout_url()" value="Save">
+    <a href="#" class="close">Cancel</a>
   </div>
   {% endif %}
 </form>


[07/14] git commit: [#7160] ticket:546 Bump FormEncode version for improved URL validator

Posted by jo...@apache.org.
[#7160] ticket:546 Bump FormEncode version for improved URL validator


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

Branch: refs/heads/cj/7134
Commit: efc7937498479413c5bb33f5b90be1f5a9f82745
Parents: cb78d45
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Feb 27 11:51:52 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Mar 27 16:12:14 2014 +0000

----------------------------------------------------------------------
 requirements-common.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/efc79374/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index 7d8e70e..a0efd00 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -13,7 +13,7 @@ docutils==0.9
 EasyWidgets==0.2dev-20130716
 faulthandler==2.1
 feedparser==5.0.1
-FormEncode==1.2.4
+FormEncode==1.2.6
 # dep of Creoleparser
 Genshi==0.6
 # dep of oauth2


[04/14] git commit: [#7160] ticket:557 add unit test for URL validator

Posted by jo...@apache.org.
[#7160] ticket:557 add unit test for URL validator


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

Branch: refs/heads/cj/7134
Commit: ac7bf98224e9ae16ed418964cba00bfb95b723a4
Parents: ee90c93
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Tue Mar 11 19:19:25 2014 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Mar 27 16:12:14 2014 +0000

----------------------------------------------------------------------
 Allura/allura/tests/test_validators.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ac7bf982/Allura/allura/tests/test_validators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_validators.py b/Allura/allura/tests/test_validators.py
index 2e6bb02..eacd286 100644
--- a/Allura/allura/tests/test_validators.py
+++ b/Allura/allura/tests/test_validators.py
@@ -233,3 +233,20 @@ class TestPathValidator(unittest.TestCase):
 
     def test_no_input(self):
         self.assertEqual({}, self.val.to_python(''))
+
+
+class TestUrlValidator(unittest.TestCase):
+    val = v.URL
+    def test_valid(self):
+        self.assertEqual('http://192.168.0.1', self.val.to_python('192.168.0.1'))
+        self.assertEqual('http://url', self.val.to_python('url'))
+
+    def test_invalid_ip(self):
+        with self.assertRaises(fe.Invalid) as cm:
+            self.val.to_python('192.168.0')
+        self.assertEqual(str(cm.exception), 'That is not a valid URL')
+
+    def test_invalid_url(self):
+        with self.assertRaises(fe.Invalid) as cm:
+            self.val.to_python('u"rl')
+        self.assertEqual(str(cm.exception), 'That is not a valid URL')


[02/14] git commit: [#7287] Added docs for using ApacheAccessHandler.py for SCM auth

Posted by jo...@apache.org.
[#7287] Added docs for using ApacheAccessHandler.py for SCM auth

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/7134
Commit: f39683572e903f152d0bac28a42d4a34fa9f3699
Parents: 8e88e3a
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue Mar 25 17:14:53 2014 +0000
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Wed Mar 26 15:51:11 2014 -0400

----------------------------------------------------------------------
 Allura/docs/scm_host.rst | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/f3968357/Allura/docs/scm_host.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/scm_host.rst b/Allura/docs/scm_host.rst
index 0e11e8a..82bb6a7 100644
--- a/Allura/docs/scm_host.rst
+++ b/Allura/docs/scm_host.rst
@@ -170,6 +170,47 @@ Then Apache SVN will serve repositories for all Allura projects and subprojects.
 
 
 
+Configuring Git/SVN/Hg to use Allura auth via mod_python and ApacheAccessHandler.py
+===================================================================================
+
+This is the easiest way to integrate authentication for SCM access with Allura.  It uses
+mod_python and the handler in `scripts/ApacheAccessHandler.py` to query Allura directly
+for auth and permissions before allowing access to the SCM.  Of course, this only works
+for SCM access over HTTP(S).
+
+First, you need to ensure that mod_python is installed:
+
+.. code-block:: console
+
+    sudo aptitude install libapache2-mod-python
+
+Then, in the VirtualHost section where you proxy SCM requests to git, SVN, or Hg, add the
+access handler, e.g.:
+
+.. code-block:: apache
+
+    <LocationMatch "^/(git|svn|hg)/">
+        AddHandler mod_python .py
+        PythonAccessHandler /var/local/allura/scripts/ApacheAccessHandler.py
+        AuthType Basic
+        AuthName "SCM Access"
+        AuthBasicAuthoritative off
+        PythonOption ALLURA_VIRTUALENV /var/local/env-allura
+        PythonOption ALLURA_AUTH_URL https://127.0.0.1/auth/do_login
+        PythonOption ALLURA_PERM_URL https://127.0.0.1/auth/repo_permissions
+    </LocationMatch>
+
+If the SCM is hosted seperately from Allura, update the URLs as appropriate.
+Even if using localhost, it is recommended to use HTTPS, since the username
+and password will be otherwise be sent in the clear to Allura.
+
+.. warning::
+
+    Currently, for Mercurial, the handler doesn't correctly distinguish read
+    and write requests and thus requires WRITE permission for every request.
+
+
+
 Configuring Git/SVN/Hg to use Allura auth via LDAP and ssh
 ============================================================
 


[13/14] git commit: [#7134] Refactoring of external checkout URL option

Posted by jo...@apache.org.
[#7134] Refactoring of external checkout URL option

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/7134
Commit: 4c30636512697fad207289c05183368cf0723874
Parents: d59c3dc
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Mar 26 21:47:56 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Mar 27 17:42:35 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/repository.py                 | 33 ++++++++++++------
 Allura/allura/model/repository.py               |  4 +--
 Allura/allura/templates/repo/admin_options.html | 32 -----------------
 Allura/allura/templates/repo/checkout_url.html  | 36 ++++++++++++++++++++
 .../forgegit/tests/model/test_repository.py     |  2 +-
 ForgeSVN/forgesvn/svn_main.py                   | 31 +++++++----------
 .../forgesvn/templates/svn/checkout_url.html    | 19 +++++++++--
 .../forgesvn/tests/model/test_repository.py     |  2 +-
 ForgeSVN/forgesvn/tests/test_svn_app.py         |  2 +-
 9 files changed, 92 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 4e956bf..0dda832 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -55,7 +55,7 @@ class RepositoryApp(Application):
         ConfigOption('cloned_from_project_id', ObjectId, None),
         ConfigOption('cloned_from_repo_id', ObjectId, None),
         ConfigOption('init_from_url', str, None),
-        ConfigOption('clone_url', str, None)
+        ConfigOption('external_checkout_url', str, None)
     ]
     tool_label = 'Repository'
     default_mount_label = 'Code'
@@ -95,13 +95,24 @@ class RepositoryApp(Application):
         admin_url = c.project.url() + 'admin/' + \
             self.config.options.mount_point + '/'
         links = [
-            SitemapEntry('Viewable Files', admin_url + 'extensions', className='admin_modal')]
-        links.append(SitemapEntry('Refresh Repository',
-                                  c.project.url() +
-                                  self.config.options.mount_point +
-                                  '/refresh',
-                                  ))
+            SitemapEntry(
+                'Checkout URL',
+                c.project.url() + 'admin/' +
+                self.config.options.mount_point +
+                '/' + 'checkout_url',
+                className='admin_modal'),
+            SitemapEntry(
+                'Viewable Files',
+                admin_url + 'extensions',
+                className='admin_modal'),
+            SitemapEntry(
+                'Refresh Repository',
+                c.project.url() +
+                self.config.options.mount_point +
+                '/refresh'),
+        ]
         links += super(RepositoryApp, self).admin_menu()
+        [links.remove(l) for l in links[:] if l.label == 'Options']
         return links
 
     @h.exceptionless([], log)
@@ -248,14 +259,14 @@ class RepoAdminController(DefaultAdminController):
                         default_branch_name=self.app.default_branch_name)
 
     @without_trailing_slash
-    @expose('jinja:allura:templates/repo/admin_options.html')
-    def options(self):
+    @expose('jinja:allura:templates/repo/checkout_url.html')
+    def checkout_url(self):
         return dict(app=self.app)
 
     @without_trailing_slash
     @expose()
     @require_post()
-    def set_options(self, clone_url=None, **kw):
-        self.app.config.options.clone_url = clone_url or None
+    def set_checkout_url(self, **post_data):
+        self.app.config.options.external_checkout_url = post_data.get('external_checkout_url') or None
         flash('Repo options updated')
         redirect(c.project.url() + 'admin/tools')

http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 12661a9..c08e546 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -555,8 +555,8 @@ class Repository(Artifact, ActivityObject):
         '''Return a URL string suitable for copy/paste that describes _this_ repo,
            e.g., for use in a clone/checkout command
         '''
-        if self.app.config.options.clone_url:
-            tpl = string.Template(self.app.config.options.clone_url)
+        if self.app.config.options.get('external_checkout_url', None):
+            tpl = string.Template(self.app.config.options.external_checkout_url)
         else:
             tpl = string.Template(
                 tg.config.get('scm.host.%s.%s' % (category, self.tool)))

http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/Allura/allura/templates/repo/admin_options.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/admin_options.html b/Allura/allura/templates/repo/admin_options.html
deleted file mode 100644
index 2b2c0b7..0000000
--- a/Allura/allura/templates/repo/admin_options.html
+++ /dev/null
@@ -1,32 +0,0 @@
-{#-
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (the
-       "License"); you may not use this file except in compliance
-       with the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
--#}
-<!DOCTYPE html>
-<form action="{{c.project.url()}}admin/{{app.config.options.mount_point}}/set_options" method="post">
-    <label class="grid-4">Clone / checkout URL:</label>
-    <div class="grid-9">
-        <input type="text" name="clone_url" id="clone_url" value="{{app.config.options.clone_url or ''}}"/>
-    </div>
-    <div class="grid-13">&nbsp;</div>
-    <hr>
-    <div class="grid-13">&nbsp;</div>
-    <div class="grid-13">
-	<input type="submit" value="Save"/>
-        <a href="#" class="close">Cancel</a>
-    </div>
-</form>

http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/Allura/allura/templates/repo/checkout_url.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/checkout_url.html b/Allura/allura/templates/repo/checkout_url.html
new file mode 100644
index 0000000..8eaafd9
--- /dev/null
+++ b/Allura/allura/templates/repo/checkout_url.html
@@ -0,0 +1,36 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+<!DOCTYPE html>
+<form action="{{c.project.url()}}admin/{{app.config.options.mount_point}}/set_checkout_url" method="post">
+    <label class="grid-4">External checkout URL:</label>
+    <div class="grid-9">
+        <input type="text" name="external_checkout_url" id="external_checkout_url" value="{{app.config.options.external_checkout_url or ''}}"/>
+    </div>
+    <div class="grid-13">
+        Override the checkout URL with an external one.  This is useful if this repository is a mirror
+        of another, canonical repository.
+    </div>
+    <div class="grid-13">&nbsp;</div>
+    <hr>
+    <div class="grid-13">&nbsp;</div>
+    <div class="grid-13">
+        <input type="submit" value="Save"/>
+        <a href="#" class="close">Cancel</a>
+    </div>
+</form>

http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 106c63e..ff4ee48 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -477,7 +477,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         assert_equal(
             self.repo.clone_url('https', 'nobody'),
             'https://nobody@localhost:8022/scm-repo/test/testgit')
-        with h.push_config(self.repo.app.config.options, clone_url='https://$username@foo.com/'):
+        with h.push_config(self.repo.app.config.options, external_checkout_url='https://$username@foo.com/'):
             assert_equal(
                 self.repo.clone_url('https', 'user'),
                 'https://user@foo.com/')

http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/ForgeSVN/forgesvn/svn_main.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index 0bce7f6..e1cf7f7 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -100,17 +100,10 @@ class ForgeSVNApp(RepositoryApp):
             allura.tasks.repo_tasks.init.post()
 
     def admin_menu(self):
-        links = []
-        links.append(SitemapEntry(
-            'Checkout URL',
-            c.project.url() + 'admin/' +
-            self.config.options.mount_point +
-            '/' + 'checkout_url',
-            className='admin_modal'))
-        links.append(SitemapEntry(
+        links = super(ForgeSVNApp, self).admin_menu()
+        links.insert(1, SitemapEntry(
             'Import Repo',
             c.project.url() + 'admin/' + self.config.options.mount_point + '/' + 'importer/'))
-        links += super(ForgeSVNApp, self).admin_menu()
         return links
 
 
@@ -123,23 +116,25 @@ class SVNRepoAdminController(RepoAdminController):
     @without_trailing_slash
     @expose('jinja:forgesvn:templates/svn/checkout_url.html')
     def checkout_url(self, **kw):
-        return dict(app=self.app,
-                    allow_config=True,
-                    checkout_url=self.app.config.options.get('checkout_url'))
+        return dict(app=self.app, allow_config=True)
 
     @without_trailing_slash
     @expose()
     @require_post()
     def set_checkout_url(self, **post_data):
-        if svn_path_exists("file://%s%s/%s" %
-                          (self.app.repo.fs_path,
-                           self.app.repo.name,
-                           post_data['checkout_url'])):
-            self.app.config.options['checkout_url'] = post_data['checkout_url']
+        checkout_url = post_data.get('checkout_url')
+        external_checkout_url = post_data.get('external_checkout_url')
+        if checkout_url and svn_path_exists("file://%s%s/%s" %
+                                            (self.app.repo.fs_path,
+                                             self.app.repo.name,
+                                             checkout_url)):
+            self.app.config.options['checkout_url'] = checkout_url
             flash("Checkout URL successfully changed")
         else:
             flash("%s is not a valid path for this repository" %
-                  post_data['checkout_url'], "error")
+                  checkout_url, "error")
+        self.app.config.options.external_checkout_url = external_checkout_url
+        flash("External checkout URL successfully changed")
 
 
 class SVNImportController(BaseController):

http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/ForgeSVN/forgesvn/templates/svn/checkout_url.html
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/templates/svn/checkout_url.html b/ForgeSVN/forgesvn/templates/svn/checkout_url.html
index 3960798..9931d0c 100644
--- a/ForgeSVN/forgesvn/templates/svn/checkout_url.html
+++ b/ForgeSVN/forgesvn/templates/svn/checkout_url.html
@@ -18,17 +18,29 @@
 -#}
 {% block content %}
 <form>
-  <label class="grid-13" for="checkout_url">Checkout url:</label>
-  <div class="grid-13">
+  <label class="grid-13" for="checkout_url">Checkout branch:</label>
+  <div class="grid-9" style="text-align:right">
     {{app.repo.clone_url('ro', app)}}
     {% if allow_config %}
       <input type="text" name="checkout_url"
              id="checkout_url"
-             {% if checkout_url %} value="{{checkout_url}}"{% endif %}/>
+             {% if app.config.options.checkout_url %} value="{{app.config.options.checkout_url}}"{% endif %}/>
     {% else %}
       <span>{{checkout_url}}</span>
     {% endif %}
   </div>
+  <div class="grid-4">
+      e.g., trunk
+  </div>
+  <div class="grid-13">&nbsp;</div>
+  <label class="grid-4">External checkout URL:</label>
+  <div class="grid-5" style="text-align:right">
+      <input type="text" name="external_checkout_url" id="external_checkout_url" value="{{app.config.options.external_checkout_url or ''}}"/>
+  </div>
+  <div class="grid-13">
+      Override the checkout URL with an external one.  This is useful if this repository is a mirror
+      of another, canonical repository.
+  </div>
 
   {% if allow_config %}
   <div class="grid-13">&nbsp;</div>
@@ -45,6 +57,7 @@
         var cval = $.cookie('_session_id');
         $.post('{{c.project.url()}}admin/{{app.config.options.mount_point}}/set_checkout_url', {
             checkout_url: $('#checkout_url').val(),
+            external_checkout_url: $('#external_checkout_url').val(),
             _session_id:cval
         },
         function () {

http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 2fb7207..3ad13c7 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -784,7 +784,7 @@ class TestRepo(_TestWithRepo):
             self.repo.clone_url('https', 'nobody')
             == 'https://nobody@localhost:8022/scm-repo/p/test/test1/'),\
             self.repo.clone_url('https', 'nobody')
-        with h.push_config(self.repo.app.config.options, clone_url='https://$username@foo.com/'):
+        with h.push_config(self.repo.app.config.options, external_checkout_url='https://$username@foo.com/'):
             assert_equal(
                 self.repo.clone_url('https', 'user'),
                 'https://user@foo.com/')

http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/ForgeSVN/forgesvn/tests/test_svn_app.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/test_svn_app.py b/ForgeSVN/forgesvn/tests/test_svn_app.py
index 6ea576a..7fd8545 100644
--- a/ForgeSVN/forgesvn/tests/test_svn_app.py
+++ b/ForgeSVN/forgesvn/tests/test_svn_app.py
@@ -40,7 +40,7 @@ class TestSVNApp(unittest.TestCase):
         ThreadLocalORMSession.close_all()
 
     def test_admin_menu(self):
-        assert_equals(len(c.app.admin_menu()), 7)
+        assert_equals(len(c.app.admin_menu()), 6)
         assert_equals(c.app.admin_menu()[0].label, 'Checkout URL')
 
     def test_uninstall(self):


[08/14] git commit: [#7160] ticket:546 Downgrade back FormEncode version, just use new regex for url

Posted by jo...@apache.org.
[#7160] ticket:546 Downgrade back FormEncode version, just use new regex for url

New FormEncode breaks something in parameters encoding and validation (~30 test failures),
it's easier now to copy regex from newer version for URL validator. Especially since we're already overriding that for ValidateSvnUrl.


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

Branch: refs/heads/cj/7134
Commit: 3f5a20629beb53aafc9e0de9dbaf45a57d7025b7
Parents: fd618a7
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Feb 27 12:58:28 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Mar 27 16:12:14 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/validators.py | 14 ++++++++++++++
 requirements-common.txt         |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/3f5a2062/Allura/allura/lib/validators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index 964160d..bfb87a8 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -29,6 +29,20 @@ class URL(fev.URL):
     # allows use of IP address instead of domain name
     require_tld = False
 
+    url_re = re.compile(r'''
+        ^(http|https)://
+        (?:[%:\w]*@)?                              # authenticator
+        (?:                                        # ip or domain
+        (?P<ip>(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|
+        (?P<domain>[a-z0-9][a-z0-9\-]{,62}\.)*     # subdomain
+        (?P<tld>[a-z]{2,63}|xn--[a-z0-9\-]{2,59})  # top level domain
+        )
+        (?::[0-9]{1,5})?                           # port
+        # files/delims/etc
+        (?P<path>/[a-z0-9\-\._~:/\?#\[\]@!%\$&\'\(\)\*\+,;=]*)?
+        $
+    ''', re.I | re.VERBOSE)
+
 
 class Ming(fev.FancyValidator):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/3f5a2062/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index a0efd00..7d8e70e 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -13,7 +13,7 @@ docutils==0.9
 EasyWidgets==0.2dev-20130716
 faulthandler==2.1
 feedparser==5.0.1
-FormEncode==1.2.6
+FormEncode==1.2.4
 # dep of Creoleparser
 Genshi==0.6
 # dep of oauth2


[05/14] git commit: [#7160] ticket:557 add test for URL validator

Posted by jo...@apache.org.
[#7160] ticket:557 add test for URL validator


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

Branch: refs/heads/cj/7134
Commit: ee90c939e759eb3d8edc978d7756d4a28d0731a4
Parents: 3f5a206
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Fri Mar 7 03:26:16 2014 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Mar 27 16:12:14 2014 +0000

----------------------------------------------------------------------
 .../tests/functional/test_controllers.py        | 23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ee90c939/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 c5bb2ee..6aeca55 100644
--- a/ForgeSVN/forgesvn/tests/functional/test_controllers.py
+++ b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
@@ -308,6 +308,29 @@ class TestImportController(SVNTestController):
                       {'checkout_url': 'http://fake.svn/'})
         assert tasks.reclone.post.called
 
+    @patch('forgesvn.svn_main.allura.tasks.repo_tasks')
+    @with_tool('test', 'SVN', 'empty', 'empty SVN')
+    def test_validator(self, tasks):
+        r = self.app.post('/p/test/admin/empty/importer/do_import',
+                      {'checkout_url': 'http://fake.svn/'})
+        assert 'That is not a valid URL' not in r
+
+        r = self.app.post('/p/test/admin/empty/importer/do_import',
+                      {'checkout_url': 'http://1.1.1.1'})
+        assert 'That is not a valid URL' not in r
+
+        r = self.app.post('/p/test/admin/empty/importer/do_import',
+                      {'checkout_url': 'http://1.1.1'})
+        assert 'That is not a valid URL' in r
+
+        r = self.app.post('/p/test/admin/empty/importer/do_import',
+                      {'checkout_url': 'http://256.200.200.200'})
+        assert 'That is not a valid URL' in r
+
+        r = self.app.post('/p/test/admin/empty/importer/do_import',
+                      {'checkout_url': 'http://fak#e.svn/'})
+        assert 'That is not a valid URL' in r
+
 
 class SVNTestRenames(TestController):
 


[11/14] git commit: [#7199] ticket:555 set url prefixes in params of sitemap script

Posted by jo...@apache.org.
[#7199] ticket:555 set url prefixes in params of sitemap script


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

Branch: refs/heads/cj/7134
Commit: 0c5a5fdfb96a7d0c5986bc793d2771bd01a4718b
Parents: a5a48ba
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Fri Mar 7 02:51:54 2014 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Mar 27 16:15:58 2014 +0000

----------------------------------------------------------------------
 scripts/create-allura-sitemap.py | 53 ++++++++++++++---------------------
 1 file changed, 21 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0c5a5fdf/scripts/create-allura-sitemap.py
----------------------------------------------------------------------
diff --git a/scripts/create-allura-sitemap.py b/scripts/create-allura-sitemap.py
index 50cfba3..60deeb4 100644
--- a/scripts/create-allura-sitemap.py
+++ b/scripts/create-allura-sitemap.py
@@ -70,7 +70,7 @@ SITEMAP_TEMPLATE = """\
 """
 
 
-def main(options, args):
+def main(options):
     # This script will indirectly call app.sidebar_menu() for every app in
     # every project. Some of the sidebar_menu methods expect the
     # pylons.request threadlocal object to be present. So, we're faking it.
@@ -102,7 +102,7 @@ def main(options, args):
 
     nbhd_id = []
     if options.neighborhood:
-        nbhd_id = [nbhd._id for nbhd in M.Neighborhood.query.find({'name': {'$in': options.neighborhood}})]
+        nbhd_id = [nbhd._id for nbhd in M.Neighborhood.query.find({'url_prefix': {'$in': options.neighborhood}})]
 
     # write sitemap files, MAX_SITEMAP_URLS per file
     for chunk in utils.chunked_find(M.Project, {'deleted': False, 'neighborhood_id': {'$nin': nbhd_id}}):
@@ -140,43 +140,32 @@ def main(options, args):
         with open(os.path.join(output_path, 'sitemap.xml'), 'w') as f:
             f.write(sitemap_index_content)
 
-def callback(option, opt_str, value, parser):
-    args=[]
-    for arg in parser.rargs:
-        if arg[0] != "-":
-            args.append(arg)
-        else:
-            del parser.rargs[:len(args)]
-            break
-    if getattr(parser.values, option.dest):
-        args.extend(getattr(parser.values, option.dest))
-    setattr(parser.values, option.dest, args)
 
 def parse_options():
-
-    def validate(option, opt_str, value, parser):
-        parser.values.urls_per_file = min(value, MAX_SITEMAP_URLS)
-
-    from optparse import OptionParser
-    optparser = OptionParser(
-        usage='allurapaste script /var/local/config/production.ini '
-              '-- %prog [OPTIONS]')
-    optparser.add_option('-o', '--output-dir', dest='output_dir',
-                         default='/tmp/allura_sitemap',
-                         help='Output directory (absolute path).'
+    import argparse
+    class Validate(argparse.Action):
+        def __call__(self, parser, namespace, value, option_string=None):
+            value = min(value, MAX_SITEMAP_URLS)
+            setattr(namespace, self.dest, value)
+
+    parser = argparse.ArgumentParser(description=__doc__,
+                                     formatter_class=argparse.RawDescriptionHelpFormatter)
+    parser.add_argument('-o', '--output-dir',
+                        dest='output_dir',
+                        default='/tmp/allura_sitemap',
+                        help='Output directory (absolute path).'
                               '[default: %default]')
-    optparser.add_option('-u', '--urls-per-file', dest='urls_per_file',
-                         default=10000, type='int',
+    parser.add_argument('-u', '--urls-per-file', dest='urls_per_file',
+                         default=10000, type=int,
                          help='Number of URLs per sitemap file. '
                          '[default: %default, max: ' +
                          str(MAX_SITEMAP_URLS) + ']',
-                         action='callback', callback=validate)
-    optparser.add_option('-n', '--neighborhood', dest='neighborhood', action="callback", callback=callback,
+                         action=Validate)
+    parser.add_argument('-n', '--neighborhood', dest='neighborhood',
                          help="URL prefix of excluded neighborhood(s)",
                          default=None, nargs='*')
-    options, args = optparser.parse_args()
-    return options, args
+
+    return parser.parse_args()
 
 if __name__ == '__main__':
-    options, args = parse_options()
-    main(options, args)
+    sys.exit(main(parse_options()))


[03/14] git commit: [#7277] Remove "incubating" references

Posted by jo...@apache.org.
[#7277] Remove "incubating" references

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/7134
Commit: cb78d4554172210cfea05c14fc12fdb2b6b9fa23
Parents: 829f967
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Mar 26 18:53:14 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Mar 26 20:20:38 2014 +0000

----------------------------------------------------------------------
 Allura/allura/templates/jinja_master/theme_macros.html | 2 +-
 Allura/docs/conf.py                                    | 2 +-
 ForgeImporters/docs/conf.py                            | 2 +-
 scripts/asf-release.sh                                 | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/cb78d455/Allura/allura/templates/jinja_master/theme_macros.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/theme_macros.html b/Allura/allura/templates/jinja_master/theme_macros.html
index f188692..17702dd 100644
--- a/Allura/allura/templates/jinja_master/theme_macros.html
+++ b/Allura/allura/templates/jinja_master/theme_macros.html
@@ -36,7 +36,7 @@
 {%- macro footer(year, path_to_static='') %}
 <footer id="site-footer">
   <nav>
-      <p>This project is powered by <a href="https://forge-allura.apache.org/p/allura/">Apache Allura (incubating)</a>.</p>
+      <p>This project is powered by <a href="https://forge-allura.apache.org/p/allura/">Apache Allura</a>.</p>
       <p>
       Copyright &copy; 2014 The Apache Software Foundation, Licensed under the
       <a style="color: #069;" href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.<br/>

http://git-wip-us.apache.org/repos/asf/allura/blob/cb78d455/Allura/docs/conf.py
----------------------------------------------------------------------
diff --git a/Allura/docs/conf.py b/Allura/docs/conf.py
index 081dd0c..14651da 100644
--- a/Allura/docs/conf.py
+++ b/Allura/docs/conf.py
@@ -53,7 +53,7 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = 'Apache Allura (incubating)'
+project = 'Apache Allura'
 copyright = '2012-2014 The Apache Software Foundation'
 
 # The version info for the project you're documenting, acts as replacement for

http://git-wip-us.apache.org/repos/asf/allura/blob/cb78d455/ForgeImporters/docs/conf.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/docs/conf.py b/ForgeImporters/docs/conf.py
index 26fc1b9..7783282 100644
--- a/ForgeImporters/docs/conf.py
+++ b/ForgeImporters/docs/conf.py
@@ -53,7 +53,7 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = 'Apache Allura (incubating)'
+project = 'Apache Allura'
 copyright = '2012-2014 The Apache Software Foundation'
 
 # The version info for the project you're documenting, acts as replacement for

http://git-wip-us.apache.org/repos/asf/allura/blob/cb78d455/scripts/asf-release.sh
----------------------------------------------------------------------
diff --git a/scripts/asf-release.sh b/scripts/asf-release.sh
index 19ac9e5..b33c47d 100755
--- a/scripts/asf-release.sh
+++ b/scripts/asf-release.sh
@@ -35,7 +35,7 @@ PREV_VERSION=`git tag -l asf_release_* | sort -rn | head -1 | sed -e 's/^asf_rel
 VERSION=`echo $PREV_VERSION | perl -pe '@_ = split /\./; $_[-1]++; $_ = join ".", @_'`
 prompt VERSION "Version" "$VERSION"
 
-RELEASE_BASE=allura-incubating-$VERSION
+RELEASE_BASE=allura-$VERSION
 RELEASE_DIR=$RELEASE_DIR_BASE/$RELEASE_BASE
 RELEASE_FILENAME=$RELEASE_BASE.tar.gz
 RELEASE_FILE=$RELEASE_DIR/$RELEASE_FILENAME
@@ -76,12 +76,12 @@ echo "    git push"
 echo "    git push --tags"
 echo "Then upload the files and signatures, and post the following:"
 echo "-------------------------------------------------------------"
-echo "Subject: [VOTE] Release of Apache Allura $VERSION (incubating)"
+echo "Subject: [VOTE] Release of Apache Allura $VERSION"
 echo "-------------------------------------------------------------"
 cat <<EOF
 Hello,
 
-This is a call for a vote on Apache Allura $VERSION incubating.
+This is a call for a vote on Apache Allura $VERSION.
 
 Source tarball, signature and checksums are available at:
   https://dist.apache.org/repos/dist/dev/incubator/allura/