summaryrefslogtreecommitdiffstats
path: root/rust/tests
diff options
context:
space:
mode:
Diffstat (limited to 'rust/tests')
-rw-r--r--rust/tests/helpers.rs21
-rw-r--r--rust/tests/test_api_server_client.rs5
-rw-r--r--rust/tests/test_api_server_http.rs10
-rw-r--r--rust/tests/test_auth.rs17
-rw-r--r--rust/tests/test_fcid.rs2
-rw-r--r--rust/tests/test_old_python_tests.rs5
6 files changed, 18 insertions, 42 deletions
diff --git a/rust/tests/helpers.rs b/rust/tests/helpers.rs
index f5624dff..2ba94a5c 100644
--- a/rust/tests/helpers.rs
+++ b/rust/tests/helpers.rs
@@ -1,17 +1,12 @@
-extern crate diesel;
-extern crate fatcat;
-extern crate fatcat_api_spec;
-extern crate iron;
-extern crate iron_test;
-extern crate uuid;
-
-use self::iron_test::response;
-use fatcat::api_helpers::FatCatId;
+use fatcat::auth::MacaroonAuthMiddleware;
+use fatcat::identifiers::FatCatId;
+use fatcat::server;
use fatcat_api_spec::client::Client;
use fatcat_api_spec::Context;
use iron::headers::{Authorization, Bearer, ContentType};
use iron::mime::Mime;
use iron::{status, Chain, Headers, Iron, Listening};
+use iron_test::response;
use std::str::FromStr;
// A current problem with this method is that if the test fails (eg, panics, assert fails), the
@@ -20,7 +15,7 @@ use std::str::FromStr;
// cleanup.
#[allow(dead_code)]
pub fn setup_client() -> (Client, Context, Listening) {
- let server = fatcat::test_server().unwrap();
+ let server = server::create_test_server().unwrap();
// setup auth as admin user
let admin_id = FatCatId::from_str("aaaaaaaaaaaabkvkaaaaaaaaae").unwrap();
@@ -37,7 +32,7 @@ pub fn setup_client() -> (Client, Context, Listening) {
let router = fatcat_api_spec::router(server);
let mut chain = Chain::new(router);
chain.link_before(fatcat_api_spec::server::ExtractAuthData);
- chain.link_before(fatcat::auth::MacaroonAuthMiddleware::new());
+ chain.link_before(MacaroonAuthMiddleware::new());
let mut iron_server = Iron::new(chain);
iron_server.threads = 1;
@@ -56,7 +51,7 @@ pub fn setup_http() -> (
iron::middleware::Chain,
diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::PgConnection>>,
) {
- let server = fatcat::test_server().unwrap();
+ let server = fatcat::create_test_server().unwrap();
let conn = server.db_pool.get().expect("db_pool error");
// setup auth as admin user
@@ -69,7 +64,7 @@ pub fn setup_http() -> (
let router = fatcat_api_spec::router(server);
let mut chain = Chain::new(router);
chain.link_before(fatcat_api_spec::server::ExtractAuthData);
- chain.link_before(fatcat::auth::MacaroonAuthMiddleware::new());
+ chain.link_before(MacaroonAuthMiddleware::new());
let mut headers = Headers::new();
let mime: Mime = "application/json".parse().unwrap();
headers.set(ContentType(mime));
diff --git a/rust/tests/test_api_server_client.rs b/rust/tests/test_api_server_client.rs
index 3effc0a3..96d8d924 100644
--- a/rust/tests/test_api_server_client.rs
+++ b/rust/tests/test_api_server_client.rs
@@ -9,11 +9,6 @@
* middleware.
*/
-extern crate fatcat;
-extern crate fatcat_api_spec;
-extern crate iron;
-extern crate uuid;
-
use fatcat_api_spec::{ApiNoContext, ContextWrapperExt, Future};
mod helpers;
diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs
index f84e7e1f..2ea01658 100644
--- a/rust/tests/test_api_server_http.rs
+++ b/rust/tests/test_api_server_http.rs
@@ -6,16 +6,10 @@
* test basic serialization/deserialization, and take advantage of hard-coded example entities.
*/
-extern crate diesel;
-extern crate fatcat;
-extern crate fatcat_api_spec;
-extern crate iron;
-extern crate iron_test;
-extern crate uuid;
-
use diesel::prelude::*;
-use fatcat::api_helpers::*;
use fatcat::database_schema::*;
+use fatcat::editing::get_or_create_editgroup;
+use fatcat::identifiers::*;
use iron::status;
use iron_test::request;
use uuid::Uuid;
diff --git a/rust/tests/test_auth.rs b/rust/tests/test_auth.rs
index 82d9f981..d93051f2 100644
--- a/rust/tests/test_auth.rs
+++ b/rust/tests/test_auth.rs
@@ -1,16 +1,13 @@
-extern crate chrono;
-extern crate fatcat;
-extern crate uuid;
-
-use fatcat::api_helpers::*;
-use fatcat::auth::*;
+use fatcat::auth::AuthConfectionary;
+use fatcat::identifiers::FatCatId;
+use fatcat::{auth, server};
use std::str::FromStr;
#[test]
fn test_macaroons() {
// Test everything we can without connecting to database
- let c = fatcat::auth::AuthConfectionary::new_dummy();
+ let c = AuthConfectionary::new_dummy();
let editor_id = FatCatId::from_str("q3nouwy3nnbsvo3h5klxsx4a7y").unwrap();
// create token w/o expiration
@@ -25,9 +22,9 @@ fn test_macaroons() {
fn test_auth_db() {
// Test things that require database
- let server = fatcat::test_server().unwrap();
+ let server = server::create_test_server().unwrap();
let conn = server.db_pool.get().expect("db_pool error");
- let c = fatcat::auth::AuthConfectionary::new_dummy();
+ let c = AuthConfectionary::new_dummy();
let editor_id = FatCatId::from_str("aaaaaaaaaaaabkvkaaaaaaaaae").unwrap();
// create token
@@ -38,7 +35,7 @@ fn test_auth_db() {
assert_eq!(editor_row.id, editor_id.to_uuid());
// revoke token
- revoke_tokens(&conn, editor_id).unwrap();
+ auth::revoke_tokens(&conn, editor_id).unwrap();
// verification should fail
// XXX: one-second slop breaks this
diff --git a/rust/tests/test_fcid.rs b/rust/tests/test_fcid.rs
index 4feaef5d..aac27129 100644
--- a/rust/tests/test_fcid.rs
+++ b/rust/tests/test_fcid.rs
@@ -1,7 +1,7 @@
extern crate fatcat;
extern crate uuid;
-use fatcat::api_helpers::{fcid2uuid, uuid2fcid};
+use fatcat::identifiers::{fcid2uuid, uuid2fcid};
use uuid::Uuid;
#[test]
diff --git a/rust/tests/test_old_python_tests.rs b/rust/tests/test_old_python_tests.rs
index d607fa42..0676a604 100644
--- a/rust/tests/test_old_python_tests.rs
+++ b/rust/tests/test_old_python_tests.rs
@@ -4,11 +4,6 @@
* a single editgroup.
*/
-extern crate fatcat;
-extern crate fatcat_api_spec;
-extern crate iron;
-extern crate uuid;
-
use fatcat_api_spec::models::*;
use fatcat_api_spec::*;