Skip to content

Repository files navigation

rclone-webdav-mock-drive

A small Go MVP that behaves like a fake WebDAV backend for rclone experiments.

It does not persist cloud data and is not a production WebDAV implementation. It is intended for local development, rclone connection checks, mount smoke tests, and request log inspection.

Table of contents

Features

  • WebDAV-ish endpoints for rclone smoke testing:
    • OPTIONS
    • PROPFIND
    • PROPPATCH
    • PUT
    • GET
    • HEAD
    • DELETE
    • MKCOL
    • COPY
    • MOVE
    • LOCK
    • UNLOCK
  • In-memory file storage for basic create/open/save/delete round trips.
  • Basic WebDAV write locks: LOCK returns a Lock-Token, locked files reject writes without that token, token-bearing saves update the existing content, and UNLOCK releases the file.
  • JSON Lines request logging with method, path, status, user agent, Depth header, request ID, byte counts, and duration.
  • Health endpoint at /healthz.
  • Windows PowerShell install/run scripts.
  • rclone config example.

Architecture

Mode 1: local Go server

+-------------------+      http://127.0.0.1:8080       +----------------------+
| curl / rclone CLI +--------------------------------->| Go mock WebDAV       |
| / browser tests   |                                  | server               |
+-------------------+                                  +----------+-----------+
                                                                   |
                                                                   | JSONL logs
                                                                   v
                                                             ./requests.jsonl

Mode 2: Docker Compose with optional Windows drive mount

+-----------------------------+
| Windows Explorer / Office / |
| PowerShell file operations  |
+--------------+--------------+
               |
               | optional drive mount
               v
+-----------------------------+
| rclone mount + WinFsp       |
| drive letter, e.g. X:       |
+--------------+--------------+
               |
               | WebDAV requests
               v
+-------------------+      http://127.0.0.1:8081       +----------------------+
| curl / rclone CLI +--------------------------------->| docker compose       |
| / browser tests   |                                  | -> Go mock WebDAV    |
+-------------------+                                  | container :8080      |
                                                       +----------+-----------+
                                                                  |
                                                                  | JSONL logs
                                                                  v
                                                       ./docker-data/logs/
                                                       requests.jsonl

Mode 3: production sketch with auth, cache, and remote Drive API

+-----------------------------+
| Windows Explorer / Office / |
| rclone / API clients        |
+--------------+--------------+
               |
               | HTTPS WebDAV
               v
+-----------------------------+
| Edge / reverse proxy        |
| TLS + rate limit + IP rules |
+--------------+--------------+
               |
               | authenticated requests
               v
+-----------------------------+
| Auth layer                  |
| Basic/OIDC/SSO + authz      |
+--------------+--------------+
               |
               v
+------------------------------------------------------+
| WebDAV gateway service                               |
| - PROPFIND / GET / PUT / MOVE / LOCK / UNLOCK        |
| - ETag / conditional requests                        |
| - audit / metrics / tracing                          |
+-----------+----------------------+-------------------+
            |                      |
            | cache lookup         | lock + policy state
            v                      v
+------------------------+   +-------------------------+
| Metadata/listing cache |   | Shared state store      |
| Redis / memory         |   | locks / sessions / ACLs |
+-----------+------------+   +------------+------------+
            |                             |
            | cache miss / invalidate     |
            +---------------+-------------+
                            |
                            v
                 +-------------------------+
                 | Upload staging / temp    |
                 | files / write buffer     |
                 +------------+-------------+
                              |
                              | API calls / commit
                              v
                 +-------------------------+
                 | Remote Drive API         |
                 | OneDrive / Google Drive  |
                 | SharePoint / custom API  |
                 +------------+-------------+
                              |
                              | durable content + metadata
                              v
                 +-------------------------+
                 | Remote storage platform  |
                 +-------------------------+

Notes:

  • Local Go execution listens on 127.0.0.1:8080 by default.
  • Docker Compose publishes the service on host port 8081.
  • Windows drive mounting is optional; direct curl or rclone calls can hit the Docker service without WinFsp.
  • A production version should treat the remote Drive API or backing store as the source of truth; cache should accelerate reads and metadata, not replace persistence.
  • If the service is remote, use HTTPS and authentication in front of WebDAV requests.

Prerequisites

Choose the tools you need based on how you want to run the project:

Scenario Required software
Run locally with Go Go
Run with Docker Compose Docker Desktop
Mount as a Windows drive letter rclone + WinFsp
Mount a Windows drive letter to the Docker service Docker Desktop + rclone + WinFsp

Install prerequisites on Windows with winget

winget install -e --id Docker.DockerDesktop
winget install -e --id Rclone.Rclone
winget install -e --id WinFsp.WinFsp
winget install -e --id GoLang.Go

Notes:

  • Docker Compose is included with Docker Desktop.
  • rclone mount on Windows requires WinFsp.
  • If you only use Docker Compose, Go is optional.
  • After installing with winget, open a new terminal before running the commands below.

Windows end-to-end quickstart

