Skip to content
Snippets Groups Projects
README.md 3.01 KiB
Newer Older
  • Learn to ignore specific revisions
  • Francesco Giacomini's avatar
    Francesco Giacomini committed
    # `ngx_http_voms_module` Testing 
    
    Nicholas Terranova's avatar
    Nicholas Terranova committed
    
    ## Description
    
    
    Francesco Giacomini's avatar
    Francesco Giacomini committed
    Setup and files to test the *ngx_http_voms_module* are contained in the `t` folder. The [Openresty data-driven testsuite](https://openresty.gitbooks.io/programming-openresty/content/testing/) has been adopted for testing.
    
    Nicholas Terranova's avatar
    Nicholas Terranova committed
    ### Test fixture setup 
    
    Nicholas Terranova's avatar
    Nicholas Terranova committed
    
    
    All the certificates, proxy certificates, trust-anchors directory, LSC files, etc., needed for the tests are automatically created by the `t/setup.sh` script. It uses utilities contained in the [helper-scripts](https://baltig.infn.it/mw-devel/helper-scripts) repo, in particulare in the `x509-scripts` subdirectory, and the VOMS clients. Certificates and proxies are described in configuration files `t/openssl.conf`, `t/conf.d/*` and `t/proxies.d/*`.
    
    The `helper-scripts` repo needs to be cloned somewhere locally and its X509 scripts made available in the PATH:
    
    Nicholas Terranova's avatar
    Nicholas Terranova committed
    
    
    ```shell
    
    $ git clone https://baltig.infn.it/mw-devel/helper-scripts.git
    $ PATH=$(pwd)/helper-scripts/x509-scripts/scripts:$PATH
    
    ```
    
    Then, to setup, just run:
    
    ```shell
    
    Nicholas Terranova's avatar
    Nicholas Terranova committed
    
    ### Running Tests
    
    
    To run the tests made available in `t` just type
    
    Nicholas Terranova's avatar
    Nicholas Terranova committed
    
    
    Francesco Giacomini's avatar
    Francesco Giacomini committed
    ```shell
    
    $ prove
    
    Francesco Giacomini's avatar
    Francesco Giacomini committed
    ```
    
    Nicholas Terranova's avatar
    Nicholas Terranova committed
    
    
    from `t`'s parent directory.
    
    Francesco Giacomini's avatar
    Francesco Giacomini committed
    The `prove` command creates a directory called `servroot` in `t`, so if the `t` folder is accessible read-only, for
    example in a docker container, just make a copy somewhere else and run the tests from there:
    
    ```shell
    
    Francesco Giacomini's avatar
    Francesco Giacomini committed
    cp -r t /tmp
    cd /tmp
    
    prove
    
    Note: the alert below is unavoidable, but it doesn't affect the tests.
    
    ```
    [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
    ```
    
    
    Francesco Giacomini's avatar
    Francesco Giacomini committed
    ### Testing directly the Nginx server
    
    Francesco Giacomini's avatar
    Francesco Giacomini committed
    You can reuse the config file `t/servroot/conf/nginx.conf` produced by `test::Nginx`, which contains something like
    
    http {
    
        client_body_temp_path /tmp/client_temp;
        proxy_temp_path       /tmp/proxy_temp_path;
        fastcgi_temp_path     /tmp/fastcgi_temp;
        uwsgi_temp_path       /tmp/uwsgi_temp;
        scgi_temp_path        /tmp/scgi_temp;
        server {
    
            error_log logs/error.log debug;
    
            listen 8443 ssl;
    
            ssl_certificate ../../certs/star_test_example.cert.pem;
            ssl_certificate_key ../../certs/star_test_example.key.pem;
            ssl_client_certificate ../../trust-anchors/igi_test_ca.pem;
    
            ssl_verify_depth 10;
            ssl_verify_client on;
            location = / {
    
                default_type text/plain;
                return 200 "$voms_user";
    
    You may want to change the configuration so that the log goes to standard output instead of to a log file:
    
    ```
    server {
        error_log /dev/stdout debug;
        ...
    ```
    
    Francesco Giacomini's avatar
    Francesco Giacomini committed
    
    ```shell
    
    $ nginx -c conf/nginx.conf -p t/servroot/ -elogs/error.log
    
    Modify (as root) `/etc/hosts` so that `nginx-voms.test.example` is an alias for `localhost`:
    
    127.0.0.1	localhost nginx-voms.test.example
    
    Francesco Giacomini's avatar
    Francesco Giacomini committed
    Then run for example `curl`, calling directly the HTTPS endpoint:
    
    ```shell
    
    $ curl https://nginx-voms.test.example:8443 --cert t/certs/3.pem --capath t/trust-anchors --cacert t/certs/3.cert.pem