Testserver

This documentation describes how to setup a VFS testserver needed during development for the junit tests.

I tried to simplify things as good as I can, e.g. this setup uses for all server the same vfs work directory. Thus it is needed to setup apache to use user 'vfsusr' instead of 'wwwrun'.

Based on this description it should be possible for you to avoid this "insecurity" if needed.

I created it during setup a fresh server based on the following components:

  1. SuSE Linux 9.3 Minimal Installation
  2. Apache 2 Webserver (apache2-2.0.53)
  3. Samba 3 (samba-3.0.12)
  4. ssh (openssh-3.9p1)
  5. vsftp (vsftpd-2.0.2-3)

System setup

  1. You need maven to build the local test-data structure. This is done automatically during build of VFS.
  2. Create a user 'vfsusr' with password 'vfs/%\te:st' and home directory '/home/vfsusr'

    useradd -p vfsusr -m vfsusr
                        
  3. Create the directories
    1. /vfstest
    2. /vfstest/write-tests
    and copy from your local 'target/test-data' the directories
    code,read-tests
    into it.

    Now your structure looks like this:

    /vfstest
    /vfstest/write-tests
    /vfstest/read-tests
    /vfstest/read-tests/emptydir
    /vfstest/read-tests/file1.txt
    /vfstest/read-tests/dir1
    /vfstest/read-tests/dir1/file1.txt
    /vfstest/read-tests/dir1/file2.txt
    /vfstest/read-tests/dir1/file3.txt
    /vfstest/read-tests/dir1/subdir1
    /vfstest/read-tests/dir1/subdir1/file1.txt
    /vfstest/read-tests/dir1/subdir1/file2.txt
    /vfstest/read-tests/dir1/subdir1/file3.txt
    /vfstest/read-tests/dir1/subdir2
    /vfstest/read-tests/dir1/subdir2/file1.txt
    /vfstest/read-tests/dir1/subdir2/file2.txt
    /vfstest/read-tests/dir1/subdir2/file3.txt
    /vfstest/read-tests/dir1/subdir3
    /vfstest/read-tests/dir1/subdir3/file1.txt
    /vfstest/read-tests/dir1/subdir3/file2.txt
    /vfstest/read-tests/dir1/subdir3/file3.txt
    /vfstest/read-tests/empty.txt
    /vfstest/read-tests/file%.txt
    /vfstest/code
    /vfstest/code/sealed
    /vfstest/code/sealed/AnotherClass.class
    /vfstest/code/ClassToLoad.class
                        
  4. Setup a symbolic link to '/vfstest'

    ln -s /vfstest /home/vfsusr/vfstest
                        
  5. Set permissions

    find /vfstest -print0 | xargs -0 chown vfsusr.users
                        
  6. After you followed the steps below and setup the server ensure they are activated and running.

    This is only needed if you installed a fresh system. Otherwise simply restart them.

    insserv xinetd
    insserv apache2
    insserv smb
    insserv nmb
    /etc/rc.d/xinetd restart
    /etc/rc.d/apache2 restart
    /etc/rc.d/smb restart
    /etc/rc.d/nmb restart
                            

Apache 2 Webserver

  1. Create a file named '/etc/apache2/conf.d/vfstest.conf' with this content

    #
    # VFSTEST
    #
    Alias /vfstest /vfstest/
    
    DAVLockDB /var/lib/apache2/dav.lockDB
    DAVMinTimeout 600
    
    <Directory /vfstest>
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    
    <Location />
            DAV On
            Options Indexes MultiViews
            AllowOverride None
    
            AuthType Basic
            AuthName vfstest_zone
            AuthUserFile /etc/apache2/passwd
            <Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
                    Require user vfsusr
            </Limit>
    </Location>
                                
  2. change the permission on
    chown vfsusr.users /var/lib/apache2
                            
  3. Activate the WebDAV module by adding 'dav' and 'dav_fs' to the list of modules in '/etc/sysconfig/apache2'. e.g

    APACHE_MODULES="access actions alias auth auth_dbm autoindex cgi dir env expires include log_config
    mime negotiation setenvif ssl suexec userdir php4 php5 dav dav_fs"
                                
  4. Setup the webserver to use user-id 'vfsusr' and group 'users'. This can be done by changing the file '/etc/apache2/uid.conf'

    User vfsusr
    Group users
                            
  5. Create the VFS user to access the Webdav resource

    htpasswd2 -cmb /etc/apache2/passwd  vfsusr 'vfs/%\te:st'
                            

Samba 3

  1. Create a share 'vfsusr'

    [vfsusr]
       comment = VFS Test Directory
       path = /home/vfsusr
       guest ok = yes
       writable = yes
                            
  2. Setup a 'vfsusr' with password 'vfs/%\te:st'

    smbpasswd -a vfsusr
                            

ssh

  1. In '/etc/ssh/sshd_config' ensure

    PasswordAuthentication yes
                            

vsftp

  1. Ensure the server is not disabled in the xinetd configuration

    Set
    disable=no
    in '/etc/xinetd.d/vsftpd'
  2. Setup the server config: '/etc/vsftpd.conf'

    write_enable=YES
    local_enable=YES
                            

Tests

  1. reactivate the tests in 'build.xml'.

    Search for and comment the exclude.
  2. <!-- tests disabled
    <exclude name="**/*.java">
    </exclude>
     -->
                        
  3. or use the class org.apache.commons.vfs.RunTest where you have to adapt some properties at the top of the file and choose which test you would like to run by comment the others.

    This is the way how I debug a failed testcase.