def test_delete_array_failure(self):
     expected_exception = exception.CTERAException()
     self._filer.delete = mock.MagicMock(side_effect=expected_exception)
     with self.assertRaises(exception.CTERAException) as error:
         array.Array(self._filer).delete(self._array_name)
     self.assertEqual('Storage array deletion failed.',
                      error.exception.message)
 def test_login_failure(self):
     error_message = "Expected Failure"
     expected_exception = exception.CTERAException(message=error_message)
     self._filer.form_data = mock.MagicMock(side_effect=expected_exception)
     with self.assertRaises(exception.CTERAException) as error:
         login.Login(self._filer).login(self._username, self._password)
     self.assertEqual(error_message, error.exception.message)
 def test_modify_user_not_found(self):
     self._filer.get = mock.MagicMock(
         side_effect=exception.CTERAException())
     with self.assertRaises(exception.CTERAException) as error:
         users.Users(self._filer).modify(self._username)
     self._filer.get.assert_called_once_with('/config/auth/users/' +
                                             self._username)
     self.assertEqual('Failed to get the user', error.exception.message)
 def test_add_array_failure(self):
     expected_exception = exception.CTERAException()
     self._filer.add = mock.MagicMock(side_effect=expected_exception)
     with self.assertRaises(exception.CTERAException) as error:
         array.Array(self._filer).add(self._array_name, self._array_level,
                                      self._array_members)
     self.assertEqual('Storage array creation failed.',
                      error.exception.message)
 def test_mkfg_no_owner_raise(self):
     error_message = "Expected Failure"
     expected_exception = exception.CTERAException(message=error_message)
     self._global_admin.execute = mock.MagicMock(
         side_effect=expected_exception)
     with self.assertRaises(exception.CTERAException) as error:
         cloudfs.CloudFS(self._global_admin).mkfg(self._name)
     self.assertEqual(error_message, error.exception.message)
    def test_connect_failure_no_connection_over_port(self):
        get_response = self._get_workgroup_param()
        self._init_filer(get_response=get_response)

        expected_exception = exception.CTERAException()
        self._filer.execute = mock.MagicMock(side_effect=expected_exception)
        with self.assertRaises(exception.CTERAException):
            directoryservice.DirectoryService(self._filer).connect(
                self._domain, self._username, self._password)
Beispiel #7
0
 def test_modify_volume_not_found(self):
     self._init_filer()
     self._filer.get = mock.MagicMock(
         side_effect=exception.CTERAException())
     with self.assertRaises(exception.CTERAException) as error:
         volumes.Volumes(self._filer).modify(self._volume_1_name, 9999)
     self._filer.get.assert_called_once_with('/config/storage/volumes/' +
                                             self._volume_1_name)
     self.assertEqual('Failed to get the volume', error.exception.message)
Beispiel #8
0
 def test_modify_raise(self):
     self._init_filer(get_response=TestEdgeSMB._get_cifs_configuration_response())
     self._filer.put = mock.MagicMock(side_effect=exception.CTERAException())
     with self.assertRaises(exception.CTERAException) as error:
         smb.SMB(self._filer).modify(CIFSPacketSigning.Required, 20, True, False, False)
     self._filer.get.assert_called_once_with('/config/fileservices/cifs')
     self._filer.put.assert_called_once_with('/config/fileservices/cifs', mock.ANY)
     expected_param = TestEdgeSMB._get_cifs_configuration_response(CIFSPacketSigning.Required, 20, True, False, False)
     actual_param = self._filer.put.call_args[0][1]
     self._assert_equal_objects(actual_param, expected_param)
     self.assertEqual('Failed to update SMB configuration.', error.exception.message)