This is the simplest way to get a Windows drive letter that sends file operations to the Docker Compose service.

1. Install required software

Use the winget commands in Prerequisites.

After installation:

  • start Docker Desktop
  • wait until Docker Desktop shows Running
  • open a new PowerShell window

2. Start the Docker Compose service

From this repository:

docker compose up -d --build

Verify the service:

curl http://127.0.0.1:8081/healthz
curl -X PROPFIND -H "Depth: 1" http://127.0.0.1:8081/webdav/

Expected result:

  • /healthz returns {"status":"ok"}
  • PROPFIND returns WebDAV XML with HTTP 207

3. Configure rclone and mount a drive letter

Run the Windows installer script and point it at the Docker Compose port:

powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1 -Addr 127.0.0.1:8081 -ConfigureRclone -Mount -DriveLetter X

What this does:

  • configures the mockdrive rclone remote to http://127.0.0.1:8081/webdav/
  • writes helper scripts to %LOCALAPPDATA%\rclone-webdav-mock-drive
  • opens a new PowerShell window running rclone mount mockdrive: X: --vfs-cache-mode writes

When this succeeds, you should see drive X: in Windows Explorer.

4. Test through the mounted drive

In a new PowerShell window:

Set-Content X:\hello.txt "hello from windows"
Get-Content X:\hello.txt
New-Item -ItemType Directory X:\demo
Get-ChildItem X:\

You can also test with rclone directly:

rclone lsd mockdrive:
rclone copy .\README.md mockdrive:/README.md
rclone cat mockdrive:/README.md

5. Check logs

Docker container logs:

docker compose logs -f

Request log file written by the container:

Get-Content .\docker-data\logs\requests.jsonl -Wait

6. Stop everything

Stop the mounted drive:

  • close the PowerShell window that is running rclone mount
  • or press Ctrl+C in that mount window

Stop Docker Compose:

docker compose down

Troubleshooting

Docker says the daemon is not running

Start Docker Desktop first, then retry:

docker version
docker compose up -d --build

Port 8080 is already in use

This repository already maps Docker to host port 8081, so use:

  • http://127.0.0.1:8081/healthz
  • http://127.0.0.1:8081/webdav/

rclone mount fails on Windows

Check:

  • rclone version
  • WinFsp is installed
  • Docker Compose service is healthy
  • the remote points to 127.0.0.1:8081

Inspect the remote:

rclone config show mockdrive

Try mounting manually:

rclone mount mockdrive: X: --vfs-cache-mode writes

Running from Git Bash

Use powershell.exe and forward the script path with /:

powershell.exe -ExecutionPolicy Bypass -File ./scripts/install.ps1 -Addr 127.0.0.1:8081 -ConfigureRclone -Mount -DriveLetter X

Start the server

The mock WebDAV server listens on 127.0.0.1:8080 by default and exposes:

  • Health check: http://127.0.0.1:8080/healthz
  • WebDAV root: http://127.0.0.1:8080/webdav/

For the Windows install-script flow, see Windows one-click install. For the Docker-backed Windows drive mount flow, see Windows end-to-end quickstart.

Option 1: run locally with Go

go test ./...
go run . -addr 127.0.0.1:8080 -log-file requests.jsonl

Verify in another shell:

curl http://127.0.0.1:8080/healthz
curl -X PROPFIND -H 'Depth: 1' http://127.0.0.1:8080/webdav/

Local request logs are written to:

./requests.jsonl

Option 2: run with Docker Compose

Docker Compose publishes the service on host port 8081 to avoid conflicts with other local services that may already use 8080.

Build and start:

docker compose up --build

Run in the background:

docker compose up -d --build

Verify:

curl http://127.0.0.1:8081/healthz
curl -X PROPFIND -H 'Depth: 1' http://127.0.0.1:8081/webdav/

View logs:

docker compose logs -f

Request logs are also written to:

./docker-data/logs/requests.jsonl

If you use rclone against the Docker Compose service, use:

http://127.0.0.1:8081/webdav/

Stop the service:

docker compose down

Build

Linux/macOS local build:

go build -o bin/rclone-webdav-mock-drive .

Windows amd64 cross compile:

GOOS=windows GOARCH=amd64 go build -o dist/rclone-webdav-mock-drive-windows-amd64.exe .

Windows one-click install

Use this section if you want the install script to set up the locally installed Windows executable. For Docker + drive mount, use Windows end-to-end quickstart instead.

Install prerequisites first using Prerequisites, then run:

powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1 -ConfigureRclone -AddToPath

Start the locally installed server:

powershell -ExecutionPolicy Bypass -File "$env:LOCALAPPDATA\rclone-webdav-mock-drive\run.ps1"
curl http://127.0.0.1:8080/healthz

Or install and immediately start it:

powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1 -ConfigureRclone -AddToPath -Start

GitHub/private repo install example:

$env:GITHUB_TOKEN = "ghp_xxx"
powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1 -ConfigureRclone -AddToPath

Git Bash variant:

powershell.exe -ExecutionPolicy Bypass -File ./scripts/install.ps1 -ConfigureRclone -AddToPath

