Mock Server

Files.com publishes a mock Files.com API server, which is useful for testing your use of the Files.com SDKs and other direct integrations against the Files.com API in an integration test environment. It never checks credentials: send any placeholder API key, and never use real Files.com credentials with it.

Docker Quick Start

These steps start the mock server from its published Docker image and point your tests at it:

  1. Install Docker Desktop, or another Docker installation, and start it.
  2. Download the image from Docker Hub: docker pull filescom/files-mock-server:latest
  3. Start the server: docker run --rm -p 127.0.0.1:40410:4041 filescom/files-mock-server:latest. It listens at http://127.0.0.1:40410, which only your computer can reach. The command keeps running in that terminal, so run your tests from another one. Press Ctrl+C in the server's terminal to stop it.
  4. Set the base URL of your SDK or client to http://127.0.0.1:40410, as Configuration describes. Send any placeholder API key, and never use real Files.com credentials with it.

Start the Mock Server

# Download the image
docker pull filescom/files-mock-server:latest

# Legacy mode, at http://127.0.0.1:40410. Press Ctrl+C to stop it.
docker run --rm -p 127.0.0.1:40410:4041 filescom/files-mock-server:latest

Server Modes

The quick start runs legacy mode, the default. Legacy mode checks required parameters and parameter types, then returns a fixed example response for each API endpoint. It does not maintain state and it does not deeply inspect your submissions for correctness, which makes it useful for testing basic network operations and JSON encoding for your SDK or API client.

Simulation mode keeps records, files and folders in memory, so a test can create, list, update and delete resources, upload a file and download the same bytes, and make chosen requests fail, stall or lose their connection on purpose. Requests it does not simulate fail with a clear error instead of returning an example response.

FILES_MOCK_MODE is read once at startup. Leaving it unset or empty, or setting it to legacy, starts legacy mode. Setting it to simulation starts simulation mode. Any other value stops startup with an error. Running simulation mode in Docker takes more settings than the quick start command, and the README's Docker Image Usage section gives that command. The image's latest tag moves to whichever server was published last, so it need not include simulation mode. To run exactly the server the README describes, build the image from the source. The README also describes simulation mode's control endpoints, the operations it simulates and its limits.

The source code is on GitHub. To run the server from its source with Ruby and Bundler instead of Docker, follow the README's Requirements and Local Ruby Usage.