Refactor for actix and futures upgrade (#190)

This commit is contained in:
Firstyear 2020-03-07 10:49:39 +10:00 committed by GitHub
parent 5a9ad39d6b
commit c5664988e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 2178 additions and 2905 deletions

1398
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -20,7 +20,7 @@ serde_derive = "1.0"
toml = "0.5"
[dev-dependencies]
tokio = "0.1"
actix = "0.7"
tokio = "0.2"
actix = "0.9"
kanidm = { path = "../kanidmd", version = "0.1" }
futures = "0.1"
futures = "0.3"

View file

@ -1,5 +1,6 @@
use crate::{ClientError, KanidmClientBuilder};
use crate::{ClientError, KanidmClientBuilder, APPLICATION_JSON};
use reqwest;
use reqwest::header::CONTENT_TYPE;
use serde::de::DeserializeOwned;
use serde::Serialize;
@ -29,6 +30,7 @@ impl KanidmAsyncClient {
.client
.post(dest.as_str())
.body(req_string)
.header(CONTENT_TYPE, APPLICATION_JSON)
.send()
.await
.map_err(ClientError::Transport)?;
@ -59,6 +61,7 @@ impl KanidmAsyncClient {
let response = self
.client
.put(dest.as_str())
.header(CONTENT_TYPE, APPLICATION_JSON)
.body(req_string)
.send()
.await

View file

@ -5,6 +5,7 @@
extern crate log;
use reqwest;
use reqwest::header::CONTENT_TYPE;
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde_derive::Deserialize;
@ -28,6 +29,8 @@ pub mod asynchronous;
use crate::asynchronous::KanidmAsyncClient;
pub static APPLICATION_JSON: &'static str = "application/json";
#[derive(Debug)]
pub enum ClientError {
Unauthorized,
@ -295,6 +298,7 @@ impl KanidmClient {
let response = self
.client
.post(dest.as_str())
.header(CONTENT_TYPE, APPLICATION_JSON)
.body(req_string)
.send()
.map_err(ClientError::Transport)?;
@ -322,6 +326,7 @@ impl KanidmClient {
let response = self
.client
.put(dest.as_str())
.header(CONTENT_TYPE, APPLICATION_JSON)
.body(req_string)
.send()
.map_err(ClientError::Transport)?;
@ -550,6 +555,7 @@ impl KanidmClient {
.attrs
.insert("name".to_string(), vec![name.to_string()]);
self.perform_post_request("/v1/group", new_group)
.map(|_: OperationResponse| ())
}
// ==== accounts
@ -568,6 +574,7 @@ impl KanidmClient {
.attrs
.insert("displayname".to_string(), vec![dn.to_string()]);
self.perform_post_request("/v1/account", new_acct)
.map(|_: OperationResponse| ())
}
pub fn idm_account_set_displayname(&self, id: &str, dn: &str) -> Result<(), ClientError> {

View file

@ -44,7 +44,8 @@ fn run_test(test_fn: fn(KanidmClient) -> ()) {
// This appears to be bind random ...
// let srv = srv.bind("127.0.0.1:0").unwrap();
let _ = tx.send(System::current());
});
})
.expect("unable to start system");
});
let sys = rx.recv().unwrap();
System::set_current(sys.clone());

View file

@ -13,7 +13,7 @@ repository = "https://github.com/kanidm/kanidm/"
serde = "1.0"
serde_derive = "1.0"
uuid = { version = "0.7", features = ["serde", "v4"] }
actix = { version = "0.7", optional = true }
# actix = { version = "0.9", optional = true }
zxcvbn = { version = "2.0", features = ["ser"] }
[dev-dependencies]

View file

@ -43,9 +43,6 @@ path = "src/test_auth.rs"
kanidm_client = { path = "../kanidm_client", version = "0.1" }
kanidm_proto = { path = "../kanidm_proto", version = "0.1" }
kanidm = { path = "../kanidmd" }
# actix = { path = "../../actix", version = "0.9" }
actix = "0.7"
# actix-rt = "1.0"
toml = "0.5"
rpassword = "0.4"
tokio = { version = "0.2", features=["full"] }
@ -69,3 +66,4 @@ reqwest = { version = "0.10" }
[dev-dependencies]
kanidm = { path = "../kanidmd", version = "0.1" }
actix = "0.9"

View file

@ -40,7 +40,8 @@ fn run_test(fix_fn: fn(&KanidmClient) -> (), test_fn: fn(CacheLayer, KanidmAsync
System::run(move || {
create_server_core(config);
let _ = tx.send(System::current());
});
})
.expect("Failed to start system");
});
let sys = rx.recv().unwrap();
System::set_current(sys.clone());

View file

@ -28,10 +28,11 @@ path = "src/server/main.rs"
[dependencies]
kanidm_proto = { path = "../kanidm_proto", version = "0.1" }
actix = "0.7"
actix-web = { version = "0.7", features = ["ssl"] }
actix = "0.9"
actix-web = { version = "2.0", features = ["openssl"] }
actix-session = "0.3"
actix-files = "0.2"
bytes = "0.4"
log = "0.4"
env_logger = "0.6"
rand = "0.6"
@ -42,8 +43,8 @@ regex = "1"
lazy_static = "1.2.0"
lru = "0.1"
tokio = "0.1"
futures = "0.1"
tokio = "0.2"
futures = "0.3"
uuid = { version = "0.7", features = ["serde", "v4" ] }
serde = "1.0"
serde_cbor = "0.10"

File diff suppressed because it is too large Load diff

1567
kanidmd/src/lib/core/mod.rs Normal file

File diff suppressed because it is too large Load diff