예제 #1
0
 def test_device_notfound(self):
     o = Object()
     o.name = None
     self._init_global_admin(get_multi_response=o)
     with self.assertRaises(exception.CTERAException) as error:
         devices.Devices(self._global_admin).device(o.name)
     self.assertEqual('Device not found', error.exception.message)
예제 #2
0
 def _get_nfs_configuration_response(async_write=True,
                                     aggregate_writes=True):
     obj = Object()
     obj.mode = Mode.Enabled
     setattr(obj, 'async', Mode.Enabled if async_write else Mode.Disabled)
     obj.aggregateWrites = Mode.Enabled if aggregate_writes else Mode.Disabled
     return obj
예제 #3
0
 def _get_pending_mount_task(mount_id=None, name=None):
     param = Object()
     if mount_id:
         param.id = mount_id
     if name:
         param.name = name
     return param
예제 #4
0
 def _get_volumes_response_param(self):
     storage_volumes = []
     for volume_name in self._volumes:
         param = Object()
         param.name = volume_name
         storage_volumes.append(param)
     return storage_volumes
예제 #5
0
 def test_modify_raise(self):
     param = Object()
     param.mode = Mode.Disabled
     self._init_filer(get_response=param)
     with self.assertRaises(exception.CTERAException) as error:
         ftp.FTP(self._filer).modify()
     self.assertEqual('FTP must be enabled in order to modify its configuration', error.exception.message)
예제 #6
0
 def _get_cifs_object(self, enable_aio):
     robust_mutexes, aio_read_threshold, aio_write_threshold = self._enable_aio if enable_aio else self._disable_aio
     cifs_param = Object()
     cifs_param.robustMutexes = robust_mutexes
     cifs_param.aioReadThreshold = aio_read_threshold
     cifs_param.aioWriteThreshold = aio_write_threshold
     return cifs_param
예제 #7
0
 def test_modify_smb_disabled_raise(self):
     param = Object()
     param.mode = Mode.Disabled
     self._init_filer(get_response=param)
     with self.assertRaises(exception.CTERAException) as error:
         smb.SMB(self._filer).modify(CIFSPacketSigning.Required)
     self.assertEqual('SMB must be enabled in order to modify its configuration', error.exception.message)
 def _get_domain_join_param(self, ou=None):
     o = Object()
     o.username = self._username
     o.password = self._password
     if ou is not None:
         o.ouPath = ou
     return o
예제 #9
0
 def _find_cloud_folder(folder_name, folder_owner, include):
     # pylint: disable=unused-argument
     folder_info = TestCoreZones._cloud_folders[folder_owner][folder_name]
     param = Object()
     param.uid = folder_info['uid']
     param.owner = folder_info['owner']
     return param
예제 #10
0
 def _get_device_objects(self):
     devices = []
     for device_id in self._device_ids:
         param = Object()
         param.uid = device_id
         devices.append(param)
     return devices
예제 #11
0
 def _get_create_folder_param(passphrase=None):
     param = Object()
     if passphrase:
         param.encryptionMode = backup.EncryptionMode.Secret
         param.sharedSecret = passphrase
     else:
         param.encryptionMode = backup.EncryptionMode.Recoverable
     return param
예제 #12
0
 def _get_default_backup_settings(encryption_mode=None,
                                  shared_secret=None,
                                  passphrase_salt=None):
     param = Object()
     param.encryptionMode = encryption_mode
     param.sharedSecret = shared_secret
     param.passPhraseSalt = passphrase_salt
     return param
예제 #13
0
    def test_format_drive(self):
        self._init_filer()
        drive.Drive(self._filer).format(self._drive_name)
        self._filer.execute.assert_called_once_with('/proc/storage', 'format', mock.ANY)

        expected_param = Object()
        expected_param.name = self._drive_name
        actual_param = self._filer.execute.call_args[0][2]
        self._assert_equal_objects(actual_param, expected_param)
예제 #14
0
 def _get_init_replication_param(replicate_from=None):
     params = Object()
     params._classname = 'SetReplicationParam'  # pylint: disable=protected-access
     if replicate_from:
         params.enabledReplicationParam = Object()
         params.enabledReplicationParam._classname = 'EnabledReplicationParam'  # pylint: disable=protected-access
         params.enabledReplicationParam.replicationOf = replicate_from
         params.enabledReplicationParam.restartDB = True
     return params
 def test_domains(self):
     domain = Object()
     domain.flatName = self._domain_flat_name
     execute_response = [domain]
     self._init_filer(execute_response=execute_response)
     ret = directoryservice.DirectoryService(self._filer).domains()
     self._filer.execute.assert_called_once_with(
         '/status/fileservices/cifs', 'enumDiscoveredDomains')
     self.assertEqual(ret[0], self._domain_flat_name)
 def _fetch_resources_side_effect(path, name, param):
     # pylint: disable=unused-argument
     response = Object()
     response.items = []
     if param.start == 0:
         response.hasMore = True
         return BaseCoreServicesFilesList._fetch_resources_response(response, BaseCoreServicesFilesList.files[0])
     response.hasMore = False
     return BaseCoreServicesFilesList._fetch_resources_response(response, BaseCoreServicesFilesList.files[1])
 def _obtain_session_info(path):
     if path == '/currentPortal':
         return TestCoreLogin._tenant
     if path == '/currentSession':
         current_session = Object()
         current_session.username = TestCoreLogin._username
         current_session.role = TestCoreLogin._password
         return current_session
     return ''
