From c99dfaeac9c784b71d64a40702af04743a108fef Mon Sep 17 00:00:00 2001 From: Eddy Filip Date: Thu, 30 May 2024 09:25:47 +0200 Subject: [PATCH] Improve secure note test case We now check that the password attribute is set to null --- internal/provider/onepassword_item_resource_test.go | 1 + internal/provider/test_http_server.go | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/provider/onepassword_item_resource_test.go b/internal/provider/onepassword_item_resource_test.go index 60a4975b..5b425e59 100644 --- a/internal/provider/onepassword_item_resource_test.go +++ b/internal/provider/onepassword_item_resource_test.go @@ -119,6 +119,7 @@ func TestAccItemResourceSecureNote(t *testing.T) { resource.TestCheckResourceAttr("onepassword_item.test-secure-note", "title", expectedItem.Title), resource.TestCheckResourceAttr("onepassword_item.test-secure-note", "category", strings.ToLower(string(expectedItem.Category))), resource.TestCheckResourceAttr("onepassword_item.test-secure-note", "note_value", expectedItem.Fields[0].Value), + resource.TestCheckNoResourceAttr("onepassword_item.test-secure-note", "password"), ), }, }, diff --git a/internal/provider/test_http_server.go b/internal/provider/test_http_server.go index 9dad7c65..cb58a860 100644 --- a/internal/provider/test_http_server.go +++ b/internal/provider/test_http_server.go @@ -59,11 +59,13 @@ func setupTestServer(expectedItem *onepassword.Item, expectedVault onepassword.V } else if r.Method == http.MethodPost { if r.URL.String() == fmt.Sprintf("/v1/vaults/%s/items", expectedItem.Vault.ID) { itemToReturn := convertBodyToItem(r, t) - itemField := onepassword.ItemField{ - Label: "password", - Value: "somepassword", + if itemToReturn.Category != onepassword.SecureNote { + itemField := onepassword.ItemField{ + Label: "password", + Value: "somepassword", + } + itemToReturn.Fields = append(itemToReturn.Fields, &itemField) } - itemToReturn.Fields = append(itemToReturn.Fields, &itemField) itemToReturn.ID = expectedItem.ID itemBytes, err := json.Marshal(itemToReturn)