aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael Albinus2017-10-25 13:36:49 +0200
committerMichael Albinus2017-10-25 13:36:49 +0200
commit761c630766abf5b59c9b8c8f6edde07b276ea4b4 (patch)
tree33b27342de1423fa265d77b20aadb6e014343f38 /test
parent628b65320953ff5333b332e9010c16941cba177f (diff)
downloademacs-761c630766abf5b59c9b8c8f6edde07b276ea4b4.tar.gz
emacs-761c630766abf5b59c9b8c8f6edde07b276ea4b4.zip
Fix Bug#28982
* admin/MAINTAINERS: Add test/lisp/url/url-tramp-tests.el. * lisp/url/url-tramp.el (url-tramp-convert-url-to-tramp) (url-tramp-convert-tramp-to-url): Adapt to recent Tramp changes. * test/lisp/url/url-tramp-tests.el: New file. (Bug#28982)
Diffstat (limited to 'test')
-rw-r--r--test/lisp/url/url-tramp-tests.el83
1 files changed, 83 insertions, 0 deletions
diff --git a/test/lisp/url/url-tramp-tests.el b/test/lisp/url/url-tramp-tests.el
new file mode 100644
index 00000000000..9892cd78475
--- /dev/null
+++ b/test/lisp/url/url-tramp-tests.el
@@ -0,0 +1,83 @@
1;;; url-tramp-tests.el --- Test suite for Tramp / URL conversion.
2
3;; Copyright (C) 2017 Free Software Foundation, Inc.
4
5;; Author: Michael Albinus <michael.albinus@gmx>
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
21
22;;; Code:
23
24(require 'url-tramp)
25(require 'ert)
26
27(ert-deftest url-tramp-test-convert-url-to-tramp ()
28 "Test that URLs are converted into proper Tramp file names."
29 (should
30 (string-equal
31 (url-tramp-convert-url-to-tramp "ftp://ftp.is.co.za/rfc/rfc1808.txt")
32 "/ftp:ftp.is.co.za:/rfc/rfc1808.txt"))
33
34 (should
35 (string-equal
36 (url-tramp-convert-url-to-tramp "ssh://user@localhost")
37 "/ssh:user@localhost:"))
38
39 (should
40 (string-equal
41 (url-tramp-convert-url-to-tramp "telnet://remotehost:42")
42 "/telnet:remotehost#42:"))
43
44 ;; The password will be added to the cache. The password cache key
45 ;; is the remote file name identification of the Tramp file.
46 (should
47 (string-equal
48 (url-tramp-convert-url-to-tramp "scp://user:geheim@somewhere/localfile")
49 "/scp:user@somewhere:/localfile"))
50 (let ((key
51 (file-remote-p
52 (url-tramp-convert-url-to-tramp "scp://user@somewhere/localfile"))))
53 (should (password-in-cache-p key))
54 (should (string-equal (password-read-from-cache key) "geheim"))
55 (password-cache-remove key)
56 (should-not (password-in-cache-p key)))
57
58 ;; "http" does not belong to `url-tramp-protocols'.
59 (should-not (url-tramp-convert-url-to-tramp "http://www.gnu.org")))
60
61(ert-deftest url-tramp-test-convert-tramp-to-url ()
62 "Test that Tramp file names are converted into proper URLs."
63 (should
64 (string-equal
65 (url-tramp-convert-tramp-to-url "/ftp:ftp.is.co.za:/rfc/rfc1808.txt")
66 "ftp://ftp.is.co.za/rfc/rfc1808.txt"))
67
68 (should
69 (string-equal
70 (url-tramp-convert-tramp-to-url "/ssh:user@localhost:")
71 "ssh://user@localhost"))
72
73 (should
74 (string-equal
75 (url-tramp-convert-tramp-to-url "/telnet:user@remotehost#42:")
76 "telnet://user@remotehost:42"))
77
78 ;; "sftp" does not belong to `url-tramp-protocols'.
79 (should-not (url-tramp-convert-tramp-to-url "/sftp:user@localhost:")))
80
81(provide 'url-tramp-tests)
82
83;;; url-tramp-tests.el ends here