diff --git a/tests/readme.md b/tests/readme.md new file mode 100644 index 0000000..9a6644a --- /dev/null +++ b/tests/readme.md @@ -0,0 +1,25 @@ +# Tests + +## Dependencies + +* docker +* docker-compose +* python 3 + +## Run tests + +Execute [`test.bash`](test.bash). + +## Upgrade python packages + +The following will install the newest version of packages in requirements.txt. + +``` bash +cat requirements.txt | sed 's/==.*//g' | xargs pip install -U +``` + +If updates are available --> update and create new version with: + +``` bash +pip-chill > requirements.txt +``` diff --git a/tests/test.bash b/tests/test.bash index 5bf15dc..9955249 100755 --- a/tests/test.bash +++ b/tests/test.bash @@ -17,12 +17,10 @@ generateCert() { generateCert "localhost" generateCert "conference.localhost" -generateCert "pubsub.localhost" generateCert "proxy.localhost" +generateCert "pubsub.localhost" generateCert "upload.localhost" - # If updates are available --> update and create new version with 'pip-chill > requirements.txt' - sudo docker-compose down \ && sudo docker-compose up -d \ \ diff --git a/tests/tests.bats b/tests/tests.bats index 00df7e8..fb387cf 100644 --- a/tests/tests.bats +++ b/tests/tests.bats @@ -3,12 +3,43 @@ load 'bats/bats-support/load' load 'bats/bats-assert/load' +# group alternation in regex because the xml properties switch around. sometimes 'type=...' comes after 'to=...' and sometimes before @test "Should send 5 messages" { - run bash -c "sudo docker-compose logs | grep \"Received\[c2s\]: \" | wc -l" + run bash -c "sudo docker-compose logs | grep -E \"Received\[c2s\]: \" | wc -l" assert_success assert_output "5" } +@test "Should select certificate for localhost" { + run bash -c "sudo docker-compose logs | grep \"Selecting certificate /usr/local/etc/prosody/certs/localhost/fullchain.pem with key /usr/local/etc/prosody/certs/localhost/privkey.pem for localhost\" | wc -l" + assert_success + assert_output "3" +} + +@test "Should select certificate for conference.localhost" { + run bash -c "sudo docker-compose logs | grep \"Selecting certificate /usr/local/etc/prosody/certs/conference.localhost/fullchain.pem with key /usr/local/etc/prosody/certs/conference.localhost/privkey.pem for conference.localhost\" | wc -l" + assert_success + assert_output "3" +} + +@test "Should select certificate for proxy.localhost" { + run bash -c "sudo docker-compose logs | grep \"Selecting certificate /usr/local/etc/prosody/certs/proxy.localhost/fullchain.pem with key /usr/local/etc/prosody/certs/proxy.localhost/privkey.pem for proxy.localhost\" | wc -l" + assert_success + assert_output "3" +} + +@test "Should select certificate for pubsub.localhost" { + run bash -c "sudo docker-compose logs | grep \"Selecting certificate /usr/local/etc/prosody/certs/pubsub.localhost/fullchain.pem with key /usr/local/etc/prosody/certs/pubsub.localhost/privkey.pem for pubsub.localhost\" | wc -l" + assert_success + assert_output "3" +} + +@test "Should select certificate for upload.localhost" { + run bash -c "sudo docker-compose logs | grep \"Selecting certificate /usr/local/etc/prosody/certs/upload.localhost/fullchain.pem with key /usr/local/etc/prosody/certs/upload.localhost/privkey.pem for upload.localhost\" | wc -l" + assert_success + assert_output "3" +} + @test "Should log error for user with wrong password" { run bash -c "sudo docker-compose logs | grep \"Session closed by remote with error: undefined-condition (user intervention: authentication failed: authentication aborted by user)\"" assert_success