Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature to handle field references, resolves #75 #370

Merged
merged 3 commits into from
Mar 5, 2017
Merged

Add feature to handle field references, resolves #75 #370

merged 3 commits into from
Mar 5, 2017

Conversation

mrrsm
Copy link
Contributor

@mrrsm mrrsm commented Mar 3, 2017

Description

  • Create popup for clone options
  • Add ability to resolve references for title, username, password, url, notes, and uuid fields when using autotype, http, and/or copying

Motivation and Context

Allows references to be used across all fields for autotype, http, and copying
Resolves #75

How Has This Been Tested?

Created multiple clones of different entries
Tested http by removing the url from the original and having chromeIPass fill the appropriate data
Tested inline copy/paste by manually editing all supported fields and using the context menu to copy the values
Tested autotype similar to http by cloning a working entry and removing the association from the original

Screenshots (if appropriate):

May/or may not be helpful but this shows the different states of the clone process

ysyunrq

jg9vihl

zqtzixx

Types of changes

  • ✅ New feature (non-breaking change which adds functionality)

Checklist:

  • ✅ I have read the CONTRIBUTING document.
  • ✅ My code follows the code style of this project.
  • ✅ All new and existing tests passed.

@phoerious
Copy link
Member

I added the screenshots directly to your post.

@phoerious phoerious added this to the v2.2.0 milestone Mar 3, 2017
@TheZ3ro
Copy link
Contributor

TheZ3ro commented Mar 4, 2017

Travis gui-tests are failing

Running tests...
Test project /home/travis/build/keepassxreboot/keepassxc/build
    Start 22: testgui
1/2 Test #22: testgui ..........................***Failed   10.98 sec
********* Start testing of TestGui *********
Config: Using QtTest library 5.2.1, Qt 5.2.1
FAIL!  : TestGui::testCloneEntry() Compared values are not the same
   Actual   (entryView->model()->rowCount()): 1
   Expected (2)                             : 2
   Loc: [/home/travis/build/keepassxreboot/keepassxc/tests/gui/TestGui.cpp(566)]
Totals: 17 passed, 1 failed, 0 skipped
********* Finished testing of TestGui *********

@mrrsm
Copy link
Contributor Author

mrrsm commented Mar 4, 2017

Can someone provide some insight into how I can test a QDialog box?
The two things I have tried so far were changing the show() to an exec() for the clone entry slot but that causes the test to just hang as I can't pass in an input to the dialog box. Leaving it as it currently is with the show() seems to have it not do anything?

@phoerious
Copy link
Member

Generally, you use QTest::keyClick() for that.

@mrrsm
Copy link
Contributor Author

mrrsm commented Mar 4, 2017

For example in DatabaseWidget.cpp if I have the following and I run the tests I do not even see the popup window show up as far as I can tell.

CloneDialog* cloneDialog = new CloneDialog(this, m_db, currentEntry);
cloneDialog->show();

However if I still try adding the key click after the triggerAction in the unit test it still fails.

QTest::keyClick(m_mainWindow, Qt::Key_Enter);

My guess there is it is due to me sending the key press to the main window and not the dialog box which pops up.

That lead me to trying it with an exec rather then a show for the cloneDialog. That seems to show the popup however it just freezes waiting for input.

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Mar 4, 2017

@mrrsm I've made a little patch for you (since I've nothing to do 😄 ) based on your last commit in this PR.
Every dialog called from a parent can be retrived with the findChild() function.
The Widget name is declared in src/gui/CloneDialog.ui line 4

diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp
index 0c776e0..a49590e 100644
--- a/tests/gui/TestGui.cpp
+++ b/tests/gui/TestGui.cpp
@@ -45,6 +45,7 @@
 #include "format/KeePass2Reader.h"
 #include "gui/DatabaseTabWidget.h"
 #include "gui/DatabaseWidget.h"
+#include "gui/CloneDialog.h"
 #include "gui/FileDialog.h"
 #include "gui/MainWindow.h"
 #include "gui/MessageBox.h"
@@ -563,6 +564,10 @@ void TestGui::testCloneEntry()
 
     triggerAction("actionEntryClone");
 
