Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/api/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub async fn get_domain<I: AsRef<str>, N: AsRef<str>>(
state
.provider
.get_resource_provider()
.get_domain(&state.db, did.as_ref())
.get_domain(state, did.as_ref())
.await?
.ok_or_else(|| KeystoneApiError::NotFound {
resource: "domain".into(),
Expand All @@ -49,7 +49,7 @@ pub async fn get_domain<I: AsRef<str>, N: AsRef<str>>(
state
.provider
.get_resource_provider()
.find_domain_by_name(&state.db, name.as_ref())
.find_domain_by_name(state, name.as_ref())
.await?
.ok_or_else(|| KeystoneApiError::NotFound {
resource: "domain".into(),
Expand All @@ -76,7 +76,7 @@ pub async fn find_project_from_scope(
state
.provider
.get_resource_provider()
.get_project(&state.db, pid)
.get_project(state, pid)
.await?
} else if let Some(name) = &scope.name {
if let Some(domain) = &scope.domain {
Expand All @@ -87,7 +87,7 @@ pub async fn find_project_from_scope(
.provider
.get_resource_provider()
.find_domain_by_name(
&state.db,
state,
&domain
.name
.clone()
Expand All @@ -107,7 +107,7 @@ pub async fn find_project_from_scope(
state
.provider
.get_resource_provider()
.get_project_by_name(&state.db, name, &domain_id)
.get_project_by_name(state, name, &domain_id)
.await?
} else {
return Err(KeystoneApiError::ProjectDomain);
Expand Down Expand Up @@ -137,7 +137,7 @@ mod tests {
let mut resource_mock = MockResourceProvider::default();
resource_mock
.expect_get_domain()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "domain_id")
.withf(|_, id: &'_ str| id == "domain_id")
.returning(|_, _| {
Ok(Some(Domain {
id: "domain_id".into(),
Expand All @@ -147,7 +147,7 @@ mod tests {
});
resource_mock
.expect_find_domain_by_name()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "domain_name")
.withf(|_, id: &'_ str| id == "domain_name")
.returning(|_, _| {
Ok(Some(Domain {
id: "domain_id".into(),
Expand Down
18 changes: 9 additions & 9 deletions src/api/v3/auth/token/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Token {
&state
.provider
.get_identity_provider()
.get_user(&state.db, token.user_id())
.get_user(state, token.user_id())
.await
.map_err(KeystoneApiError::identity)?
.ok_or_else(|| KeystoneApiError::NotFound {
Expand Down Expand Up @@ -88,7 +88,7 @@ impl Token {
state
.provider
.get_resource_provider()
.get_project(&state.db, &token.project_id)
.get_project(state, &token.project_id)
.await
.map_err(KeystoneApiError::resource)?
.ok_or_else(|| KeystoneApiError::NotFound {
Expand All @@ -104,7 +104,7 @@ impl Token {
state
.provider
.get_resource_provider()
.get_project(&state.db, &token.project_id)
.get_project(state, &token.project_id)
.await
.map_err(KeystoneApiError::resource)?
.ok_or_else(|| KeystoneApiError::NotFound {
Expand All @@ -128,7 +128,7 @@ impl Token {
state
.provider
.get_resource_provider()
.get_project(&state.db, &token.project_id)
.get_project(state, &token.project_id)
.await
.map_err(KeystoneApiError::resource)?
.ok_or_else(|| KeystoneApiError::NotFound {
Expand All @@ -144,7 +144,7 @@ impl Token {
state
.provider
.get_resource_provider()
.get_project(&state.db, &token.project_id)
.get_project(state, &token.project_id)
.await
.map_err(KeystoneApiError::resource)?
.ok_or_else(|| KeystoneApiError::NotFound {
Expand Down Expand Up @@ -219,7 +219,7 @@ mod tests {
let mut identity_mock = MockIdentityProvider::default();
identity_mock
.expect_get_user()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "bar")
.withf(|_, id: &'_ str| id == "bar")
.returning(|_, _| {
Ok(Some(UserResponse {
id: "bar".into(),
Expand All @@ -231,7 +231,7 @@ mod tests {
let mut resource_mock = MockResourceProvider::default();
resource_mock
.expect_get_domain()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "user_domain_id")
.withf(|_, id: &'_ str| id == "user_domain_id")
.returning(|_, _| {
Ok(Some(Domain {
id: "user_domain_id".into(),
Expand Down Expand Up @@ -274,7 +274,7 @@ mod tests {
let mut identity_mock = MockIdentityProvider::default();
identity_mock
.expect_get_user()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "bar")
.withf(|_, id: &'_ str| id == "bar")
.returning(|_, _| {
Ok(Some(UserResponse {
id: "bar".into(),
Expand Down Expand Up @@ -333,7 +333,7 @@ mod tests {
let mut identity_mock = MockIdentityProvider::default();
identity_mock
.expect_get_user()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "bar")
.withf(|_, id: &'_ str| id == "bar")
.returning(|_, _| {
Ok(Some(UserResponse {
id: "bar".into(),
Expand Down
22 changes: 11 additions & 11 deletions src/api/v3/auth/token/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async fn authenticate_request(
state
.provider
.get_identity_provider()
.authenticate_by_password(&state.db, &state.provider, req)
.authenticate_by_password(state, req)
.await?,
);
}
Expand All @@ -83,7 +83,7 @@ async fn authenticate_request(
state
.provider
.get_identity_provider()
.get_user(&state.db, &authz.user_id)
.get_user(state, &authz.user_id)
.await
.map(|x| {
x.ok_or_else(|| KeystoneApiError::NotFound {
Expand Down Expand Up @@ -196,7 +196,7 @@ async fn post(
let catalog: Catalog = state
.provider
.get_catalog_provider()
.get_catalog(&state.db, true)
.get_catalog(&state, true)
.await?
.into();
api_token.token.catalog = Some(catalog);
Expand Down Expand Up @@ -277,7 +277,7 @@ async fn show(
let catalog: Catalog = state
.provider
.get_catalog_provider()
.get_catalog(&state.db, true)
.get_catalog(&state, true)
.await?
.into();
response_token.catalog = Some(catalog);
Expand Down Expand Up @@ -356,12 +356,12 @@ mod tests {
let mut identity_mock = MockIdentityProvider::default();
identity_mock
.expect_authenticate_by_password()
.withf(|_, _, req: &UserPasswordAuthRequest| {
.withf(|_, req: &UserPasswordAuthRequest| {
req.id == Some("uid".to_string())
&& req.password == "pwd"
&& req.name == Some("uname".to_string())
})
.returning(move |_, _, _| Ok(auth_clone.clone()));
.returning(move |_, _| Ok(auth_clone.clone()));

let provider = Provider::mocked_builder()
.config(config.clone())
Expand Down Expand Up @@ -535,7 +535,7 @@ mod tests {
let mut resource_mock = MockResourceProvider::default();
resource_mock
.expect_get_domain()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "user_domain_id")
.withf(|_, id: &'_ str| id == "user_domain_id")
.returning(|_, _| {
Ok(Some(Domain {
id: "user_domain_id".into(),
Expand Down Expand Up @@ -634,7 +634,7 @@ mod tests {
let mut resource_mock = MockResourceProvider::default();
resource_mock
.expect_get_domain()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "user_domain_id")
.withf(|_, id: &'_ str| id == "user_domain_id")
.returning(|_, _| {
Ok(Some(Domain {
id: "user_domain_id".into(),
Expand Down Expand Up @@ -823,12 +823,12 @@ mod tests {
let mut identity_mock = MockIdentityProvider::default();
identity_mock
.expect_authenticate_by_password()
.withf(|_, _, req: &UserPasswordAuthRequest| {
.withf(|_, req: &UserPasswordAuthRequest| {
req.id == Some("uid".to_string())
&& req.password == "pass"
&& req.name == Some("uname".to_string())
})
.returning(|_, _, _| {
.returning(|_, _| {
Ok(AuthenticatedInfo::builder()
.user_id("uid")
.user(UserResponse {
Expand Down Expand Up @@ -979,7 +979,7 @@ mod tests {
let mut identity_mock = MockIdentityProvider::default();
identity_mock
.expect_authenticate_by_password()
.returning(|_, _, _| {
.returning(|_, _| {
Ok(AuthenticatedInfo::builder()
.user_id("uid")
.user(UserResponse {
Expand Down
26 changes: 12 additions & 14 deletions src/api/v3/group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async fn list(
let groups: Vec<Group> = state
.provider
.get_identity_provider()
.list_groups(&state.db, &query.into())
.list_groups(&state, &query.into())
.await
.map_err(KeystoneApiError::identity)?
.into_iter()
Expand Down Expand Up @@ -85,7 +85,7 @@ async fn show(
state
.provider
.get_identity_provider()
.get_group(&state.db, &group_id)
.get_group(&state, &group_id)
.await
.map(|x| {
x.ok_or_else(|| KeystoneApiError::NotFound {
Expand Down Expand Up @@ -115,7 +115,7 @@ async fn create(
let res = state
.provider
.get_identity_provider()
.create_group(&state.db, req.into())
.create_group(&state, req.into())
.await
.map_err(KeystoneApiError::identity)?;
Ok((StatusCode::CREATED, res).into_response())
Expand All @@ -142,7 +142,7 @@ async fn remove(
state
.provider
.get_identity_provider()
.delete_group(&state.db, &group_id)
.delete_group(&state, &group_id)
.await
.map_err(KeystoneApiError::identity)?;
Ok((StatusCode::NO_CONTENT).into_response())
Expand All @@ -155,7 +155,7 @@ mod tests {
http::{Request, StatusCode, header},
};
use http_body_util::BodyExt; // for `collect`
use sea_orm::DatabaseConnection;

use serde_json::json;

use tower::ServiceExt; // for `call`, `oneshot`, and `ready`
Expand All @@ -179,7 +179,7 @@ mod tests {
let mut identity_mock = MockIdentityProvider::default();
identity_mock
.expect_list_groups()
.withf(|_: &DatabaseConnection, _: &GroupListParameters| true)
.withf(|_, _: &GroupListParameters| true)
.returning(|_, _| {
Ok(vec![Group {
id: "1".into(),
Expand Down Expand Up @@ -228,7 +228,7 @@ mod tests {
let mut identity_mock = MockIdentityProvider::default();
identity_mock
.expect_list_groups()
.withf(|_: &DatabaseConnection, qp: &GroupListParameters| {
.withf(|_, qp: &GroupListParameters| {
GroupListParameters {
domain_id: Some("domain".into()),
name: Some("name".into()),
Expand Down Expand Up @@ -282,12 +282,12 @@ mod tests {
let mut identity_mock = MockIdentityProvider::default();
identity_mock
.expect_get_group()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "foo")
.withf(|_, id: &'_ str| id == "foo")
.returning(|_, _| Ok(None));

identity_mock
.expect_get_group()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "bar")
.withf(|_, id: &'_ str| id == "bar")
.returning(|_, _| {
Ok(Some(Group {
id: "bar".into(),
Expand Down Expand Up @@ -346,9 +346,7 @@ mod tests {
let mut identity_mock = MockIdentityProvider::default();
identity_mock
.expect_create_group()
.withf(|_: &DatabaseConnection, req: &GroupCreate| {
req.domain_id == "domain" && req.name == "name"
})
.withf(|_, req: &GroupCreate| req.domain_id == "domain" && req.name == "name")
.returning(|_, req| {
Ok(Group {
id: "bar".into(),
Expand Down Expand Up @@ -399,12 +397,12 @@ mod tests {
let mut identity_mock = MockIdentityProvider::default();
identity_mock
.expect_delete_group()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "foo")
.withf(|_, id: &'_ str| id == "foo")
.returning(|_, _| Err(IdentityProviderError::GroupNotFound("foo".into())));

identity_mock
.expect_delete_group()
.withf(|_: &DatabaseConnection, id: &'_ str| id == "bar")
.withf(|_, id: &'_ str| id == "bar")
.returning(|_, _| Ok(()));

let state = get_mocked_state(identity_mock);
Expand Down
Loading
Loading