From 02fe6c77bc89ff6257084a6c6299546e1b64703f Mon Sep 17 00:00:00 2001 From: perf3ct Date: Fri, 20 Jun 2025 19:17:30 +0000 Subject: [PATCH] feat(tests): fix integration test that was using wrong boolean --- tests/document_deletion_integration_tests.rs | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/document_deletion_integration_tests.rs b/tests/document_deletion_integration_tests.rs index 102075b..077dd8d 100644 --- a/tests/document_deletion_integration_tests.rs +++ b/tests/document_deletion_integration_tests.rs @@ -173,6 +173,25 @@ impl DocumentDeletionTestClient { Ok(result) } + /// Delete document without authentication (for testing unauthorized access) + async fn delete_document_without_auth(&self, document_id: &str) -> Result> { + let response = self.client + .delete(&format!("{}/api/documents/{}", get_base_url(), document_id)) + .timeout(TIMEOUT) + .send() + .await?; + + let status = response.status(); + let text = response.text().await?; + + if !status.is_success() { + return Err(format!("Document deletion failed ({}): {}", status, text).into()); + } + + let result: Value = serde_json::from_str(&text)?; + Ok(result) + } + /// Get document by ID async fn get_document(&self, document_id: &str) -> Result, Box> { let token = self.token.as_ref().ok_or("Not authenticated")?; @@ -436,7 +455,7 @@ async fn test_unauthorized_deletion() { // Try to delete without authentication let fake_id = Uuid::new_v4().to_string(); - let delete_result = client.delete_document(&fake_id).await; + let delete_result = client.delete_document_without_auth(&fake_id).await; // Should return 401 error assert!(delete_result.is_err(), "Unauthenticated deletion should fail");