From bce67be67d9afb2e477ebece026a39de6fab566b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sara=20Aim=C3=A9e=20Smiseth?= <51710585+SaraSmiseth@users.noreply.github.com> Date: Wed, 24 Aug 2022 17:10:54 +0200 Subject: [PATCH] Renamed STORAGE to DEFAULT_STORAGE. Added ARCHIVE_STORE and STORAGE_ARCHIVE2. --- conf.d/02-storage.cfg.lua | 7 +-- docker-entrypoint.bash | 4 +- readme.md | 62 ++++++++++--------- tests/docker-compose.yml | 22 ++++++- tests/test.bash | 10 ++- ...ests-prosody_internal_storage_archive.bats | 21 +++++++ tests/tests.bats | 5 ++ 7 files changed, 93 insertions(+), 38 deletions(-) create mode 100644 tests/tests-prosody_internal_storage_archive.bats diff --git a/conf.d/02-storage.cfg.lua b/conf.d/02-storage.cfg.lua index 05cdb2d..f03f0bd 100644 --- a/conf.d/02-storage.cfg.lua +++ b/conf.d/02-storage.cfg.lua @@ -1,4 +1,4 @@ -default_storage = os.getenv("STORAGE") +default_storage = os.getenv("DEFAULT_STORAGE") sql = { driver = os.getenv("DB_DRIVER"); @@ -9,12 +9,11 @@ sql = { password = os.getenv("DB_PASSWORD"); } --- make 0.10-distributed mod_mam use sql store -archive_store = "archive2" -- Use the same data store as prosody-modules mod_mam +archive_store = os.getenv("ARCHIVE_STORE") storage = { -- this makes mod_mam use the sql storage backend - archive2 = os.getenv("STORAGE"); + archive2 = os.getenv("STORAGE_ARCHIVE2"); } -- https://modules.prosody.im/mod_mam.html diff --git a/docker-entrypoint.bash b/docker-entrypoint.bash index 2f20e9b..b4f0035 100755 --- a/docker-entrypoint.bash +++ b/docker-entrypoint.bash @@ -2,6 +2,8 @@ set -e export ALLOW_REGISTRATION=${ALLOW_REGISTRATION:-true} +export ARCHIVE_STORE=${ARCHIVE_STORE:-"archive2"} +export DEFAULT_STORAGE=${DEFAULT_STORAGE:-"sql"} export DOMAIN_HTTP_UPLOAD=${DOMAIN_HTTP_UPLOAD:-"upload.$DOMAIN"} export DOMAIN_MUC=${DOMAIN_MUC:-"conference.$DOMAIN"} export DOMAIN_PROXY=${DOMAIN_PROXY:-"proxy.$DOMAIN"} @@ -21,7 +23,7 @@ export SERVER_CONTACT_INFO_FEEDBACK=${SERVER_CONTACT_INFO_FEEDBACK:-"xmpp:feedba export SERVER_CONTACT_INFO_SALES=${SERVER_CONTACT_INFO_SALES:-"xmpp:sales@$DOMAIN"} export SERVER_CONTACT_INFO_SECURITY=${SERVER_CONTACT_INFO_SECURITY:-"xmpp:security@$DOMAIN"} export SERVER_CONTACT_INFO_SUPPORT=${SERVER_CONTACT_INFO_SUPPORT:-"xmpp:support@$DOMAIN"} -export STORAGE=${STORAGE:-"sql"} +export STORAGE_ARCHIVE2=${STORAGE_ARCHIVE2:-"sql"} export PROSODY_ADMINS=${PROSODY_ADMINS:-""} if [[ "$1" != "prosody" ]]; then diff --git a/readme.md b/readme.md index 6c1208f..3a2880a 100644 --- a/readme.md +++ b/readme.md @@ -150,7 +150,7 @@ Check [Volumes permissions](#volumes-permissions) as well. I recommend using a `docker-compose.yml` file: ```yaml -version: '3.7' +version: "3.7" services: server: @@ -197,35 +197,37 @@ sudo chown 999:999 ./data #### Environment variables -| Variable | Description | Type | Default value | -| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------ | -------------------------- | -| **ALLOW_REGISTRATION** | Whether to allow registration of new accounts via Jabber clients | _optional_ | true | -| **DOMAIN** | domain | **required** | null | -| **DOMAIN_HTTP_UPLOAD** | Domain which lets clients upload files over HTTP | _optional_ | upload.**DOMAIN** | -| **DOMAIN_MUC** | Domain for Multi-user chat (MUC) for allowing you to create hosted chatrooms/conferences for XMPP users | _optional_ | conference.**DOMAIN** | -| **DOMAIN_PROXY** | Domain for SOCKS5 bytestream proxy for server-proxied file transfers | _optional_ | proxy.**DOMAIN** | -| **DOMAIN_PUBSUB** | Domain for a XEP-0060 pubsub service | _optional_ | pubsub.**DOMAIN** | -| **DB_DRIVER** | May also be "PostgreSQL" or "MySQL" or "SQLite3" (case sensitive!) | _optional_ | SQLite3 | -| **DB_DATABASE** | The database name to use. For SQLite3 this the database filename (relative to the data storage directory). | _optional_ | prosody.sqlite | -| **DB_HOST** | The address of the database server | _optional_ | | -| **DB_PORT** | Port on which the database is listening | _optional_ | | -| **DB_USERNAME** | The username to authenticate to the database | _optional_ | | -| **DB_PASSWORD** | The password to authenticate to the database | _optional_ | | -| **E2E_POLICY_CHAT** | Policy for chat messages. Possible values: "none", "optional" and "required". | _optional_ | "required" | -| **E2E_POLICY_MUC** | Policy for MUC messages. Possible values: "none", "optional" and "required". | _optional_ | "required" | -| **E2E_POLICY_WHITELIST** | Make this module ignore messages sent to and from this JIDs or MUCs. | _optional_ | "" | -| **LOG_LEVEL** | Min log level. Change to debug for more information | _optional_ | info | -| **C2S_REQUIRE_ENCRYPTION** | Whether to force all client-to-server connections to be encrypted or not | _optional_ | true | -| **S2S_REQUIRE_ENCRYPTION** | Whether to force all server-to-server connections to be encrypted or not | _optional_ | true | -| **S2S_SECURE_AUTH** | Require encryption and certificate authentication | _optional_ | true | -| **SERVER_CONTACT_INFO_ABUSE** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:abuse@**DOMAIN**" | -| **SERVER_CONTACT_INFO_ADMIN** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:admin@**DOMAIN**" | -| **SERVER_CONTACT_INFO_FEEDBACK** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:feedback@**DOMAIN**" | -| **SERVER_CONTACT_INFO_SALES** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:sales@**DOMAIN**" | -| **SERVER_CONTACT_INFO_SECURITY** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:security@**DOMAIN**" | -| **SERVER_CONTACT_INFO_SUPPORT** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:support@**DOMAIN**" | -| **PROSODY_ADMINS** | Specify who is an administrator. List of adresses. Eg. "me@example.com", "admin@example.net" | _optional_ | "" | -| **STORAGE** | Select the storage backend to load with the 'storage' configuration option. See [here](https://prosody.im/doc/storage). | _optional_ | "sql" | +| Variable | Description | Type | Default value | +| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------ | -------------------------- | +| **ALLOW_REGISTRATION** | Whether to allow registration of new accounts via Jabber clients | _optional_ | true | +| **DOMAIN** | domain | **required** | null | +| **DOMAIN_HTTP_UPLOAD** | Domain which lets clients upload files over HTTP | _optional_ | upload.**DOMAIN** | +| **DOMAIN_MUC** | Domain for Multi-user chat (MUC) for allowing you to create hosted chatrooms/conferences for XMPP users | _optional_ | conference.**DOMAIN** | +| **DOMAIN_PROXY** | Domain for SOCKS5 bytestream proxy for server-proxied file transfers | _optional_ | proxy.**DOMAIN** | +| **DOMAIN_PUBSUB** | Domain for a XEP-0060 pubsub service | _optional_ | pubsub.**DOMAIN** | +| **DB_DRIVER** | May also be "PostgreSQL" or "MySQL" or "SQLite3" (case sensitive!) | _optional_ | SQLite3 | +| **DB_DATABASE** | The database name to use. For SQLite3 this the database filename (relative to the data storage directory). | _optional_ | prosody.sqlite | +| **DB_HOST** | The address of the database server | _optional_ | | +| **DB_PORT** | Port on which the database is listening | _optional_ | | +| **DB_USERNAME** | The username to authenticate to the database | _optional_ | | +| **DB_PASSWORD** | The password to authenticate to the database | _optional_ | | +| **E2E_POLICY_CHAT** | Policy for chat messages. Possible values: "none", "optional" and "required". | _optional_ | "required" | +| **E2E_POLICY_MUC** | Policy for MUC messages. Possible values: "none", "optional" and "required". | _optional_ | "required" | +| **E2E_POLICY_WHITELIST** | Make this module ignore messages sent to and from this JIDs or MUCs. | _optional_ | "" | +| **LOG_LEVEL** | Min log level. Change to debug for more information | _optional_ | info | +| **C2S_REQUIRE_ENCRYPTION** | Whether to force all client-to-server connections to be encrypted or not | _optional_ | true | +| **S2S_REQUIRE_ENCRYPTION** | Whether to force all server-to-server connections to be encrypted or not | _optional_ | true | +| **S2S_SECURE_AUTH** | Require encryption and certificate authentication | _optional_ | true | +| **SERVER_CONTACT_INFO_ABUSE** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:abuse@**DOMAIN**" | +| **SERVER_CONTACT_INFO_ADMIN** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:admin@**DOMAIN**" | +| **SERVER_CONTACT_INFO_FEEDBACK** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:feedback@**DOMAIN**" | +| **SERVER_CONTACT_INFO_SALES** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:sales@**DOMAIN**" | +| **SERVER_CONTACT_INFO_SECURITY** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:security@**DOMAIN**" | +| **SERVER_CONTACT_INFO_SUPPORT** | A list of strings. Each string should be an URI. See [here](https://prosody.im/doc/modules/mod_server_contact_info). | _optional_ | "xmpp:support@**DOMAIN**" | +| **PROSODY_ADMINS** | Specify who is an administrator. List of adresses. Eg. "me@example.com", "admin@example.net" | _optional_ | "" | +| **DEFAULT_STORAGE** | Select the storage backend to load with the 'storage' configuration option. See [here](https://prosody.im/doc/storage). | _optional_ | "sql" | +| **ARCHIVE_STORE** | Select the archive store. 'archive' or 'archive2'. See [here](https://prosody.im/doc/storage). | _optional_ | "archive2" | +| **STORAGE_ARCHIVE2** | Select the storage backend to load with the 'storage.archive2' configuration option. See [here](https://prosody.im/doc/storage). | _optional_ | "sql" | #### DNS diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 5cfbc65..fff9c10 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -32,7 +32,27 @@ services: E2E_POLICY_WHITELIST: "admin@localhost, user1@localhost" LOG_LEVEL: debug PROSODY_ADMINS: "admin@localhost, admin2@localhost" - STORAGE: "internal" + DEFAULT_STORAGE: "internal" + STORAGE_ARCHIVE2: "internal" + volumes: + - ./certs:/usr/local/etc/prosody/certs + + prosody_internal_storage_archive: + image: prosody + restart: unless-stopped + ports: + - "5000:5000" + - "5222:5222" + - "5223:5223" + - "5269:5269" + - "5281:5281" + environment: + DOMAIN: localhost + E2E_POLICY_WHITELIST: "admin@localhost, user1@localhost" + LOG_LEVEL: debug + PROSODY_ADMINS: "admin@localhost, admin2@localhost" + DEFAULT_STORAGE: "internal" + ARCHIVE_STORE: "archive" volumes: - ./certs:/usr/local/etc/prosody/certs diff --git a/tests/test.bash b/tests/test.bash index d16373f..c74c561 100755 --- a/tests/test.bash +++ b/tests/test.bash @@ -64,14 +64,20 @@ registerTestUsers prosody_postgres runTests prosody_postgres sudo docker-compose down -# Run tests for second container with SQLite +# Run tests for container with SQLite sudo docker-compose up -d prosody registerTestUsers prosody runTests prosody sudo docker-compose down -# Run tests for third container with internal storage +# Run tests for container with internal storage and archive store archive2 sudo docker-compose up -d prosody_internal_storage registerTestUsers prosody_internal_storage runTests prosody_internal_storage sudo docker-compose down + +# Run tests for container with internal storage and archive store archive +sudo docker-compose up -d prosody_internal_storage_archive +registerTestUsers prosody_internal_storage_archive +runTests prosody_internal_storage_archive +sudo docker-compose down diff --git a/tests/tests-prosody_internal_storage_archive.bats b/tests/tests-prosody_internal_storage_archive.bats new file mode 100644 index 0000000..d7bc232 --- /dev/null +++ b/tests/tests-prosody_internal_storage_archive.bats @@ -0,0 +1,21 @@ +# For tests with pipes see: https://github.com/sstephenson/bats/issues/10 + +load 'bats/bats-support/load' +load 'bats/bats-assert/load' + +# TODO +#@test "Should use internal storage" { +# run bash -c "sudo docker-compose logs $batsContainerName | grep -E \"Connecting to \[SQLite3\] \/usr\/local\/var\/lib\/prosody\/prosody\.sqlite\.\.\.\"" +# assert_failure +# assert_output +#} + +@test "Should not use sqlite" { + run bash -c "sudo docker-compose logs $batsContainerName | grep -E \"Connecting to \[SQLite3\] \/usr\/local\/var\/lib\/prosody\/prosody\.sqlite\.\.\.\"" + assert_failure +} + +@test "Should not use postgres" { + run bash -c "sudo docker-compose logs $batsContainerName | grep -E \"Connecting to \[PostgreSQL\] prosody\.\.\.\"" + assert_failure +} diff --git a/tests/tests.bats b/tests/tests.bats index bbac09d..3dc1760 100644 --- a/tests/tests.bats +++ b/tests/tests.bats @@ -86,3 +86,8 @@ load 'bats/bats-assert/load' assert_success assert_output } + +@test "Should not have any sql errors" { + run bash -c "sudo docker-compose logs $batsContainerName | grep --ignore-case Error in SQL transaction" + assert_failure +}