diff --git a/onepassword/items.go b/onepassword/items.go index fd40309..a383ebb 100644 --- a/onepassword/items.go +++ b/onepassword/items.go @@ -71,7 +71,7 @@ type Item struct { UpdatedAt time.Time `json:"updatedAt,omitempty"` // Deprecated: Connect does not return trashed items. - Trashed bool `json:"trashed,omitempty"` + Trashed bool `json:"trashed,omitempty"` } // ItemVault represents the Vault the Item is found in @@ -108,9 +108,10 @@ type ItemField struct { Generate bool `json:"generate,omitempty"` Recipe *GeneratorRecipe `json:"recipe,omitempty"` Entropy float64 `json:"entropy,omitempty"` + TOTP string `json:"totp,omitempty"` } -// Get Retrieve the value of a field on the item by its label. To specify a +// GetValue Retrieve the value of a field on the item by its label. To specify a // field from a specific section pass in
.. If // no field matching the selector is found return "". func (i *Item) GetValue(field string) string { diff --git a/onepassword/items_test.go b/onepassword/items_test.go index 16830a9..b3222df 100644 --- a/onepassword/items_test.go +++ b/onepassword/items_test.go @@ -9,6 +9,7 @@ import ( var testUsernmae = "user123" var testPassword = "Password2!" var testOther = "Test Value" +var testTOTP = "154626" func TestItemGetValuePassword(t *testing.T) { login := testLogin() @@ -52,6 +53,19 @@ func TestItemGetValueMissingField(t *testing.T) { } } +func TestItemGetTOTP(t *testing.T) { + login := testLogin() + + for _, field := range login.Fields { + if field.Type == "OTP" { + if field.TOTP != "154626" { + t.Logf("Expected other value %q, found %q", testTOTP, field.TOTP) + t.FailNow() + } + } + } +} + func testLogin() *Item { sectionUUID := uuid.New().String() return &Item{ @@ -94,6 +108,13 @@ func testLogin() *Item { Label: "other", Value: testOther, }, + { + ID: "TOTP_c624e90aae964fdaa829517c24", + Type: "OTP", + Label: "one-time password", + Value: "otpauth://totp/testop?secret=totpcode", + TOTP: "154626", + }, }, } }