Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] error while extractng data from group #46

Merged
merged 1 commit into from
Nov 23, 2023
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
26 changes: 19 additions & 7 deletions src/controller/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@ use anyhow::{anyhow, bail, Ok, Result};
use ory_kratos_client::models::Identity;
use serde_json::Value;

use tracing::{error, info, debug};
use tracing::{debug, error, info};

use crate::config::SiriusConfig;

fn populate_set(projects: &mut HashSet<String>, mut data: Value, request_id: &str) -> Result<()> {
let data = data.take();
let data = data
.as_object()
.ok_or_else(|| anyhow!("{request_id}: This should be a map!"))?;
if !data.is_empty() {
for (key, _) in data.iter() {
projects.insert(key.to_owned());
match data {
Value::Object(map) => {
if !map.is_empty() {
for (key, _) in map.iter() {
projects.insert(key.to_owned());
}
}
}
Value::Array(array) => {
if !array.is_empty() {
for project in array.iter() {
let project = project
.as_str()
.ok_or_else(|| anyhow!(" this shoud be a string"))?;
projects.insert(project.to_owned());
}
}
}
_ => bail!("{request_id}: This should be a map or an array!"),
}
Ok(())
}
Expand Down
14 changes: 10 additions & 4 deletions src/controller/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ pub mod test_controler {
.create_async()
.await; */
let identity = serde_json::from_str(IDENTITY_USER).unwrap();
update_controller(Arc::new(config), vec![data], uuid, identity)
update_controller(Arc::new(config), vec![data], uuid, identity, "project")
.await
.unwrap();
kratos_mock.assert_async().await;
Expand Down Expand Up @@ -269,9 +269,15 @@ pub mod test_controler {
.await; */

let identity = serde_json::from_str(IDENTITY_USER).unwrap();
update_controller(Arc::new(config), vec![data.clone(), data], uuid, identity)
.await
.unwrap();
update_controller(
Arc::new(config),
vec![data.clone(), data],
uuid,
identity,
"project",
)
.await
.unwrap();
kratos_mock.assert_async().await;
// opa_mock.assert_async().await;
}
Expand Down
Loading