Skip to content

Commit

Permalink
Added integrationtests
Browse files Browse the repository at this point in the history
  • Loading branch information
wiomoc committed Jul 28, 2019
1 parent cdbb78b commit c3386da
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 6 deletions.
27 changes: 21 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
language: rust

cache: cargo

#codecov
sudo: required

addons:
apt:
sources:
- sourceline: deb https://repo.mosquitto.org/debian jessie main
key_url: http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key

packages:
- libcurl4-openssl-dev
- libelf-dev
Expand All @@ -15,16 +15,31 @@ addons:
- gcc
- binutils-dev
- libiberty-dev

env:
- RUST_TEST_THREADS=1

before_install:
- wget http://ftp.nz.debian.org/debian/pool/main/libw/libwebsockets/libwebsockets3_1.2.2-1_amd64.deb
- sudo dpkg -i libwebsockets3_1.2.2-1_amd64.deb
- sudo apt install -y mosquitto
script:
- cargo build --verbose
- cargo test --verbose
- cargo build --release --verbose
after_success: |
cargo install cargo-kcov &&
mkdir kcov &&
cd kcov &&
cargo kcov --print-install-kcov-sh | sh &&
cd ${TRAVIS_BUILD_DIR} &&
rm -rf kcov &&
cargo kcov --all -v --coveralls &&
cargo kcov --all -v --coveralls --no-clean-rebuild &&
echo "Uploaded code coverage"
deploy:
provider: releases
api_key:
secure: MsOQjpV5QdqOUqG8qJOPJ8IZ5wXARq9y0SDHbqVX2W13vJx3n1sYkbFYTQcuionL5HtMve62AsE+TrRbaUSUob9aytqjOU8eFH095aqpG6ZZh+CzDOnuirVs0WPIizU9zHtzAQT7YcbN59hvivJwnZ03w7SWS129zuoY3VNiOCAgq0h8jmUH/weFc+CuiohhCPXhvTOTuOIemMbnS6r1CTq2hzpj0mdrXRMEwInBpTV8vhOR3TLruIWObHHijW6wnCt0ROobDWq+MaY+3tv3jsdTLJKH++U00c1h3XIznFIyb6GZM2MHkjMsOebHnMnkHqj7Sgi8sbvXsdVazCD/mH4QVrjRuOxuYpWJ700hUnezahuK4uRk62rRr/oc383CBJri2fuXv2V8SY9rPgQAmn0VwSEk7Sys7jmlQ59Y8SYrwMpgFpJjxqrNMU9jOYnSU7O+9IjoD5z5GC8wTRtw+jyzXjm7FcU+/W0fT0yCYdbYGPCs0epc8jB/Na+A14M/y8AcFR86DvOjsv5ko1hWw/yROPR9Y9N/f6unVgCgf90osxLFP6NE8KxSC+CZI2ZAbtll3iwxuPfZxRYanT7g+MgqWnwRJhzrlb/W40NSEX5XT+8+mq1E5aD/O0FBLi54NDK/GuUelaL99S1YPxCcmFvSnXoRZ+dehhHckluPktE=
file: target/release/libmosquitto_jwt_auth.so
on:
repo: wiomoc/mosquitto-jwt-auth
tags: true
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "mosquitto-jwt-auth"
version = "0.1.0"
authors = ["Christoph Walcher <[email protected]>"]
edition = "2018"
[badges]
travis-ci = { repository = "wiomoc/mosquitto-jwt-auth" }
coveralls = { repository = "wiomoc/mosquitto-jwt-auth" }

[lib]
crate-type=["dylib"]
Expand Down
6 changes: 6 additions & 0 deletions tests/mosquitto_invalid_alg.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
auth_plugin target/debug/libmosquitto_jwt_auth.so
auth_opt_jwt_alg HS999
auth_opt_jwt_sec_base64 XmThTwNsoLBlbk3cbOi5r2g1EIJNT7o7zSKy9tMUsIg=
auth_opt_jwt_validate_exp false
auth_opt_jwt_validate_sub_match_username false
listener 3883
6 changes: 6 additions & 0 deletions tests/mosquitto_valid.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
auth_plugin target/debug/libmosquitto_jwt_auth.so
auth_opt_jwt_alg HS256
auth_opt_jwt_sec_base64 XmThTwNsoLBlbk3cbOi5r2g1EIJNT7o7zSKy9tMUsIg=
auth_opt_jwt_validate_exp false
auth_opt_jwt_validate_sub_match_username false
listener 3884
34 changes: 34 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use std::io::{BufRead, BufReader};
use std::process::{Child, Command, Stdio};
use std::thread;
use std::time::Duration;

#[test]
#[cfg(target_os = "linux")]
fn test_should_start() {
let mut child = Command::new("mosquitto")
.args(&["-c", "tests/mosquitto_valid.conf"])
.stdout(Stdio::piped())
.spawn()
.unwrap();

thread::sleep(Duration::from_secs(3));

assert!(child.try_wait().unwrap().is_none());
child.kill().unwrap();
thread::sleep(Duration::from_secs(3));
}

#[test]
#[cfg(target_os = "linux")]
fn test_invalid_config() {
let mut child = Command::new("mosquitto")
.args(&["-c", "tests/mosquitto_invalid_alg.conf"])
.stdout(Stdio::piped())
.spawn()
.unwrap();

thread::sleep(Duration::from_secs(3));

assert_eq!(child.wait().unwrap().code().unwrap(), 1);
}

0 comments on commit c3386da

Please sign in to comment.