summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-08-12 15:38:32 +0200
committerMartin Kosek <mkosek@redhat.com>2013-08-13 15:42:48 +0200
commita8d2ec6677d97907c84751242620a3198484dc7b (patch)
treefa92728edf6308e659f38e87981f2a58c924f67b
parentb1474a53c0c249b5090fb067a3cdf99316989afe (diff)
downloadfreeipa.git-a8d2ec6677d97907c84751242620a3198484dc7b.tar.gz
freeipa.git-a8d2ec6677d97907c84751242620a3198484dc7b.tar.xz
freeipa.git-a8d2ec6677d97907c84751242620a3198484dc7b.zip
Allow freeipa-tests to work with older paramiko versions
The integration testing framework used Paramiko SFTP files as context managers. This feature is only available in Paramiko 1.10+. Use an explicit context manager so that we don't rely on the feature.
-rw-r--r--freeipa.spec.in5
-rw-r--r--ipatests/test_integration/host.py20
2 files changed, 22 insertions, 3 deletions
diff --git a/freeipa.spec.in b/freeipa.spec.in
index bffd95e1..46a2ae02 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -304,7 +304,7 @@ Requires: python-nose
Requires: python-paste
Requires: python-coverage
Requires: python-polib
-Requires: python-paramiko >= 1.10.1
+Requires: python-paramiko >= 1.7.7
%description tests
IPA is an integrated solution to provide centrally managed Identity (machine,
@@ -833,6 +833,9 @@ fi
%endif # ONLY_CLIENT
%changelog
+* Mon Aug 12 2013 Petr Viktorin <pviktori@redhat.com> - 3.3.90-1
+- Downgrade required version of python-paramiko for the tests subpackage
+
* Thu Aug 8 2013 Martin Kosek <mkosek@redhat.com> - 3.2.99-13
- Require slapi-nis 0.47.7 and sssd 1.11.0-0.1.beta2 required for core
features of 3.3.0 release
diff --git a/ipatests/test_integration/host.py b/ipatests/test_integration/host.py
index b4c7ffd6..1614b5fd 100644
--- a/ipatests/test_integration/host.py
+++ b/ipatests/test_integration/host.py
@@ -23,6 +23,7 @@ import os
import socket
import threading
import subprocess
+from contextlib import contextmanager
import errno
import paramiko
@@ -118,6 +119,21 @@ class RemoteCommand(object):
return thread
+@contextmanager
+def sftp_open(sftp, filename, mode='r'):
+ """Context manager that provides a file-like object over a SFTP channel
+
+ This provides compatibility with older Paramiko versions.
+ (In Paramiko 1.10+, file objects from `sftp.open` are directly usable as
+ context managers).
+ """
+ file = sftp.open(filename, mode)
+ try:
+ yield file
+ finally:
+ file.close()
+
+
class Host(object):
"""Representation of a remote IPA host"""
def __init__(self, domain, hostname, role, index, ip=None):
@@ -314,13 +330,13 @@ class Host(object):
def get_file_contents(self, filename):
"""Read the named remote file and return the contents as a string"""
self.log.debug('READ %s', filename)
- with self.sftp.open(filename) as f:
+ with sftp_open(self.sftp, filename) as f:
return f.read()
def put_file_contents(self, filename, contents):
"""Write the given string to the named remote file"""
self.log.info('WRITE %s', filename)
- with self.sftp.open(filename, 'w') as f:
+ with sftp_open(self.sftp, filename, 'w') as f:
f.write(contents)
def file_exists(self, filename):