Skip to content

Commit 3f44031

Browse files
author
cleissonbr
committed
fix: review change requests
1 parent 994bfb0 commit 3f44031

File tree

2 files changed

+6
-41
lines changed

2 files changed

+6
-41
lines changed

tests/services/data_tests.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use std::sync::Arc;
21
use std::path::PathBuf;
3-
use std::fs::File;
4-
use std::io::Write;
52

63
use crate::services::utils;
74

@@ -27,25 +24,6 @@ async fn memory_tests() {
2724

2825
#[tokio::test]
2926
async fn test_load_entities_from_file() {
30-
let temp_file_path = Arc::new(PathBuf::from("test_entities.json"));
31-
let test_data = r#"[{
32-
"attrs": {},
33-
"parents": [
34-
{
35-
"id": "Admin",
36-
"type": "Role"
37-
}
38-
],
39-
"uid": {
40-
"id": "admin.1@domain.com",
41-
"type": "User"
42-
}
43-
}]"#;
44-
let mut temp_file = File::create(&*temp_file_path.clone()).unwrap();
45-
temp_file.write_all(test_data.as_bytes()).unwrap();
46-
47-
let entities = load_entities_from_file(temp_file_path.clone().to_path_buf()).await.unwrap();
48-
assert_eq!(entities.len(), 1);
49-
50-
std::fs::remove_file(temp_file_path.clone().to_path_buf()).unwrap();
51-
}
27+
let entities = load_entities_from_file(PathBuf::from("./examples/data.json")).await.unwrap();
28+
assert_eq!(entities.len(), 12);
29+
}

tests/services/policies_tests.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use std::str::FromStr;
2-
use std::sync::Arc;
32
use std::path::PathBuf;
4-
use std::fs::File;
5-
use std::io::Write;
63

74
use cedar_policy::PolicyId;
85

@@ -91,17 +88,7 @@ async fn memory_tests() {
9188

9289
#[tokio::test]
9390
async fn test_load_policies_from_file() {
94-
let temp_file_path = Arc::new(PathBuf::from("test_policies.json"));
95-
let test_data = r#"[{
96-
"id": "test",
97-
"content": "permit(principal in Role::\"Viewer\",action in [Action::\"get\",Action::\"list\"],resource == Document::\"cedar-agent.pdf\");"
98-
}]"#;
99-
let mut temp_file = File::create(&*temp_file_path.clone()).unwrap();
100-
temp_file.write_all(test_data.as_bytes()).unwrap();
101-
102-
let policies = load_policies_from_file(temp_file_path.clone().to_path_buf()).await.unwrap();
103-
assert_eq!(policies.len(), 1);
104-
assert_eq!(policies[0].id, "test".to_string());
105-
106-
std::fs::remove_file(temp_file_path.clone().to_path_buf()).unwrap();
91+
let policies = load_policies_from_file(PathBuf::from("./examples/policies.json")).await.unwrap();
92+
assert_eq!(policies.len(), 3);
93+
assert_eq!(policies[0].id, "admins-policy".to_string());
10794
}

0 commit comments

Comments
 (0)