From 0574d58a7c3f0ee87261eec84a85ce63c8ec7252 Mon Sep 17 00:00:00 2001 From: 3wc <3wc.cyberia@doesthisthing.work> Date: Mon, 16 Aug 2021 02:27:59 +0200 Subject: [PATCH] Tidying; add .env.sample --- .env.sample | 11 +++++++++++ capsulflask/__init__.py | 1 + capsulflask/tests/test_auth.py | 2 -- capsulflask/tests/test_console.py | 7 ------- capsulflask/tests_base.py | 4 ++-- docs/configuration.md | 1 + 6 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..df59bfa --- /dev/null +++ b/.env.sample @@ -0,0 +1,11 @@ +# Optional, default `mock` +#SPOKE_MODEL=shell-scripts +# Optional, default `0` +#FLASK_DEBUG=0 +# Optional, default `http://localhost:5000` +#BASE_URL=http://localhost:5000 +# Optional, default `qemu:///system` if you're root, otherwise `qemu:///session` +#VIRSH_DEFAULT_CONNECT_URI=qemu:///system +#ADMIN_PANEL_ALLOW_EMAIL_ADDRESSES=3wc.capsul@doesthisthing.work +# Optional, default no theme +#THEME=yolocolo diff --git a/capsulflask/__init__.py b/capsulflask/__init__.py index c5396ae..154b109 100644 --- a/capsulflask/__init__.py +++ b/capsulflask/__init__.py @@ -59,6 +59,7 @@ def create_app(http_client_factory): LOG_LEVEL=config.get("LOG_LEVEL", "INFO"), SPOKE_HOST_ID=config.get("SPOKE_HOST_ID", "baikal"), SPOKE_HOST_TOKEN=config.get("SPOKE_HOST_TOKEN", "changeme"), + SSH_USERNAME=os.environ.get("SSH_USERNAME", default="cyberian"), HUB_TOKEN=config.get("HUB_TOKEN", "changeme"), # https://www.postgresql.org/docs/9.1/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS diff --git a/capsulflask/tests/test_auth.py b/capsulflask/tests/test_auth.py index 7886c8a..9ba454d 100644 --- a/capsulflask/tests/test_auth.py +++ b/capsulflask/tests/test_auth.py @@ -12,8 +12,6 @@ class LoginTests(BaseTestCase): response = client.get(url_for("auth.login")) self.assert_200(response) - # FIXME test generated login link - def test_login_magiclink(self): token, ignoreCaseMatches = get_model().login('test@example.com') diff --git a/capsulflask/tests/test_console.py b/capsulflask/tests/test_console.py index a02997a..0610a66 100644 --- a/capsulflask/tests/test_console.py +++ b/capsulflask/tests/test_console.py @@ -29,7 +29,6 @@ class ConsoleTests(BaseTestCase): def setUp(self): super().setUp() - get_model().cursor.execute("DELETE FROM host_operation") get_model().cursor.execute("DELETE FROM operations") get_model().cursor.execute("DELETE FROM vm_ssh_host_key") @@ -48,8 +47,6 @@ class ConsoleTests(BaseTestCase): for host_id in host_ids: get_model().host_heartbeat(host_id) - - def test_index(self): self._login('test@example.com') with self.client as client: @@ -80,7 +77,6 @@ class ConsoleTests(BaseTestCase): 0 ) - def test_create_fails_capacity(self): with self.client as client: @@ -162,7 +158,6 @@ class ConsoleTests(BaseTestCase): url_for("console.index") + f'?created={vm_id}' ) - def test_keys_loads(self): self._login('test@example.com') with self.client as client: @@ -215,5 +210,3 @@ class ConsoleTests(BaseTestCase): 'A key with that name already exists', category='message' ) - - diff --git a/capsulflask/tests_base.py b/capsulflask/tests_base.py index ac0f241..62cb695 100644 --- a/capsulflask/tests_base.py +++ b/capsulflask/tests_base.py @@ -26,7 +26,7 @@ from capsulflask.shared import * class BaseTestCase(TestCase): def create_app(self): # Use default connection paramaters - os.environ['POSTGRES_CONNECTION_PARAMETERS'] = "host=localhost port=5432 user=postgres password=dev dbname=capsulflask_test" + os.environ['POSTGRES_CONNECTION_PARAMETERS'] = "host=db port=5432 user=capsul password=capsul dbname=capsulflask_test" os.environ['TESTING'] = 'True' os.environ['LOG_LEVEL'] = 'DEBUG' os.environ['SPOKE_MODEL'] = 'mock' @@ -116,4 +116,4 @@ class TestHTTPClient: # in the same order as the tasks that we passed in -- which were in the same order as online_hosts results = await asyncio.gather(*tasks) - return results \ No newline at end of file + return results diff --git a/docs/configuration.md b/docs/configuration.md index 51ff7ee..19dc08f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -3,6 +3,7 @@ Create a `.env` file to set up the application configuration: ``` +cp .env.sample .env nano .env ```