Skip to content

Commit

Permalink
Improve secure note test case
Browse files Browse the repository at this point in the history
We now check that the password attribute is set to null
  • Loading branch information
edif2008 committed May 30, 2024
1 parent 866dfce commit c99dfae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions internal/provider/onepassword_item_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand Down
10 changes: 6 additions & 4 deletions internal/provider/test_http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c99dfae

Please sign in to comment.