Update tests for version 0.12.0

This commit is contained in:
Sara Aimée Smiseth 2022-05-05 17:30:21 +02:00
parent ba39c2e299
commit 8af304bc61
5 changed files with 13 additions and 19 deletions

View file

@ -37,6 +37,7 @@ RUN apt-get update \
lua-filesystem \ lua-filesystem \
lua-socket \ lua-socket \
lua-sec \ lua-sec \
lua-unbound \
wget \ wget \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*

View file

@ -1,4 +1,4 @@
version: '3.7' version: '3.9'
services: services:
prosody: prosody:

View file

@ -1,3 +1,3 @@
aioxmpp==0.12.2 aioxmpp==0.13.2
pip-chill==1.0.1 pip-chill==1.0.1
pytest-asyncio==0.15.1 pytest-asyncio==0.18.3

View file

@ -18,7 +18,7 @@ generateCert() {
registerTestUser() { registerTestUser() {
local userName="$1" local userName="$1"
local containerName="$2" local containerName="$2"
sudo docker exec "$containerName" /bin/bash -c "/entrypoint.bash register $userName localhost 12345678" sudo docker compose exec "$containerName" /bin/bash -c "/entrypoint.bash register $userName localhost 12345678"
} }
registerTestUsers() { registerTestUsers() {
@ -60,12 +60,12 @@ sudo docker-compose down \
&& sleep 10 \ && sleep 10 \
&& sudo docker-compose up -d prosody_postgres && sudo docker-compose up -d prosody_postgres
registerTestUsers tests_prosody_postgres_1 registerTestUsers prosody_postgres
runTests prosody_postgres runTests prosody_postgres
sudo docker-compose down sudo docker-compose down
# Run tests for second container with SQLite # Run tests for second container with SQLite
sudo docker-compose up -d prosody sudo docker-compose up -d prosody
registerTestUsers tests_prosody_1 registerTestUsers prosody
runTests prosody runTests prosody
sudo docker-compose down sudo docker-compose down

View file

@ -3,9 +3,8 @@
load 'bats/bats-support/load' load 'bats/bats-support/load'
load 'bats/bats-assert/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" { @test "Should send 5 messages" {
run bash -c "sudo docker-compose logs $batsContainerName | grep -E \"Received\[c2s\]: <message (type='chat'|to='.*@localhost'|id=':.*') (type='chat'|to='.*@localhost'|id=':.*') (type='chat'|to='.*@localhost'|id=':.*')>\" | wc -l" run bash -c "sudo docker-compose logs $batsContainerName | grep -E \"Received\[c2s\]: <message\" | wc -l"
assert_success assert_success
assert_output "5" assert_output "5"
} }
@ -13,31 +12,31 @@ load 'bats/bats-assert/load'
@test "Should select certificate for localhost" { @test "Should select certificate for localhost" {
run bash -c "sudo docker-compose logs $batsContainerName | 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" run bash -c "sudo docker-compose logs $batsContainerName | 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_success
assert_output "3" assert_output "15"
} }
@test "Should select certificate for conference.localhost" { @test "Should select certificate for conference.localhost" {
run bash -c "sudo docker-compose logs $batsContainerName | 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" run bash -c "sudo docker-compose logs $batsContainerName | 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_success
assert_output "3" assert_output "11"
} }
@test "Should select certificate for proxy.localhost" { @test "Should select certificate for proxy.localhost" {
run bash -c "sudo docker-compose logs $batsContainerName | 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" run bash -c "sudo docker-compose logs $batsContainerName | 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_success
assert_output "3" assert_output "11"
} }
@test "Should select certificate for pubsub.localhost" { @test "Should select certificate for pubsub.localhost" {
run bash -c "sudo docker-compose logs $batsContainerName | 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" run bash -c "sudo docker-compose logs $batsContainerName | 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_success
assert_output "3" assert_output "11"
} }
@test "Should select certificate for upload.localhost" { @test "Should select certificate for upload.localhost" {
run bash -c "sudo docker-compose logs $batsContainerName | 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" run bash -c "sudo docker-compose logs $batsContainerName | 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_success
assert_output "3" assert_output "15"
} }
@test "Should log error for user with wrong password" { @test "Should log error for user with wrong password" {
@ -70,12 +69,6 @@ load 'bats/bats-assert/load'
assert_output assert_output
} }
@test "Should activate http" {
run bash -c "sudo docker-compose logs $batsContainerName | grep -E \"Activated service 'http' on (\[::\]:5280|\[\*\]:5280), (\[::\]:5280|\[\*\]:5280)\""
assert_success
assert_output
}
@test "Should activate https" { @test "Should activate https" {
run bash -c "sudo docker-compose logs $batsContainerName | grep -E \"Activated service 'https' on (\[::\]:5281|\[\*\]:5281), (\[::\]:5281|\[\*\]:5281)\"" run bash -c "sudo docker-compose logs $batsContainerName | grep -E \"Activated service 'https' on (\[::\]:5281|\[\*\]:5281), (\[::\]:5281|\[\*\]:5281)\""
assert_success assert_success