From b211538368b1cb106e49442103203a471741e56d Mon Sep 17 00:00:00 2001 From: Shahzad Lone Date: Tue, 8 Oct 2024 01:12:24 -0400 Subject: [PATCH] PR(COVERAGE): Test coverage for the missing error block. --- acp/acp_local_test.go | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/acp/acp_local_test.go b/acp/acp_local_test.go index fce65e9974..b3763da2a9 100644 --- a/acp/acp_local_test.go +++ b/acp/acp_local_test.go @@ -482,7 +482,7 @@ func Test_LocalACP_InMemory_CheckDocAccess_TrueIfHaveAccessFalseIfNotErrorOtherw policyID, ) - // Invalid empty arguments such that we can't check doc access. + // Invalid empty arguments such that we can't check doc access (read). hasAccess, errCheckDocAccess := localACP.CheckDocAccess( ctx, ReadPermission, @@ -495,6 +495,19 @@ func Test_LocalACP_InMemory_CheckDocAccess_TrueIfHaveAccessFalseIfNotErrorOtherw require.ErrorIs(t, errCheckDocAccess, ErrFailedToVerifyDocAccessWithACP) require.False(t, hasAccess) + // Invalid empty arguments such that we can't check doc access (write). + hasAccess, errCheckDocAccess = localACP.CheckDocAccess( + ctx, + WritePermission, + identity1.DID, + validPolicyID, + "", + "", + ) + require.Error(t, errCheckDocAccess) + require.ErrorIs(t, errCheckDocAccess, ErrFailedToVerifyDocAccessWithACP) + require.False(t, hasAccess) + // Check document accesss for a document that does not exist. hasAccess, errCheckDocAccess = localACP.CheckDocAccess( ctx, @@ -568,7 +581,7 @@ func Test_LocalACP_PersistentMemory_CheckDocAccess_TrueIfHaveAccessFalseIfNotErr policyID, ) - // Invalid empty arguments such that we can't check doc access. + // Invalid empty arguments such that we can't check doc access (read). hasAccess, errCheckDocAccess := localACP.CheckDocAccess( ctx, ReadPermission, @@ -581,6 +594,19 @@ func Test_LocalACP_PersistentMemory_CheckDocAccess_TrueIfHaveAccessFalseIfNotErr require.ErrorIs(t, errCheckDocAccess, ErrFailedToVerifyDocAccessWithACP) require.False(t, hasAccess) + // Invalid empty arguments such that we can't check doc access (write). + hasAccess, errCheckDocAccess = localACP.CheckDocAccess( + ctx, + WritePermission, + identity1.DID, + validPolicyID, + "", + "", + ) + require.Error(t, errCheckDocAccess) + require.ErrorIs(t, errCheckDocAccess, ErrFailedToVerifyDocAccessWithACP) + require.False(t, hasAccess) + // Check document accesss for a document that does not exist. hasAccess, errCheckDocAccess = localACP.CheckDocAccess( ctx,