Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
sudo is no longer used during testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard70NL committed May 9, 2019
1 parent e15694c commit 1445e1e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -20,7 +20,7 @@ script:
- cargo build --verbose
- cargo build --verbose --release
- if [ "$TRAVIS_OS_NAME" != "windows" ] ; then cargo run -- install --verbose --test-data --database-url=postgresql://dialogue_test@localhost/dialogue_test ; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ] ; then sudo cargo test ; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ] ; then cargo test ; fi

rust:
- stable
Expand Down
5 changes: 3 additions & 2 deletions src/server.rs
Expand Up @@ -80,10 +80,11 @@ impl Server {

/*------------------------------------------------------------------------------------------*/

fn accept_by_address(&self, _addr: &SocketAddr) -> bool {
fn accept_by_address(&self, addr: &SocketAddr) -> bool {
// TODO: implement black/white list functionality here
// for now only connection from 127.0.0.1 are accepted

true
addr.ip().to_string().eq("127.0.0.1")
}

/*------------------------------------------------------------------------------------------*/
Expand Down
7 changes: 4 additions & 3 deletions src/tests/server_tests.rs
Expand Up @@ -13,7 +13,8 @@ use std::time::Duration;

/************************************************************************************************/

const TEST_SERVER_ADDRESS: &str = "127.0.0.1:119";
const TEST_BINDING_ADDRESS: &str = "0.0.0.0:119";
const TEST_CONNECTION_ADDRESS: &str = "127.0.0.1:119";
const TEST_DATA_BASE_URL: &str = "postgresql://dialogue_test@localhost/dialogue_test";
const TEST_READ_TIMEOUT: u64 = 10;

Expand All @@ -34,7 +35,7 @@ fn start_server_in_thread() {
let _handle = spawn(move || {
let mut server = Server::new();
server.set_binding_address(
SocketAddr::from_str(TEST_SERVER_ADDRESS)
SocketAddr::from_str(TEST_BINDING_ADDRESS)
.expect("could not set the binding address of the server"),
);
server.set_database_url(String::from(TEST_DATA_BASE_URL));
Expand All @@ -51,7 +52,7 @@ fn start_server_in_thread() {
/************************************************************************************************/

fn connect_to_server() -> Result<TcpStream, std::io::Error> {
match TcpStream::connect(TEST_SERVER_ADDRESS) {
match TcpStream::connect(TEST_CONNECTION_ADDRESS) {
Ok(stream) => {
stream
.set_read_timeout(Some(Duration::new(TEST_READ_TIMEOUT, 0)))
Expand Down
4 changes: 2 additions & 2 deletions start.sh
Expand Up @@ -2,7 +2,7 @@
# - Set address to 0.0.0.0 (:: for IPv6) to bind to all IP addresses on the
# host.
# - Set address to 127.0.0.1 (::1 for IPv6) to bind to the loopback address
# which limits access to the localhost only (best option during development).
# which limits access to the localhost only.
# - Or set address to specific IP.
cargo build
sudo cargo run -- start --verbose --address 127.0.0.1:119
cargo run -- start --verbose --address 0.0.0.0:119
2 changes: 1 addition & 1 deletion test.sh
Expand Up @@ -4,4 +4,4 @@ psql -c 'drop schema if exists dialogue cascade;' -d dialogue_test -U dialogue_t

cargo run -- install --verbose --test-data --database-url=postgresql://dialogue_test@localhost/dialogue_test

sudo cargo test
cargo test

0 comments on commit 1445e1e

Please sign in to comment.