mozilla-services / syncserver

Run-Your-Own Firefox Sync Server
Mozilla Public License 2.0
1.87k stars 145 forks source link

builtin test not working #190

Closed David-Lor closed 4 years ago

David-Lor commented 4 years ago

Trying the internal test suite as specified on the README section, running the following command on the same Docker container where the syncserver is running:

/usr/local/bin/python -m syncstorage.tests.functional.test_storage \
    --use-token-server http://localhost:5555/token/1.0/sync/1.5

It returns:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/site-packages/syncstorage/tests/functional/test_storage.py", line 2281, in <module>
    res = run_live_functional_tests(TestStorage, sys.argv)
  File "/usr/local/lib/python2.7/site-packages/syncstorage/tests/functional/support.py", line 203, in run_live_functional_tests
    creds = authenticate_to_token_server(url, opts.email, opts.audience)
  File "/usr/local/lib/python2.7/site-packages/syncstorage/tests/functional/support.py", line 135, in authenticate_to_token_server
    r.raise_for_status()
  File "/usr/local/lib/python2.7/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://localhost:5555/token/1.0/sync/1.5

Deployed with the following docker-compose:

version: '3'

services:
  mozilla-sync:
    # https://github.com/mozilla-services/syncserver#runner-under-docker
    container_name: mozilla-sync
    image: mozilla/syncserver
    ports:
      - 5555:5555
    volumes:
      # data dir must be owned by UID/GID 1001:1001
      - ./data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
      - PORT=5555
      - SYNCSERVER_SQLURI=sqlite:////data/syncserver.db
    env_file:
      - mozilla-sync.env
    restart: unless-stopped
    networks:
      - frontend

networks:
  frontend:
    driver: bridge
    internal: false

The mozilla-sync.env:

SYNCSERVER_PUBLIC_URL=http://server.lan:5555
SYNCSERVER_BATCH_UPLOAD_ENABLED=true
SYNCSERVER_FORCE_WSGI_ENVIRON=true
SYNCSERVER_SECRET=xxxxxx
David-Lor commented 4 years ago

The problem was running the command with localhost instead of server.lan (as specified in the SYNCSERVER_PUBLIC_URL env var), although SYNCSERVER_FORCE_WSGI_ENVIRON was set to true (AFAIK it should allow accessing the server from any url?)