Beispiel #9
0
 def test_delete_volume_raise(self):
     self._init_filer()
     self._filer.delete = mock.MagicMock(
         side_effect=exception.CTERAException())
     taskmgr.by_name = mock.MagicMock(return_value=[])
     with self.assertRaises(exception.CTERAException) as error:
         volumes.Volumes(self._filer).delete(self._volume_1_name)
     taskmgr.by_name.assert_called_once_with(
         self._filer,
         ' '.join(['Mounting', self._volume_1_name, 'file system']))
     self._filer.delete.assert_called_once_with('/config/storage/volumes/' +
                                                self._volume_1_name)
     self.assertEqual('Volume deletion falied', error.exception.message)
 def test_logout_failure_after_login_success(self):
     self._init_filer()
     login.Login(self._filer).login(self._username, self._password)
     self._filer.form_data.assert_called_once_with(
         '/login', {
             'username': self._username,
             'password': self._password
         })
     error_message = "Expected Failure"
     expected_exception = exception.CTERAException(message=error_message)
     self._filer.form_data = mock.MagicMock(side_effect=expected_exception)
     with self.assertRaises(exception.CTERAException) as error:
         login.Login(self._filer).logout()
     self._filer.form_data.assert_called_once_with('/logout',
                                                   {'foo': 'bar'})
     self.assertEqual(error_message, error.exception.message)
    def test_modify_user_update_failed(self):
        get_response = Object()
        get_response.username = self._username
        self._init_filer(get_response=get_response)
        self._filer.put = mock.MagicMock(
            side_effect=exception.CTERAException())
        with self.assertRaises(exception.CTERAException) as error:
            users.Users(self._filer).modify(self._username, self._password,
                                            self._full_name, self._email,
                                            self._uid)

        self._filer.get.assert_called_once_with('/config/auth/users/' +
                                                self._username)
        self._filer.put.assert_called_once_with(
            '/config/auth/users/' + self._username, mock.ANY)
        expected_param = self._get_user_object(self._full_name, self._email,
                                               self._uid)
        actual_param = self._filer.put.call_args[0][1]
        self._assert_equal_objects(actual_param, expected_param)
        self.assertEqual('Failed to modify user', error.exception.message)
    def test_mkdir_with_local_owner_raise(self):
        get_response = 'admin'
        self._init_global_admin(get_response=get_response,
                                execute_response='Success')
        self._mock_get_user_base_object_ref()

        error_message = "Expected Failure"
        expected_exception = exception.CTERAException(message=error_message)
        self._global_admin.execute = mock.MagicMock(
            side_effect=expected_exception)
        with self.assertRaises(exception.CTERAException) as error:
            cloudfs.CloudFS(self._global_admin).mkdir(self._name, self._group,
                                                      self._local_user_account)

        self._global_admin.users.get.assert_called_once_with(
            self._local_user_account, ['baseObjectRef'])
        self._global_admin.get.assert_called_once_with('/foldersGroups/' +
                                                       self._group +
                                                       '/baseObjectRef')

        self.assertEqual(error_message, error.exception.message)
    def test_add_share_failure(self):
        execute_response = self._get_list_physical_folders_response_object()
        self._init_filer(execute_response=execute_response)
        self._filer.add = mock.MagicMock(
            side_effect=exception.CTERAException())
        with self.assertRaises(exception.CTERAException) as error:
            shares.Shares(self._filer).add(self._share_name,
                                           self._share_fullpath, [])

        self._filer.execute.assert_called_once_with('/status/fileManager',
                                                    'listPhysicalFolders',
                                                    mock.ANY)
        expected_param = self._get_list_physical_folders_param()
        actual_param = self._filer.execute.call_args[0][2]
        self._assert_equal_objects(actual_param, expected_param)

        self._filer.add.assert_called_once_with('/config/fileservices/share',
                                                mock.ANY)
        expected_param = self._get_share_object(acl=[])
        actual_param = self._filer.add.call_args[0][1]
        self._assert_equal_objects(actual_param, expected_param)

        self.assertEqual('Share creation failed', error.exception.message)
 def test_delete_share_failure(self):
     self._filer.delete = mock.MagicMock(
         side_effect=exception.CTERAException())
     with self.assertRaises(exception.CTERAException) as error:
         shares.Shares(self._filer).delete(self._share_name)
     self.assertEqual('Share deletion failed', error.exception.message)
 def test_add_user_raise(self):
     expected_exception = exception.CTERAException()
     self._filer.add = mock.MagicMock(side_effect=expected_exception)
     with self.assertRaises(exception.CTERAException) as error:
         users.Users(self._filer).add(self._username, self._password)
     self.assertEqual('User creation failed', error.exception.message)
 def test_delete_user_raise(self):
     expected_exception = exception.CTERAException()
     self._filer.delete = mock.MagicMock(side_effect=expected_exception)
     with self.assertRaises(exception.CTERAException) as error:
         users.Users(self._filer).delete(self._username)
     self.assertEqual('User deletion failed', error.exception.message)
Beispiel #17
0
 def test_set_packet_signing_raise_error(self):
     expected_exception = exception.CTERAException()
     self._filer.put = mock.MagicMock(side_effect=expected_exception)
     with self.assertRaises(exception.CTERAException) as error:
         smb.SMB(self._filer).set_packet_signing(CIFSPacketSigning.Disabled)
     self.assertEqual('Invalid packet signing co', error.exception.message)