agate

Simple gemini server for static files
git clone https://github.com/mbrubeck/agate.git
Log | Files | Refs | README

commit ce55c964dde9a6575947f2c2360163af5099b281
parent 43014748bfceb9d25ad66437849939cc5b134db7
Author: Johann150 <johann.galle@protonmail.com>
Date:   Sat, 27 Feb 2021 10:08:28 +0100

add tests for vhosts

closes #34

Diffstat:
Mtests/tests.rs | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+), 0 deletions(-)

diff --git a/tests/tests.rs b/tests/tests.rs @@ -297,3 +297,66 @@ fn explicit_tls_version() { let mut buf = [0; 10]; tls.read(&mut buf).unwrap(); } + +#[test] +/// - simple vhosts are enabled when multiple hostnames are supplied +/// - the vhosts access the correct files +fn vhosts_example_com() { + let page = get( + &[ + "--addr", + "[::]:1977", + "--hostname", + "example.com", + "--hostname", + "example.org", + ], + addr(1977), + "gemini://example.com/", + ) + .expect("could not get page"); + + assert_eq!(page.header.status, Status::Success); + + assert_eq!( + page.body, + Some( + std::fs::read_to_string(concat!( + env!("CARGO_MANIFEST_DIR"), + "/tests/data/content/example.com/index.gmi" + )) + .unwrap() + ) + ); +} + +#[test] +/// - the vhosts access the correct files +fn vhosts_example_org() { + let page = get( + &[ + "--addr", + "[::]:1978", + "--hostname", + "example.com", + "--hostname", + "example.org", + ], + addr(1978), + "gemini://example.org/", + ) + .expect("could not get page"); + + assert_eq!(page.header.status, Status::Success); + + assert_eq!( + page.body, + Some( + std::fs::read_to_string(concat!( + env!("CARGO_MANIFEST_DIR"), + "/tests/data/content/example.org/index.gmi" + )) + .unwrap() + ) + ); +}