Installer options:

-InstallDir        Install location. Default: %LOCALAPPDATA%\rclone-webdav-mock-drive
-Addr              Listen address. Default: 127.0.0.1:8080
-LogFile           JSONL log path. Default: <InstallDir>\requests.jsonl
-GitHubToken       Token for private repo/release downloads. Default: $env:GITHUB_TOKEN
-RemoteName        rclone remote name. Default: mockdrive
-DriveLetter       Drive letter for rclone mount. Default: X
-BuildFromSource   Force go install github.com/kyleap/rclone-webdav-mock-drive@latest
-ConfigureRclone   Create/update the rclone WebDAV remote when rclone is installed
-Mount             Start rclone mount in a new PowerShell window (WinFsp required)
-AddToPath         Add the installed bin folder to the current user's PATH
-Start             Start the mock WebDAV server after installing
-Force             Reinstall even if the executable already exists

rclone configuration

Example file: examples/rclone.conf

[mockdrive]
type = webdav
url = http://127.0.0.1:8080/webdav/
vendor = other

That example targets the local Go/Windows server on port 8080. If you are using Docker Compose, change the URL to:

url = http://127.0.0.1:8081/webdav/

Use it with rclone:

rclone --config ./examples/rclone.conf lsd mockdrive:
rclone --config ./examples/rclone.conf copy ./README.md mockdrive:/README.md
rclone --config ./examples/rclone.conf cat mockdrive:/README.md

For mounting, use your OS-specific rclone mount prerequisites. Example:

mkdir -p ./mnt/mockdrive
rclone --config ./examples/rclone.conf mount mockdrive: ./mnt/mockdrive --vfs-cache-mode writes

On Windows, install WinFsp before using rclone mount. For a Docker-backed X: drive walkthrough, see Windows end-to-end quickstart.

Office-style open/save smoke path:

  1. Mount mockdrive: with rclone/WinFsp.
  2. Open an Office file from the mounted drive.
  3. The WebDAV server logs discovery/open traffic such as PROPFIND, HEAD, GET, and LOCK.
  4. While the file is locked, writes to the locked file require the returned lock token; saves with the lock token update the in-memory file content.
  5. Office temp lock files such as ~$name.docx are normal file operations and are also logged.

Windows Explorer / rclone mount action log mapping:

  • Open a folder or refresh a folder: usually PROPFIND with Depth: 1; logged.
  • Create a folder: usually MKCOL; logged.
  • Drag/drop or copy a file into the mounted drive: usually PUT; logged.
  • Open a file: usually HEAD and/or GET; logged.
  • Rename or move a file/folder: usually MOVE; logged.
  • Copy inside the mounted drive: usually COPY or a read/write sequence depending on the client; logged.
  • Delete a file: usually DELETE; logged.
  • Delete a folder: usually DELETE; logged.
  • Open an Office file: discovery/open traffic such as PROPFIND, HEAD, GET, and LOCK; logged.
  • Save an Office file: PUT with the active lock token updates the in-memory content; logged.
  • Office temporary lock files such as ~$report.docx: normal PUT/DELETE file operations; logged.

Example observed log sequence for open folder, drag file in, open file, and delete:

PROPFIND /webdav/ 207
MKCOL /webdav/dragtest/ 201
PROPFIND /webdav/dragtest/ 207
PUT /webdav/dragtest/from-desktop.txt 201
PROPFIND /webdav/dragtest/ 207
GET /webdav/dragtest/from-desktop.txt 200
DELETE /webdav/dragtest/from-desktop.txt 204
DELETE /webdav/dragtest/ 204

On Windows, the default installed log file is:

$env:LOCALAPPDATA\rclone-webdav-mock-drive\requests.jsonl

Watch logs live:

Get-Content "$env:LOCALAPPDATA\rclone-webdav-mock-drive\requests.jsonl" -Wait

Request logs

Run with a log file:

go run . -addr 127.0.0.1:8080 -log-file requests.jsonl

Example log entry:

{"time":"2026-06-01T00:00:00Z","request_id":"abc123","method":"PROPFIND","path":"/webdav/","user_agent":"rclone/v1","depth":"1","status":207,"bytes_in":0,"bytes_out":256,"duration_ms":1}

If -log-file is omitted, request logs are written to stdout.

CLI flags

-addr      HTTP listen address. Default: 127.0.0.1:8080
-log-file  JSONL request log file path. Default: stdout

Scope and limitations

  • This is a mock backend, not a real cloud drive.
  • File contents are kept in memory and are lost when the process exits.
  • No authentication is required.
  • It is designed for local development only; do not expose it to the internet.
  • WebDAV coverage is intentionally minimal and only targets rclone smoke tests/log capture.

Development

go test ./...
go build -o bin/rclone-webdav-mock-drive .
GOOS=windows GOARCH=amd64 go build -o dist/rclone-webdav-mock-drive-windows-amd64.exe .

About

Go MVP mock WebDAV backend for rclone request logging experiments

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages