fixes #7918 - onepassword lookup fails if field name contains uppercase letters and section is specified (#7919)

* fix #7918

* Update plugins/lookup/onepassword.py

Co-authored-by: Sam Doran <github@samdoran.com>

* onepassword lookup: transform field ids to lowercase

* #7918: added unit tests

* #7919: add changelog fragment

* Update changelogs/fragments/7919-onepassword-fieldname-casing.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Sam Doran <github@samdoran.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Benjamin Mitzkus 2024-02-16 13:53:07 +01:00 committed by GitHub
commit 6088e2dc0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 277 additions and 2 deletions

View file

@ -123,5 +123,173 @@ MOCK_ENTRIES = {
"expected": [""],
"output": load_file("v2_out_04.json")
},
{
# Query item without section by lowercase id (case matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "lowercaseid",
},
"expected": ["lowercaseid"],
"output": load_file("v2_out_05.json")
},
{
# Query item without section by lowercase id (case not matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "LOWERCASEID",
},
"expected": ["lowercaseid"],
"output": load_file("v2_out_05.json")
},
{
# Query item without section by lowercase label (case matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "lowercaselabel",
},
"expected": ["lowercaselabel"],
"output": load_file("v2_out_05.json")
},
{
# Query item without section by lowercase label (case not matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "LOWERCASELABEL",
},
"expected": ["lowercaselabel"],
"output": load_file("v2_out_05.json")
},
{
# Query item without section by mixed case id (case matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "MiXeDcAsEiD",
},
"expected": ["mixedcaseid"],
"output": load_file("v2_out_05.json")
},
{
# Query item without section by mixed case id (case not matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "mixedcaseid",
},
"expected": ["mixedcaseid"],
"output": load_file("v2_out_05.json")
},
{
# Query item without section by mixed case label (case matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "MiXeDcAsElAbEl",
},
"expected": ["mixedcaselabel"],
"output": load_file("v2_out_05.json")
},
{
# Query item without section by mixed case label (case not matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "mixedcaselabel",
},
"expected": ["mixedcaselabel"],
"output": load_file("v2_out_05.json")
},
{
# Query item with section by lowercase id (case matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "sectionlowercaseid",
"section": "section-with-values",
},
"expected": ["sectionlowercaseid"],
"output": load_file("v2_out_05.json")
},
{
# Query item with section by lowercase id (case not matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "SECTIONLOWERCASEID",
"section": "section-with-values",
},
"expected": ["sectionlowercaseid"],
"output": load_file("v2_out_05.json")
},
{
# Query item with section by lowercase label (case matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "sectionlowercaselabel",
"section": "section-with-values",
},
"expected": ["sectionlowercaselabel"],
"output": load_file("v2_out_05.json")
},
{
# Query item with section by lowercase label (case not matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "SECTIONLOWERCASELABEL",
"section": "section-with-values",
},
"expected": ["sectionlowercaselabel"],
"output": load_file("v2_out_05.json")
},
{
# Query item with section by lowercase id (case matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "SeCtIoNmIxEdCaSeId",
"section": "section-with-values",
},
"expected": ["sectionmixedcaseid"],
"output": load_file("v2_out_05.json")
},
{
# Query item with section by lowercase id (case not matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "sectionmixedcaseid",
"section": "section-with-values",
},
"expected": ["sectionmixedcaseid"],
"output": load_file("v2_out_05.json")
},
{
# Query item with section by lowercase label (case matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "SeCtIoNmIxEdCaSeLaBeL",
"section": "section-with-values",
},
"expected": ["sectionmixedcaselabel"],
"output": load_file("v2_out_05.json")
},
{
# Query item with section by lowercase label (case not matching)
"vault_name": "Test Vault",
"queries": ["LabelCasing"],
"kwargs": {
"field": "sectionmixedcaselabel",
"section": "section-with-values",
},
"expected": ["sectionmixedcaselabel"],
"output": load_file("v2_out_05.json")
},
],
}