diff options
author | Ondrej Holy <oholy@redhat.com> | 2015-04-29 11:04:07 +0200 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2015-05-04 10:46:32 +0200 |
commit | 254151072b40ecb83eb8034dac12b5fe5b8896ab (patch) | |
tree | 131dc25aa271173739a80d5c32ca2885264a0207 /test | |
parent | fc1d50da79d1aea0bf73d53a97c6916f9b9639c2 (diff) | |
download | gvfs-254151072b40ecb83eb8034dac12b5fe5b8896ab.tar.gz |
tests: confirm unknown certificates for webdav
Commit f5ee590 introduces TLS certificate verifying for webdav. Uknown
certificates has to be confirmed by user during mount currenlty, thus
test cases for webdav over https have to also confirm the certificates.
https://bugzilla.gnome.org/show_bug.cgi?id=708306
Diffstat (limited to 'test')
-rwxr-xr-x | test/gvfs-test | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/test/gvfs-test b/test/gvfs-test index 715d90cb..5decf886 100755 --- a/test/gvfs-test +++ b/test/gvfs-test @@ -207,6 +207,27 @@ class GvfsTestCase(unittest.TestCase): # restore flags fcntl.fcntl(popen.stdout, fcntl.F_SETFL, flags) + def wait_for_question(self, popen): + '''Wait for a gvfs-mount Popen process to show an question prompt''' + + empty_timeout = 50 + + # set stdout to nonblocking + flags = fcntl.fcntl(popen.stdout, fcntl.F_GETFL) + fcntl.fcntl(popen.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK) + while True: + r = popen.stdout.read(1000) + if r and (b'Choice' in r): + break + + self.assertGreater(empty_timeout, 0, + 'timed out waiting for question prompt') + empty_timeout -= 1 + time.sleep(0.1) + + # restore flags + fcntl.fcntl(popen.stdout, fcntl.F_SETFL, flags) + def mount_api(self, gfile, mount_op=None): '''Mount a Gio.File using the Gio API @@ -1466,7 +1487,16 @@ DAVLockDB DAVLock '''davs://localhost without credentials''' uri = 'davs://localhost:4443/public' - subprocess.check_call(['gvfs-mount', uri]) + mount = subprocess.Popen(['gvfs-mount', uri], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + + # confirm unknown certificate + self.wait_for_question (mount); + mount.stdin.write(b'1\n') + mount.stdin.flush() + self.do_mount_check(uri, 'hello.txt', 'hi\n') def test_http_auth(self): @@ -1501,6 +1531,11 @@ DAVLockDB DAVLock stdout=subprocess.PIPE, stderr=subprocess.PIPE) + # confirm unknown certificate + self.wait_for_question (mount); + mount.stdin.write(b'1\n') + mount.stdin.flush() + # wrong password self.wait_for_gvfs_mount_user_prompt(mount) mount.stdin.write(b'test\nh4ck\n') |