+    CloneDialog* cloneDialog = m_dbWidget->findChild<CloneDialog*>("CloneDialog");
+    QDialogButtonBox* cloneButtonBox = cloneDialog->findChild<QDialogButtonBox*>("buttonBox");
+    QTest::mouseClick(cloneButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
+
     QCOMPARE(entryView->model()->rowCount(), 2);
     Entry* entryClone = entryView->entryFromIndex(entryView->model()->index(1, 1));
     QVERIFY(entryOrg->uuid() != entryClone->uuid());

@mrrsm
Copy link
Contributor Author

mrrsm commented Mar 4, 2017

@TheZ3ro Thanks, I will give this another go tonight and hopefully get the tests working again

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Mar 4, 2017

@mrrsm with that patch tests sould be good. Since there are conflict with DatabaseWidget,cpp can you rebase your changes on the current develop? Thanks

  - Create popup for clone options
  - Add ability to resolve references for autotype/http/copying
@mrrsm
Copy link
Contributor Author

mrrsm commented Mar 5, 2017

Thanks for the patch @TheZ3ro
I was thrown for a loop as I was trying to do that off of the main window rather than the db widget and getting nowhere.

@TheZ3ro TheZ3ro merged commit 1e1428c into keepassxreboot:develop Mar 5, 2017
@droidmonkey
Copy link
Member

Great work @mrrsm

Copy link

@ftes ftes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference is not resolved after cloning an entry.
Problem: source entry has a lower-case UUID, while the reference uses an upper-case UUID.

}

if (flags & ClonePassAsRef) {
QString password = "{REF:P@I:" + m_uuid.toHex() + "}";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem: toHex() seems to give upper case UUID. If the UUID of the source entry is lowercase, resolvePlaceholder will fail.

Copy link

@Darksider3 Darksider3 Jun 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QString username = "{REF:U@I:" + m_uuid.toHex() + "}";
+        entry->m_attributes->set(EntryAttributes::UserNameKey, username.toUpper(), m_attributes->isProtected(EntryAttributes::UserNameKey));

Am i misinterpreting that, or do u simply uppercase the username at line 501? Just remove it? Or is the problem that different locations have different behaviours?

EDIT:// I mean, username.toUpper() must do something like that..^^

droidmonkey added a commit that referenced this pull request Jun 25, 2017
- Added YubiKey 2FA integration for unlocking databases [#127]
- Added TOTP support [#519]
- Added CSV import tool [#146, #490]
- Added KeePassXC CLI tool [#254]
- Added diceware password generator [#373]
- Added support for entry references [#370, #378]
- Added support for Twofish encryption [#167]
- Enabled DEP and ASLR for in-memory protection [#371]
- Enabled single instance mode [#510]
- Enabled portable mode [#645]
- Enabled database lock on screensaver and session lock [#545]
- Redesigned welcome screen with common features and recent databases [#292]
- Multiple updates to search behavior [#168, #213, #374, #471, #603, #654]
- Added auto-type fields {CLEARFIELD}, {SPACE}, {{}, {}} [#267, #427, #480]
- Fixed auto-type errors on Linux [#550]
- Prompt user prior to executing a cmd:// URL [#235]
- Entry attributes can be protected (hidden) [#220]
- Added extended ascii to password generator [#538]
- Added new database icon to toolbar [#289]
- Added context menu entry to empty recycle bin in databases [#520]
- Added "apply" button to entry and group edit windows [#624]
- Added macOS tray icon and enabled minimize on close [#583]
- Fixed issues with unclean shutdowns [#170, #580]
- Changed keyboard shortcut to create new database to CTRL+SHIFT+N [#515]
- Compare window title to entry URLs [#556]
- Implemented inline error messages [#162]
- Ignore group expansion and other minor changes when making database "dirty" [#464]
- Updated license and copyright information on souce files [#632]
- Added contributors list to about dialog [#629]
@JetUni
Copy link

JetUni commented Jun 5, 2020

Where is the option to add a reference to an existing entry? I can't seem to find it anywhere

@mrrsm
Copy link
Contributor Author

mrrsm commented Jun 5, 2020

@JetUni There currently isn't a way via the UI to copy the reference of another entry from the entry you want the reference on. You can get the uuid from the properties section on the entry you want to reference and then manually create the reference link on the new entry.

The other option is to clone an existing entry and check the "Replace username and password with references" option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Add support for basic references in autotype
7 participants