more tests

This commit is contained in:
Sara Aimée Smiseth 2020-10-11 07:53:52 +02:00
parent d2110bd811
commit 4bf43efb42
3 changed files with 58 additions and 4 deletions

25
tests/readme.md Normal file
View file

@ -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
```

View file

@ -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 \
\

View file

@ -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\]: <message type='chat' to='.*@localhost' id=':.*'>\" | wc -l"
run bash -c "sudo docker-compose logs | grep -E \"Received\[c2s\]: <message (type='chat' to='.*@localhost'|to='.*@localhost' type='chat') id=':.*'>\" | 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