-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
145 additions
and
109 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
use add_or_delete::add_or_delete_cmd; | ||
use cosmian_logger::log_utils::log_init; | ||
use cosmian_rest_client::Permission; | ||
use search::search_cmd; | ||
use test_findex_server::{ | ||
start_default_test_findex_server, start_default_test_findex_server_with_cert_auth, | ||
|
@@ -10,10 +11,10 @@ use uuid::Uuid; | |
use crate::{ | ||
actions::{ | ||
findex::{add_or_delete::AddOrDeleteAction, search::SearchAction, FindexParameters}, | ||
permissions::{GrantAccess, RevokeAccess}, | ||
permissions::{GrantPermission, RevokePermission}, | ||
}, | ||
error::result::CliResult, | ||
tests::permissions::{create_access_cmd, grant_access_cmd, revoke_access_cmd}, | ||
tests::permissions::{create_index_id_cmd, grant_permission_cmd, revoke_permission_cmd}, | ||
}; | ||
|
||
pub(crate) mod add_or_delete; | ||
|
@@ -100,7 +101,7 @@ pub(crate) async fn test_findex_cert_auth() -> CliResult<()> { | |
log_init(None); | ||
let ctx = start_default_test_findex_server_with_cert_auth().await; | ||
|
||
let index_id = create_access_cmd(&ctx.owner_client_conf_path)?; | ||
let index_id = create_index_id_cmd(&ctx.owner_client_conf_path)?; | ||
trace!("index_id: {index_id}"); | ||
|
||
add_search_delete(&ctx.owner_client_conf_path, &index_id)?; | ||
|
@@ -109,23 +110,22 @@ pub(crate) async fn test_findex_cert_auth() -> CliResult<()> { | |
|
||
#[allow(clippy::panic_in_result_fn, clippy::unwrap_used)] | ||
#[tokio::test] | ||
pub(crate) async fn test_findex_grant_read_access() -> CliResult<()> { | ||
pub(crate) async fn test_findex_grant_read_permission() -> CliResult<()> { | ||
log_init(None); | ||
let ctx = start_default_test_findex_server_with_cert_auth().await; | ||
|
||
let index_id = create_access_cmd(&ctx.owner_client_conf_path)?; | ||
let index_id = create_index_id_cmd(&ctx.owner_client_conf_path)?; | ||
trace!("index_id: {index_id}"); | ||
|
||
add(&ctx.owner_client_conf_path, &index_id)?; | ||
|
||
// Grant read access to the client | ||
grant_access_cmd( | ||
// Grant read permission to the client | ||
grant_permission_cmd( | ||
&ctx.owner_client_conf_path, | ||
GrantAccess { | ||
GrantPermission { | ||
user: "[email protected]".to_owned(), | ||
index_id: index_id.clone(), | ||
permission: "reader".to_owned(), /* todo(manu): use a mutual struct between server and | ||
* client */ | ||
permission: Permission::Read, | ||
}, | ||
)?; | ||
|
||
|
@@ -137,13 +137,13 @@ pub(crate) async fn test_findex_grant_read_access() -> CliResult<()> { | |
// ... but not write | ||
assert!(add(&ctx.user_client_conf_path, &index_id).is_err()); | ||
|
||
// Grant write access | ||
grant_access_cmd( | ||
// Grant write permission | ||
grant_permission_cmd( | ||
&ctx.owner_client_conf_path, | ||
GrantAccess { | ||
GrantPermission { | ||
user: "[email protected]".to_owned(), | ||
index_id: index_id.clone(), | ||
permission: "writer".to_owned(), | ||
permission: Permission::Write, | ||
}, | ||
)?; | ||
|
||
|
@@ -155,20 +155,20 @@ pub(crate) async fn test_findex_grant_read_access() -> CliResult<()> { | |
// ... and write | ||
add(&ctx.user_client_conf_path, &index_id)?; | ||
|
||
// Try to escalade privileges from `reader` to `admin` | ||
grant_access_cmd( | ||
// Try to escalade privileges from `read` to `admin` | ||
grant_permission_cmd( | ||
&ctx.user_client_conf_path, | ||
GrantAccess { | ||
GrantPermission { | ||
user: "[email protected]".to_owned(), | ||
index_id: index_id.clone(), | ||
permission: "admin".to_owned(), | ||
permission: Permission::Admin, | ||
}, | ||
) | ||
.unwrap_err(); | ||
|
||
revoke_access_cmd( | ||
revoke_permission_cmd( | ||
&ctx.owner_client_conf_path, | ||
RevokeAccess { | ||
RevokePermission { | ||
user: "[email protected]".to_owned(), | ||
index_id: index_id.clone(), | ||
}, | ||
|
@@ -181,7 +181,7 @@ pub(crate) async fn test_findex_grant_read_access() -> CliResult<()> { | |
|
||
#[allow(clippy::panic_in_result_fn)] | ||
#[tokio::test] | ||
pub(crate) async fn test_findex_no_access() -> CliResult<()> { | ||
pub(crate) async fn test_findex_no_permission() -> CliResult<()> { | ||
log_init(None); | ||
let ctx = start_default_test_findex_server_with_cert_auth().await; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.