test scuttlebutt routes
This commit is contained in:
parent
f225cf0dc8
commit
7f4b1b2b00
@ -1,9 +1,9 @@
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
use rocket::serde::json::{Value, json};
|
|
||||||
use rocket::http::{ContentType, Status};
|
use rocket::http::{ContentType, Status};
|
||||||
use rocket::local::blocking::Client;
|
use rocket::local::blocking::Client;
|
||||||
|
use rocket::serde::json::{json, Value};
|
||||||
|
|
||||||
use crate::utils::build_json_response;
|
use crate::utils::build_json_response;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ fn index_html() {
|
|||||||
let body = response.into_string().unwrap();
|
let body = response.into_string().unwrap();
|
||||||
assert!(body.contains("/peers"));
|
assert!(body.contains("/peers"));
|
||||||
assert!(body.contains("/profile"));
|
assert!(body.contains("/profile"));
|
||||||
assert!(body.contains("/messages"));
|
assert!(body.contains("/private"));
|
||||||
assert!(body.contains("/device"));
|
assert!(body.contains("/device"));
|
||||||
assert!(body.contains("/help"));
|
assert!(body.contains("/help"));
|
||||||
assert!(body.contains("/network"));
|
assert!(body.contains("/network"));
|
||||||
@ -154,9 +154,9 @@ fn login_html() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn messages_html() {
|
fn private_html() {
|
||||||
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
||||||
let response = client.get("/messages").dispatch();
|
let response = client.get("/scuttlebutt/private").dispatch();
|
||||||
assert_eq!(response.status(), Status::Ok);
|
assert_eq!(response.status(), Status::Ok);
|
||||||
assert_eq!(response.content_type(), Some(ContentType::HTML));
|
assert_eq!(response.content_type(), Some(ContentType::HTML));
|
||||||
let body = response.into_string().unwrap();
|
let body = response.into_string().unwrap();
|
||||||
@ -166,17 +166,102 @@ fn messages_html() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn peers_html() {
|
fn peers_html() {
|
||||||
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
||||||
let response = client.get("/peers").dispatch();
|
let response = client.get("/scuttlebutt/peers").dispatch();
|
||||||
assert_eq!(response.status(), Status::Ok);
|
assert_eq!(response.status(), Status::Ok);
|
||||||
assert_eq!(response.content_type(), Some(ContentType::HTML));
|
assert_eq!(response.content_type(), Some(ContentType::HTML));
|
||||||
let body = response.into_string().unwrap();
|
let body = response.into_string().unwrap();
|
||||||
assert!(body.contains("Scuttlebutt Peers"));
|
assert!(body.contains("Scuttlebutt Peers"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn friends_html() {
|
||||||
|
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
||||||
|
let response = client.get("/scuttlebutt/friends").dispatch();
|
||||||
|
assert_eq!(response.status(), Status::Ok);
|
||||||
|
assert_eq!(response.content_type(), Some(ContentType::HTML));
|
||||||
|
let body = response.into_string().unwrap();
|
||||||
|
assert!(body.contains("Friends"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn follows_html() {
|
||||||
|
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
||||||
|
let response = client.get("/scuttlebutt/follows").dispatch();
|
||||||
|
assert_eq!(response.status(), Status::Ok);
|
||||||
|
assert_eq!(response.content_type(), Some(ContentType::HTML));
|
||||||
|
let body = response.into_string().unwrap();
|
||||||
|
assert!(body.contains("Follows"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn followers_html() {
|
||||||
|
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
||||||
|
let response = client.get("/scuttlebutt/followers").dispatch();
|
||||||
|
assert_eq!(response.status(), Status::Ok);
|
||||||
|
assert_eq!(response.content_type(), Some(ContentType::HTML));
|
||||||
|
let body = response.into_string().unwrap();
|
||||||
|
assert!(body.contains("Followers"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn block_html() {
|
||||||
|
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
||||||
|
let response = client.get("/scuttlebutt/blocks").dispatch();
|
||||||
|
assert_eq!(response.status(), Status::Ok);
|
||||||
|
assert_eq!(response.content_type(), Some(ContentType::HTML));
|
||||||
|
let body = response.into_string().unwrap();
|
||||||
|
assert!(body.contains("Blocks"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn follow() {
|
||||||
|
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
||||||
|
let response = client
|
||||||
|
.post("/scuttlebutt/follow")
|
||||||
|
.header(ContentType::Form)
|
||||||
|
.body("key=@HEqy940T6uB+T+d9Jaa58aNfRzLx9eRWqkZljBmnkmk=.ed25519")
|
||||||
|
.dispatch();
|
||||||
|
// ensure we redirect (303)
|
||||||
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unfollow() {
|
||||||
|
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
||||||
|
let response = client
|
||||||
|
.post("/scuttlebutt/unfollow")
|
||||||
|
.header(ContentType::Form)
|
||||||
|
.body("key=@HEqy940T6uB+T+d9Jaa58aNfRzLx9eRWqkZljBmnkmk=.ed25519")
|
||||||
|
.dispatch();
|
||||||
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn block() {
|
||||||
|
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
||||||
|
let response = client
|
||||||
|
.post("/scuttlebutt/block")
|
||||||
|
.header(ContentType::Form)
|
||||||
|
.body("key=HEqy940T6uB+T+d9Jaa58aNfRzLx9eRWqkZljBmnkmk=.ed25519")
|
||||||
|
.dispatch();
|
||||||
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn publish_post() {
|
||||||
|
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
||||||
|
let response = client
|
||||||
|
.post("/scuttlebutt/publish")
|
||||||
|
.header(ContentType::Form)
|
||||||
|
.body("text='golden ripples in the meshwork'")
|
||||||
|
.dispatch();
|
||||||
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn profile_html() {
|
fn profile_html() {
|
||||||
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
let client = Client::tracked(init_rocket()).expect("valid rocket instance");
|
||||||
let response = client.get("/profile").dispatch();
|
let response = client.get("/scuttlebutt/profile").dispatch();
|
||||||
assert_eq!(response.status(), Status::Ok);
|
assert_eq!(response.status(), Status::Ok);
|
||||||
assert_eq!(response.content_type(), Some(ContentType::HTML));
|
assert_eq!(response.content_type(), Some(ContentType::HTML));
|
||||||
let body = response.into_string().unwrap();
|
let body = response.into_string().unwrap();
|
||||||
@ -432,7 +517,6 @@ fn test_build_json_response() {
|
|||||||
assert_eq!(j["msg"], json!(null));
|
assert_eq!(j["msg"], json!(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FILE TESTS
|
// FILE TESTS
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user