예제 #18
0
    def test_format_all_drives(self):
        self._init_filer(get_response=self._get_drives_param())
        drive.Drive(self._filer).format_all()
        self._filer.get.assert_called_once_with('/status/storage/disks')

        expected_param = Object()
        expected_param.name = self._drive_name
        actual_param = self._filer.execute.call_args[0][2]
        self._assert_equal_objects(actual_param, expected_param)
 def _get_list_physical_folders_response_object(self,
                                                name=None,
                                                fullpath=None):
     list_physical_folders_response = Object()
     list_physical_folders_response.name = self._share_volume if name is None else name
     list_physical_folders_response.type = 'some type'
     list_physical_folders_response.fullpath = (
         self._root + self._share_volume) if fullpath is None else fullpath
     return [list_physical_folders_response]
 def test_modify_raise(self):
     param = Object()
     param.mode = Mode.Disabled
     self._init_filer(get_response=param)
     with self.assertRaises(exception.CTERAException) as error:
         syslog.Syslog(self._filer).modify()
     self.assertEqual(
         'Syslog configuration cannot be modified when disabled',
         error.exception.message)
    def test_first_user_already_exists(self):
        info = Object()
        info.isfirstlogin = False
        self._init_filer(get_response=info)

        users.Users(self._filer).add_first_user(self._username, self._password)
        self._filer.get.assert_called_once_with('/nosession/logininfo')
        self._filer.post.assert_not_called()
        self._login_mock.assert_called_once_with(self._username,
                                                 self._password)
 def _get_services_connection_status(self):
     param = Object()
     param.connection = Object()
     param.connected = True
     param.ipaddr = self._ip_address
     param.user = self._user_display_name
     param.server_version = self._portal_version
     param.server_address = self._server_address
     param.last_connected_at = self._last_connnected_at
     return param
 def test_get_connected_domain(self):
     obj = Object()
     obj.type = 'domain'
     obj.domain = self._domain
     obj.workgroup = None
     self._init_filer(get_response=obj)
     ret = directoryservice.DirectoryService(
         self._filer).get_connected_domain()
     self._filer.get.assert_called_once_with('/config/fileservices/cifs')
     self._assert_equal_objects(ret, obj)
예제 #24
0
    def test_connection_success(self):
        get_response = Object()
        get_response.hostname = self._filer.host()
        self._init_filer(get_response=get_response)
        self._socket_connect_mock.return_value = 0

        self._filer.test()

        self._socket_connect_mock.assert_called_once_with(
            (self._host, self._port))
        self._filer.get.assert_called_once_with('/nosession/logininfo')
예제 #25
0
 def _get_create_folder_response(rc,
                                 shared_secret=None,
                                 passphrase_salt=None):
     task = Object()
     task.result = Object()
     task.result.createFolderRC = rc
     if shared_secret:
         task.result.sharedSecret = shared_secret
     if passphrase_salt:
         task.result.passPhraseSalt = passphrase_salt
     return task
예제 #26
0
    def test_connection_socket_connect_error(self):
        get_response = Object()
        get_response.hostname = self._filer.host()
        self._init_filer(get_response=get_response)
        self._socket_connect_mock.side_effect = socket.gaierror()

        with self.assertRaises(exception.HostUnreachable) as error:
            self._filer.test()

        self._socket_connect_mock.assert_called_once_with(
            (self._host, self._port))
        self.assertEqual('Unable to reach host', error.exception.message)
예제 #27
0
    def test_connection_socket_connect_error_none_zero_rc(self):
        get_response = Object()
        get_response.hostname = self._filer.host()
        self._init_filer(get_response=get_response)
        self._socket_connect_mock.return_value = 1

        with self.assertRaises(exception.HostUnreachable) as error:
            self._filer.test()

        self._socket_connect_mock.assert_called_once_with(
            (self._host, self._port))
        self.assertEqual('Unable to reach host', error.exception.message)
 def _create_action_resource_param(self, sources, destinations=None):
     action_resource_param = Object()
     action_resource_param._classname = 'ActionResourcesParam'  # pylint: disable=protected-access
     action_resource_param.urls = []
     for idx, source in enumerate(sources):
         param = Object()
         param._classname = 'SrcDstParam'  # pylint: disable=protected-access
         param.src = self._services.file_browser_base_path + '/' + source
         if destinations:
             param.dest = self._services.file_browser_base_path + '/' + destinations[idx]
         else:
             param.dest = None
         action_resource_param.urls.append(param)
     return action_resource_param
예제 #29
0
 def test_device_ok(self):
     o = Object()
     o.name = "unit-test"
     self._init_global_admin(get_multi_response=o)
     devices.Devices(self._global_admin).device(o.name)
     self._global_admin.get_multi.assert_called_once_with(
         '/portals/None/devices/unit-test', mock.ANY)
     expected_include = ['/' + attr for attr in devices.Devices.default]
     actual_include = self._global_admin.get_multi.call_args[0][1]
     self.assertEqual(len(expected_include), len(actual_include))
     for attr in expected_include:
         self.assertIn(attr, actual_include)
     self._remote_command_mock.assert_called_once_with(
         self._global_admin, o)
예제 #30
0
 def _get_ftp_configuration_response(allow_anonymous_ftp=None, anonymous_download_limit=None, anonymous_ftp_folder=None,
                                     banner_message=None, max_connections_per_ip=None, require_ssl=None):
     obj = Object()
     obj.mode = Mode.Enabled
     obj.AnonymousDownloadLimit = anonymous_download_limit if anonymous_download_limit is not None else None
     obj.AnonymousFTPFolder = anonymous_ftp_folder if anonymous_ftp_folder is not None else 'default folder'
     obj.AllowAnonymousFTP = allow_anonymous_ftp if allow_anonymous_ftp is not None else False
     obj.BannerMessage = banner_message if banner_message is not None else 'Welcome to CTERA FTP.'
     obj.MaxConnectionsPerIP = max_connections_per_ip if max_connections_per_ip is not None else 5
     obj.RequireSSL = require_ssl if require_ssl is not None else False
     return obj