aboutsummaryrefslogtreecommitdiffstats
path: root/rust/tests/test_api_server_http.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/tests/test_api_server_http.rs')
-rw-r--r--rust/tests/test_api_server_http.rs214
1 files changed, 143 insertions, 71 deletions
diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs
index 4773a44e..17ba6615 100644
--- a/rust/tests/test_api_server_http.rs
+++ b/rust/tests/test_api_server_http.rs
@@ -485,12 +485,15 @@ fn test_reverse_lookups() {
#[test]
fn test_post_container() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/container?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/container?editgroup_id={}",
+ editgroup_id
+ ),
headers,
r#"{"name": "test journal"}"#,
&router,
@@ -519,12 +522,15 @@ fn test_post_batch_container() {
#[test]
fn test_post_creator() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::post(
- &format!( "http://localhost:9411/v0/creator?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/creator?editgroup_id={}",
+ editgroup_id
+ ),
headers,
r#"{"display_name": "some person"}"#,
&router,
@@ -537,8 +543,8 @@ fn test_post_creator() {
#[test]
fn test_post_file() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::post(
@@ -607,8 +613,8 @@ fn test_post_file() {
#[test]
fn test_post_fileset() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::post(
@@ -667,8 +673,8 @@ fn test_post_fileset() {
#[test]
fn test_post_webcapture() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::post(
@@ -737,8 +743,8 @@ fn test_post_webcapture() {
#[test]
fn test_post_release() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::post(
@@ -840,12 +846,15 @@ fn test_post_release() {
#[test]
fn test_post_work() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::post(
- &format!( "http://localhost:9411/v0/work?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/work?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
// TODO: target_work_id
r#"{
@@ -861,12 +870,15 @@ fn test_post_work() {
#[test]
fn test_update_work() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/work?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/work?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{
"extra": { "source": "other speculation" }
@@ -879,10 +891,7 @@ fn test_update_work() {
helpers::check_http_response(
request::post(
- &format!(
- "http://localhost:9411/v0/editgroup/{}/accept",
- editgroup_id
- ),
+ &format!("http://localhost:9411/v0/editgroup/{}/accept", editgroup_id),
headers.clone(),
"",
&router,
@@ -895,12 +904,15 @@ fn test_update_work() {
#[test]
fn test_delete_work() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::delete(
- &format!("http://localhost:9411/v0/work/aaaaaaaaaaaaavkvaaaaaaaaai?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/work/aaaaaaaaaaaaavkvaaaaaaaaai?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
&router,
),
@@ -923,8 +935,8 @@ fn test_delete_work() {
#[test]
fn test_accept_editgroup() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
let c: i64 = container_ident::table
.filter(container_ident::is_live.eq(false))
@@ -941,7 +953,10 @@ fn test_accept_editgroup() {
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/container?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/container?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
&format!(
"{{\"name\": \"test journal 1\", \"editgroup_id\": \"{}\"}}",
@@ -954,7 +969,10 @@ fn test_accept_editgroup() {
);
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/container?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/container?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
&format!(
"{{\"name\": \"test journal 2\", \"editgroup_id\": \"{}\"}}",
@@ -975,10 +993,7 @@ fn test_accept_editgroup() {
helpers::check_http_response(
request::get(
- &format!(
- "http://localhost:9411/v0/editgroup/{}",
- editgroup_id
- ),
+ &format!("http://localhost:9411/v0/editgroup/{}", editgroup_id),
headers.clone(),
&router,
),
@@ -988,10 +1003,7 @@ fn test_accept_editgroup() {
helpers::check_http_response(
request::post(
- &format!(
- "http://localhost:9411/v0/editgroup/{}/accept",
- editgroup_id
- ),
+ &format!("http://localhost:9411/v0/editgroup/{}/accept", editgroup_id),
headers.clone(),
"",
&router,
@@ -1042,12 +1054,15 @@ fn test_changelog() {
#[test]
fn test_400() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers,
r#"{"title": "secret paper",
"release_type": "article-journal",
@@ -1118,13 +1133,16 @@ fn test_edit_gets() {
#[test]
fn test_bad_external_idents() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
// Bad wikidata QID
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret paper",
"wikidata_qid": "P12345"
@@ -1136,7 +1154,10 @@ fn test_bad_external_idents() {
);
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"name": "my journal",
"wikidata_qid": "P12345"
@@ -1148,7 +1169,10 @@ fn test_bad_external_idents() {
);
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"display_name": "some body",
"wikidata_qid": "P12345"
@@ -1162,7 +1186,10 @@ fn test_bad_external_idents() {
// Bad PMCID
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret paper",
"pmcid": "12345"
@@ -1176,7 +1203,10 @@ fn test_bad_external_idents() {
// Bad PMID
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret paper",
"pmid": "not-a-number"
@@ -1190,7 +1220,10 @@ fn test_bad_external_idents() {
// Bad DOI
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret paper",
"doi": "asdf"
@@ -1204,7 +1237,10 @@ fn test_bad_external_idents() {
// Good identifiers
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret paper",
"doi": "10.1234/abcde.781231231239",
@@ -1222,12 +1258,15 @@ fn test_bad_external_idents() {
#[test]
fn test_abstracts() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "some paper",
"doi": "10.1234/iiiiiii",
@@ -1317,8 +1356,8 @@ fn test_abstracts() {
#[test]
fn test_contribs() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
helpers::check_http_response(
request::post(
@@ -1404,13 +1443,16 @@ fn test_post_batch_autoaccept() {
#[test]
fn test_release_dates() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
// Ok
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret minimal paper",
"release_type": "article-journal",
@@ -1425,7 +1467,10 @@ fn test_release_dates() {
// Ok
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret minimal paper",
"release_type": "article-journal",
@@ -1440,7 +1485,10 @@ fn test_release_dates() {
// Ok; ISO 8601
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret minimal paper",
"release_type": "article-journal",
@@ -1453,7 +1501,10 @@ fn test_release_dates() {
);
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret minimal paper",
"release_type": "article-journal",
@@ -1468,7 +1519,10 @@ fn test_release_dates() {
// Ok
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret minimal paper",
"release_type": "article-journal",
@@ -1484,7 +1538,10 @@ fn test_release_dates() {
// Ok for now, but may be excluded later
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret minimal paper",
"release_type": "article-journal",
@@ -1500,7 +1557,10 @@ fn test_release_dates() {
// Bad: year/month only
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret minimal paper",
"release_type": "article-journal",
@@ -1515,7 +1575,10 @@ fn test_release_dates() {
// Bad: full timestamp
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret minimal paper",
"release_type": "article-journal",
@@ -1530,7 +1593,10 @@ fn test_release_dates() {
// Bad: bogus month/day
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret minimal paper",
"release_type": "article-journal",
@@ -1546,13 +1612,16 @@ fn test_release_dates() {
#[test]
fn test_release_types() {
let (headers, router, conn) = helpers::setup_http();
- let editor_id = FatCatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
- let editgroup_id = FatCatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
+ let editor_id = FatcatId::from_str(helpers::TEST_ADMIN_EDITOR_ID).unwrap();
+ let editgroup_id = FatcatId::from_uuid(&create_editgroup(&conn, editor_id.to_uuid()).unwrap());
// Ok
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret minimal paper",
"release_type": "article-journal"
@@ -1566,7 +1635,10 @@ fn test_release_types() {
// Bad
helpers::check_http_response(
request::post(
- &format!("http://localhost:9411/v0/release?editgroup_id={}", editgroup_id),
+ &format!(
+ "http://localhost:9411/v0/release?editgroup_id={}",
+ editgroup_id
+ ),
headers.clone(),
r#"{"title": "secret minimal paper",
"release_type": "journal-article"