[DesktopExecParser] Open {ssh,telnet,rlogin}:// urls with ktelnetservice
ClosedPublic

Authored by ahmadsamir on Mar 12 2020, 6:58 AM.

Details

Summary

Extend krununittest to test ktelnetservice.

Test Plan

$ kde-open5 ssh://user@1.1.1.1

outputs:
command= "ktelnetservice5 %u" args= ("ktelnetservice5 %u", "ssh://user@1.1.1.1")
kf5.kio.core: couldn't create slave: "klauncher said: Unknown protocol 'ssh'.\n"

and you get a message box with "File not found: ssh://user@1.1.1.1".

Apply diff then try again, now a terminal window is launched by
ktelnetservice5 and ssh is invoked as expected.

BUG: 418258

FIXED-IN: 5.69

Diff Detail

Repository
R241 KIO
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ahmadsamir created this revision.Mar 12 2020, 6:58 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptMar 12 2020, 6:58 AM
ahmadsamir requested review of this revision.Mar 12 2020, 6:58 AM

FTR, I don't have access to any smb:// servers, so couldn't test the KIOFuse stuff.

Tested fuse and it works as expected. Code looks reasonable, but I have little expertise with this class.
@feverfew probably ought to comment as well since he introduced the fuse code.

I'll review this when I have a chance (sometime this week).

Thanks for the unittest with the fix.

autotests/krununittest.cpp
238

QFINDTESTDATA() is more flexible than a solution like CMAKE_SOURCE_DIR [e.g. it allows deploying unittests to android devices]. It's also simpler to use (no buildsystem change).

ahmadsamir updated this revision to Diff 77520.Mar 12 2020, 9:19 PM
ahmadsamir edited the summary of this revision. (Show Details)
ahmadsamir removed a reviewer: feverfew.
ahmadsamir removed a subscriber: feverfew.

Address comments, use QFINDTESTDATA()

ahmadsamir updated this revision to Diff 77521.Mar 12 2020, 9:21 PM
ahmadsamir added a reviewer: feverfew.

Tweak

dfaure requested changes to this revision.Mar 12 2020, 9:23 PM
dfaure added inline comments.
autotests/krununittest.cpp
238

Good practice is to follow that with QVERIFY(!ktelnet.isEmpty());

245

Wait, I didn't notice before, but this is broken.
On my system it's in another prefix.
On Windows it won't be in /usr/bin either.
You need to either strip out the path, or use QStandardPaths::findExecutable("ktelnetservice5") in an arg() for that expected value.

This revision now requires changes to proceed.Mar 12 2020, 9:23 PM
ahmadsamir updated this revision to Diff 77533.Mar 13 2020, 6:25 AM
  • Use QStandardPaths::findExecutable(), as the path isn't hardcoded to /usr/bin/ on all systems
  • More QVERIFY()
ahmadsamir marked 3 inline comments as done.Mar 13 2020, 6:26 AM

Thanks, looks better. One possible problem left: if KIO has never been installed, I guess QStandardPaths::findExecutable(QStringLiteral("ktelnetservice5")) won't find it in builddir/bin.

You could push and see what CI says, or you could test locally what happens when running this test method with PATH=/does/not/exist.
It seems to me that desktopexecparser.cpp won't find it then, which should probably be fixed with a fallback to "if it exists in QCoreApplication::applicationDirPath(), use that" -- and then the unittest can do the same.

meven added a comment.Mar 13 2020, 8:01 AM

Good to me

ahmadsamir updated this revision to Diff 77538.Mar 13 2020, 9:15 AM

As pointed out by dfaure, we have to make sure the unit test passes even if KIO isn't installed (which might be the case on the KDE CI system). Since we aren't actually executing the ktelnetservice5 binary and only checking what DesktopExecParser will try to use, this should work.

don't merge yet, looking at the code I sense something might break here but I need some time to do my own testing first.

Friendly ping.

dfaure accepted this revision.Mar 18 2020, 9:26 PM

OK with me, but check with the fuse people.

You test ssh, telnet etc but hasSchemeHandler is also true for at least http.

This revision is now accepted and ready to land.Mar 18 2020, 9:26 PM

OK with me, but check with the fuse people.

You test ssh, telnet etc but hasSchemeHandler is also true for at least http.

While I was debugging this issue, I found that the code gets here starting from this runApplication() call https://cgit.kde.org/kio.git/tree/src/widgets/krun.cpp#n843, which, IIUC, means that "http" is caught in KRun::init() before we ever get here.

Rebase on master

Only if an external browser is set, but yeah.

Only if an external browser is set, but yeah.

Right, I missed the bit about the external browser; however with the recent change to fallback to mimeapps.list if external browser is empty, it "should" be OK...

feverfew accepted this revision.Mar 19 2020, 7:14 PM
feverfew added a reviewer: ngraham.
feverfew added a subscriber: ngraham.

Quick testing with fish protocol doesn't break anything KIOFuse side. Going to page in @ngraham, if it works for him with smb it's an all good from the "KIOFuse people" ;)

Sorry for the delay!

ngraham accepted this revision.Mar 19 2020, 7:27 PM

Quick testing with fish protocol doesn't break anything KIOFuse side. Going to page in @ngraham, if it works for him with smb it's an all good from the "KIOFuse people" ;)

Sorry for the delay!

No problem. :)

This revision was automatically updated to reflect the committed changes.
This comment was removed by ahmadsamir.