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

Add test for recently-fixed bug #331

Merged
merged 1 commit into from
Dec 2, 2024
Merged
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
41 changes: 41 additions & 0 deletions tests/document_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,47 @@ async fn doc_grant_access() -> Result<(), IronOxideErr> {
Ok(())
}

#[tokio::test]
async fn doc_add_remove_access() -> Result<(), IronOxideErr> {
let sdk = initialize_sdk().await?;

let doc = [0u8; 64];
let doc_result = sdk
.document_encrypt(doc.into(), &Default::default())
.await?;
let doc_id = doc_result.id().clone();
assert_eq!(doc_result.grants().len(), 1);

// create a second user to grant access to the document
let user = create_second_user().await;

let grants = sdk
.document_grant_access(
&doc_id,
&[UserOrGroup::User {
id: user.account_id().clone(),
}],
)
.await?;
assert_eq!(1, grants.succeeded().len());
assert_eq!(0, grants.failed().len());
let doc_get = sdk.document_get_metadata(&doc_id).await?;
assert_eq!(doc_get.visible_to_users().len(), 2);
let removals = sdk
.document_revoke_access(
&doc_id,
&[UserOrGroup::User {
id: user.account_id().clone(),
}],
)
.await?;
assert_eq!(1, removals.succeeded().len());
assert_eq!(0, removals.failed().len());
let doc_get = sdk.document_get_metadata(&doc_id).await?;
assert_eq!(doc_get.visible_to_users().len(), 1);
Ok(())
}

#[tokio::test]
async fn doc_revoke_access() -> Result<(), IronOxideErr> {
let sdk = initialize_sdk().await?;
Expand Down
Loading