[gvfs] tests: confirm unknown certificates for webdav
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] tests: confirm unknown certificates for webdav
- Date: Mon, 4 May 2015 08:47:29 +0000 (UTC)
commit 254151072b40ecb83eb8034dac12b5fe5b8896ab
Author: Ondrej Holy <oholy redhat com>
Date: Wed Apr 29 11:04:07 2015 +0200
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
test/gvfs-test | 37 ++++++++++++++++++++++++++++++++++++-
1 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/test/gvfs-test b/test/gvfs-test
index 715d90c..5decf88 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')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]