From 42ffee8c583729287aed7eaa6df4b7b121c1f7f6 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 31 Dec 2018 18:05:24 -0800 Subject: make editor_id optional when createding editgroup The editor_id can be infered from auth metadata. --- rust/tests/test_api_server_http.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'rust/tests/test_api_server_http.rs') diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs index 2160a0a0..d975fe6e 100644 --- a/rust/tests/test_api_server_http.rs +++ b/rust/tests/test_api_server_http.rs @@ -1545,3 +1545,36 @@ fn test_release_types() { Some("release_type"), ); } + +#[test] +fn test_create_editgroup() { + let (headers, router, _conn) = setup_http(); + + // We're authenticated, so don't need to supply editor_id + check_http_response( + request::post( + &format!( + "http://localhost:9411/v0/editgroup", + ), + headers.clone(), + "{}", + &router, + ), + status::Created, + None, + ); + + // But can if we want to + check_http_response( + request::post( + &format!( + "http://localhost:9411/v0/editgroup", + ), + headers.clone(), + r#"{"editor_id": "aaaaaaaaaaaabkvkaaaaaaaaae"}"#, + &router, + ), + status::Created, + None, + ); +} -- cgit v1.2.3 From b292d25b3f29407e4a6c3c093bd15027da6d8d73 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 31 Dec 2018 18:43:51 -0800 Subject: rust fmt --- rust/src/api_wrappers.rs | 2 +- rust/tests/test_api_server_http.rs | 8 ++------ rust/tests/test_old_python_tests.rs | 5 +---- 3 files changed, 4 insertions(+), 11 deletions(-) (limited to 'rust/tests/test_api_server_http.rs') diff --git a/rust/src/api_wrappers.rs b/rust/src/api_wrappers.rs index 3dec1c26..6c003802 100644 --- a/rust/src/api_wrappers.rs +++ b/rust/src/api_wrappers.rs @@ -996,7 +996,7 @@ impl Api for Server { bail!("not authorized to create editgroups in others' names"); } } - }, + } None => { entity.editor_id = Some(auth_context.editor_id.to_string()); } diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs index d975fe6e..5405c9cb 100644 --- a/rust/tests/test_api_server_http.rs +++ b/rust/tests/test_api_server_http.rs @@ -1553,9 +1553,7 @@ fn test_create_editgroup() { // We're authenticated, so don't need to supply editor_id check_http_response( request::post( - &format!( - "http://localhost:9411/v0/editgroup", - ), + &format!("http://localhost:9411/v0/editgroup",), headers.clone(), "{}", &router, @@ -1567,9 +1565,7 @@ fn test_create_editgroup() { // But can if we want to check_http_response( request::post( - &format!( - "http://localhost:9411/v0/editgroup", - ), + &format!("http://localhost:9411/v0/editgroup",), headers.clone(), r#"{"editor_id": "aaaaaaaaaaaabkvkaaaaaaaaae"}"#, &router, diff --git a/rust/tests/test_old_python_tests.rs b/rust/tests/test_old_python_tests.rs index afeff55e..4fc1ffaf 100644 --- a/rust/tests/test_old_python_tests.rs +++ b/rust/tests/test_old_python_tests.rs @@ -199,10 +199,7 @@ fn test_merge_works() { let mut eg = Editgroup::new(); eg.editor_id = Some(admin_id); - let resp = client - .create_editgroup(eg) - .wait() - .unwrap(); + let resp = client.create_editgroup(eg).wait().unwrap(); let editgroup_id = match resp { CreateEditgroupResponse::SuccessfullyCreated(eg) => eg.editgroup_id.unwrap(), _ => unreachable!(), -- cgit v1.2.3