Skip to content

Commit bcf5743

Browse files
committed
add admin server test
1 parent 0f3b2b2 commit bcf5743

3 files changed

Lines changed: 62 additions & 2 deletions

File tree

‎.github/workflows/spa-server-ci.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ jobs:
3939
with:
4040
submodules: true
4141
- uses: Swatinem/rust-cache@v2
42-
- name: run integration test
43-
# --show-output
42+
- name: run integration test 1
4443
run: cargo test -p tests --test http_test -j 1 -- --test-threads 1
44+
- name: run integration test 2
45+
run: cargo test -p tests --test admin_server_test -j 1 -- --test-threads 1
4546
- name: run spa-client test
4647
run: cargo test -p spa-client -j 1 -- --test-threads 1
4748
- name: run spa-server test
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[server]
2+
address = "http://127.0.0.1:9000"
3+
auth_token = "wrong_token"
4+
# [upload]
5+
## default value is:3
6+
# parallel = 3

‎tests/tests/admin_server_test.rs‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#![allow(unused_variables)]
2+
mod common;
3+
use common::*;
4+
5+
use spa_server::config::get_host_path_from_domain;
6+
use std::time::Duration;
7+
8+
#[tokio::test(flavor = "multi_thread", worker_threads = 3)]
9+
async fn test_wrong_token() {
10+
let domain = LOCAL_HOST.to_owned() + "/27";
11+
let domain = &domain;
12+
13+
clean_web_domain_dir(LOCAL_HOST);
14+
15+
let server_handle = run_server();
16+
17+
tokio::time::sleep(Duration::from_secs(1)).await;
18+
19+
let (api, _) = get_client_api("client_config_wrong_token.toml");
20+
let result = api
21+
.get_domain_info(Some(get_host_path_from_domain(domain).0.to_string()))
22+
.await;
23+
assert!(result.is_err());
24+
server_handle.abort();
25+
}
26+
27+
#[tokio::test(flavor = "multi_thread", worker_threads = 3)]
28+
async fn test_remove_last_version_and_domain() {
29+
let domain = LOCAL_HOST.to_owned() + "/27";
30+
let domain = &domain;
31+
let request_prefix = format!("http://{LOCAL_HOST}:8080/27");
32+
let request_prefix = &request_prefix;
33+
34+
clean_web_domain_dir(LOCAL_HOST);
35+
36+
let server_handle = run_server();
37+
38+
tokio::time::sleep(Duration::from_secs(1)).await;
39+
40+
upload_file_and_check(domain, request_prefix, 1, vec![]).await;
41+
42+
let (api, _) = get_client_api("client_config.toml");
43+
api.remove_files(Some(domain.to_string()), Some(1))
44+
.await
45+
.unwrap();
46+
47+
let result = api
48+
.get_domain_info(Some(get_host_path_from_domain(domain).0.to_string()))
49+
.await;
50+
assert!(result.is_ok());
51+
assert!(result.unwrap().is_empty());
52+
server_handle.abort();
53+
}

0 commit comments

Comments
 (0)