|
| 1 | +name: DAV Integration Tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + paths: |
| 7 | + - ".github/workflows/dav-integration.yml" |
| 8 | + - "dav/**" |
| 9 | + - "go.mod" |
| 10 | + - "go.sum" |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: dav-integration |
| 17 | + cancel-in-progress: false |
| 18 | + |
| 19 | +jobs: |
| 20 | + dav-integration: |
| 21 | + name: DAV Integration Tests |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + services: |
| 25 | + webdav: |
| 26 | + image: httpd:2.4 |
| 27 | + ports: |
| 28 | + - 8443:443 |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v6 |
| 33 | + |
| 34 | + - name: Set up Go |
| 35 | + uses: actions/setup-go@v6 |
| 36 | + with: |
| 37 | + go-version-file: go.mod |
| 38 | + |
| 39 | + - name: Install Ginkgo |
| 40 | + run: go install github.com/onsi/ginkgo/v2/ginkgo@latest |
| 41 | + |
| 42 | + - name: Setup WebDAV Server Configuration |
| 43 | + run: | |
| 44 | + # Create certificates |
| 45 | + mkdir -p /tmp/webdav-certs |
| 46 | + openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ |
| 47 | + -keyout /tmp/webdav-certs/server.key \ |
| 48 | + -out /tmp/webdav-certs/server.crt \ |
| 49 | + -subj "/C=US/ST=Test/L=Test/O=Test/CN=localhost" \ |
| 50 | + -addext "subjectAltName=DNS:localhost,IP:127.0.0.1" |
| 51 | +
|
| 52 | + # Create WebDAV directory |
| 53 | + mkdir -p /tmp/webdav-data |
| 54 | + chmod 777 /tmp/webdav-data |
| 55 | +
|
| 56 | + # Create htpasswd file |
| 57 | + docker run --rm httpd:2.4 htpasswd -nb testuser testpass > /tmp/webdav.passwd |
| 58 | +
|
| 59 | + # Create Apache config with DAV |
| 60 | + cat > /tmp/httpd.conf << 'EOF' |
| 61 | + ServerRoot "/usr/local/apache2" |
| 62 | + Listen 443 |
| 63 | +
|
| 64 | + LoadModule mpm_event_module modules/mod_mpm_event.so |
| 65 | + LoadModule authn_file_module modules/mod_authn_file.so |
| 66 | + LoadModule authn_core_module modules/mod_authn_core.so |
| 67 | + LoadModule authz_host_module modules/mod_authz_host.so |
| 68 | + LoadModule authz_user_module modules/mod_authz_user.so |
| 69 | + LoadModule authz_core_module modules/mod_authz_core.so |
| 70 | + LoadModule auth_basic_module modules/mod_auth_basic.so |
| 71 | + LoadModule dav_module modules/mod_dav.so |
| 72 | + LoadModule dav_fs_module modules/mod_dav_fs.so |
| 73 | + LoadModule setenvif_module modules/mod_setenvif.so |
| 74 | + LoadModule ssl_module modules/mod_ssl.so |
| 75 | + LoadModule unixd_module modules/mod_unixd.so |
| 76 | + LoadModule dir_module modules/mod_dir.so |
| 77 | +
|
| 78 | + User daemon |
| 79 | + Group daemon |
| 80 | +
|
| 81 | + DAVLockDB /usr/local/apache2/var/DavLock |
| 82 | +
|
| 83 | + <IfModule ssl_module> |
| 84 | + SSLRandomSeed startup builtin |
| 85 | + SSLRandomSeed connect builtin |
| 86 | + </IfModule> |
| 87 | +
|
| 88 | + <VirtualHost *:443> |
| 89 | + SSLEngine on |
| 90 | + SSLCertificateFile /usr/local/apache2/certs/server.crt |
| 91 | + SSLCertificateKeyFile /usr/local/apache2/certs/server.key |
| 92 | +
|
| 93 | + DocumentRoot "/usr/local/apache2/webdav" |
| 94 | +
|
| 95 | + <Directory "/usr/local/apache2/webdav"> |
| 96 | + Dav On |
| 97 | + Options +Indexes |
| 98 | + AuthType Basic |
| 99 | + AuthName "WebDAV" |
| 100 | + AuthUserFile /usr/local/apache2/webdav.passwd |
| 101 | + Require valid-user |
| 102 | +
|
| 103 | + <LimitExcept GET OPTIONS> |
| 104 | + Require valid-user |
| 105 | + </LimitExcept> |
| 106 | + </Directory> |
| 107 | + </VirtualHost> |
| 108 | + EOF |
| 109 | +
|
| 110 | + # Get the service container ID |
| 111 | + CONTAINER_ID=$(docker ps --filter "ancestor=httpd:2.4" --format "{{.ID}}") |
| 112 | +
|
| 113 | + # Copy files to container |
| 114 | + docker cp /tmp/httpd.conf $CONTAINER_ID:/usr/local/apache2/conf/httpd.conf |
| 115 | + docker cp /tmp/webdav.passwd $CONTAINER_ID:/usr/local/apache2/webdav.passwd |
| 116 | + docker cp /tmp/webdav-certs/server.crt $CONTAINER_ID:/usr/local/apache2/certs/server.crt |
| 117 | + docker cp /tmp/webdav-certs/server.key $CONTAINER_ID:/usr/local/apache2/certs/server.key |
| 118 | +
|
| 119 | + # Create required directories and set permissions |
| 120 | + docker exec $CONTAINER_ID mkdir -p /usr/local/apache2/webdav |
| 121 | + docker exec $CONTAINER_ID mkdir -p /usr/local/apache2/var |
| 122 | + docker exec $CONTAINER_ID chmod 777 /usr/local/apache2/webdav |
| 123 | + docker exec $CONTAINER_ID chmod 777 /usr/local/apache2/var |
| 124 | +
|
| 125 | + # Reload Apache |
| 126 | + docker exec $CONTAINER_ID apachectl graceful |
| 127 | +
|
| 128 | + # Wait for Apache to be ready |
| 129 | + sleep 3 |
| 130 | +
|
| 131 | + # Test connection |
| 132 | + curl -k -u testuser:testpass https://localhost:8443/ || true |
| 133 | +
|
| 134 | + - name: Run Integration Tests |
| 135 | + env: |
| 136 | + DAV_ENDPOINT: "https://localhost:8443" |
| 137 | + DAV_USER: "testuser" |
| 138 | + DAV_PASSWORD: "testpass" |
| 139 | + DAV_SECRET: "test-secret-key" |
| 140 | + run: | |
| 141 | + export DAV_CA_CERT="$(cat /tmp/webdav-certs/server.crt)" |
| 142 | + cd dav |
| 143 | + ginkgo -v ./integration |
| 144 | +
|
0 commit comments