None (to disable), zlib and bz2 (default: zlib)
:backup_swift_ca_cert_file: The location of the CA certificate file to use
for swift client requests (default: None)
+:backup_swift_auth_insecure: If true, bypass verification of server's
+ certificate for SSL connections (default: False)
"""
import hashlib
default=None,
help='Location of the CA certificate file to use for swift '
'client requests.'),
+ cfg.BoolOpt('backup_swift_auth_insecure',
+ default=False,
+ help='Bypass verification of server certificate when '
+ 'making SSL connection to Swift.'),
]
CONF = cfg.CONF
self.swift_backoff = CONF.backup_swift_retry_backoff
LOG.debug('Connect to %s in "%s" mode', CONF.backup_swift_url,
CONF.backup_swift_auth)
+ self.backup_swift_auth_insecure = CONF.backup_swift_auth_insecure
if CONF.backup_swift_auth == 'single_user':
if CONF.backup_swift_user is None:
LOG.error(_LE("single_user auth mode enabled, "
key=CONF.backup_swift_key,
retries=self.swift_attempts,
starting_backoff=self.swift_backoff,
+ insecure=self.backup_swift_auth_insecure,
cacert=CONF.backup_swift_ca_cert_file)
else:
self.conn = swift.Connection(retries=self.swift_attempts,
preauthurl=self.swift_url,
preauthtoken=self.context.auth_token,
starting_backoff=self.swift_backoff,
+ insecure= (
+ self.backup_swift_auth_insecure),
cacert=CONF.backup_swift_ca_cert_file)
class SwiftObjectWriter(object):
"""
import bz2
+import ddt
import filecmp
import hashlib
import os
CONF = cfg.CONF
+ANY = mock.ANY
+
def fake_md5(arg):
class result(object):
return ret
+@ddt.ddt
class BackupSwiftTestCase(test.TestCase):
"""Test Case for swift."""
swift_dr.SwiftBackupDriver,
self.ctxt)
+ @ddt.data(
+ {'auth': 'single_user', 'insecure': True},
+ {'auth': 'single_user', 'insecure': False},
+ {'auth': 'per_user', 'insecure': True},
+ {'auth': 'per_user', 'insecure': False},
+ )
+ @ddt.unpack
+ def test_backup_swift_auth_insecure(self, auth, insecure):
+ self.override_config("backup_swift_auth_insecure", insecure)
+ self.override_config('backup_swift_auth', auth)
+ if auth == 'single_user':
+ self.override_config('backup_swift_user', 'swift-user')
+
+ mock_connection = self.mock_object(swift, 'Connection')
+
+ swift_dr.SwiftBackupDriver(self.ctxt)
+
+ if auth == 'single_user':
+ mock_connection.assert_called_once_with(insecure=insecure,
+ authurl=ANY,
+ auth_version=ANY,
+ tenant_name=ANY,
+ user=ANY,
+ key=ANY,
+ retries=ANY,
+ starting_backoff=ANY,
+ cacert=ANY)
+ else:
+ mock_connection.assert_called_once_with(insecure=insecure,
+ retries=ANY,
+ preauthurl=ANY,
+ preauthtoken=ANY,
+ starting_backoff=ANY,
+ cacert=ANY)
+
def test_backup_uncompressed(self):
self._create_backup_db_entry()
self.flags(backup_compression_algorithm='none')