2021-03-31 13:15:40 +03:00
|
|
|
/**
|
2014-10-31 13:41:07 +03:00
|
|
|
* Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
|
|
|
|
*
|
2021-03-31 13:15:40 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
|
|
|
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
|
|
* @author Juan Pablo Villafáñez <jvillafanez@solidgear.es>
|
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
|
|
|
* @author Robin McCorkell <robin@mccorkell.me.uk>
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
* @author Vincent Petry <vincent@nextcloud.com>
|
2014-10-31 13:41:07 +03:00
|
|
|
*
|
2021-03-31 13:15:40 +03:00
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-10-31 13:41:07 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-10-19 18:35:13 +03:00
|
|
|
describe('OCA.Files_External.Settings tests', function() {
|
2014-10-31 13:41:07 +03:00
|
|
|
var clock;
|
|
|
|
var select2Stub;
|
|
|
|
var select2ApplicableUsers;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
clock = sinon.useFakeTimers();
|
2017-04-24 11:39:37 +03:00
|
|
|
select2Stub = sinon.stub($.fn, 'select2').callsFake(function(args) {
|
2014-10-31 13:41:07 +03:00
|
|
|
if (args === 'val') {
|
|
|
|
return select2ApplicableUsers;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
on: function() {}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
// view still requires an existing DOM table
|
|
|
|
$('#testArea').append(
|
|
|
|
'<table id="externalStorage" data-admin="true">' +
|
|
|
|
'<thead></thead>' +
|
|
|
|
'<tbody>' +
|
|
|
|
'<tr id="addMountPoint" data-id="">' +
|
|
|
|
'<td class="status"></td>' +
|
|
|
|
'<td class="mountPoint"><input type="text" name="mountPoint"/></td>' +
|
|
|
|
'<td class="backend">' +
|
|
|
|
'<select class="selectBackend">' +
|
|
|
|
'<option disable selected>Add storage</option>' +
|
|
|
|
'<option value="\\OC\\TestBackend">Test Backend</option>' +
|
|
|
|
'<option value="\\OC\\AnotherTestBackend">Another Test Backend</option>' +
|
2016-01-29 14:47:23 +03:00
|
|
|
'<option value="\\OC\\InputsTestBackend">Inputs test backend</option>' +
|
2014-10-31 13:41:07 +03:00
|
|
|
'</select>' +
|
|
|
|
'</td>' +
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
'<td class="authentication"></td>' +
|
2014-10-31 13:41:07 +03:00
|
|
|
'<td class="configuration"></td>' +
|
|
|
|
'<td class="applicable">' +
|
|
|
|
'<input type="hidden" class="applicableUsers">' +
|
|
|
|
'</td>' +
|
2018-02-27 14:11:36 +03:00
|
|
|
'<td class="mountOptionsToggle">'+
|
2018-08-02 12:45:04 +03:00
|
|
|
'<div class="icon-more" title="Advanced settings" deluminate_imagetype="unknown"></div>'+
|
2018-02-27 14:11:36 +03:00
|
|
|
'<input type="hidden" class="mountOptions"/>'+
|
|
|
|
'</td>'+
|
|
|
|
'<td class="save">'+
|
|
|
|
'<div class="icon-checkmark" title="Save" deluminate_imagetype="unknown"></div>'+
|
|
|
|
'</td>'+
|
2014-10-31 13:41:07 +03:00
|
|
|
'</tr>' +
|
|
|
|
'</tbody>' +
|
|
|
|
'</table>'
|
|
|
|
);
|
|
|
|
// these are usually appended into the data attribute
|
|
|
|
// within the DOM by the server template
|
|
|
|
$('#externalStorage .selectBackend:first').data('configurations', {
|
|
|
|
'\\OC\\TestBackend': {
|
2015-09-15 00:21:42 +03:00
|
|
|
'identifier': '\\OC\\TestBackend',
|
|
|
|
'name': 'Test Backend',
|
2014-10-31 13:41:07 +03:00
|
|
|
'configuration': {
|
2016-02-01 19:44:58 +03:00
|
|
|
'field1': {
|
|
|
|
'value': 'Display Name 1'
|
|
|
|
},
|
|
|
|
'field2': {
|
|
|
|
'value': 'Display Name 2',
|
|
|
|
'flags': 1
|
|
|
|
}
|
2015-03-16 17:07:38 +03:00
|
|
|
},
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
'authSchemes': {
|
|
|
|
'builtin': true,
|
|
|
|
},
|
2015-03-16 17:07:38 +03:00
|
|
|
'priority': 11
|
2014-10-31 13:41:07 +03:00
|
|
|
},
|
|
|
|
'\\OC\\AnotherTestBackend': {
|
2015-09-15 00:21:42 +03:00
|
|
|
'identifier': '\\OC\\AnotherTestBackend',
|
|
|
|
'name': 'Another Test Backend',
|
2014-10-31 13:41:07 +03:00
|
|
|
'configuration': {
|
2016-02-01 19:44:58 +03:00
|
|
|
'field1': {
|
|
|
|
'value': 'Display Name 1'
|
|
|
|
},
|
|
|
|
'field2': {
|
|
|
|
'value': 'Display Name 2',
|
|
|
|
'flags': 1
|
|
|
|
}
|
2015-03-16 17:07:38 +03:00
|
|
|
},
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
'authSchemes': {
|
|
|
|
'builtin': true,
|
|
|
|
},
|
2015-03-16 17:07:38 +03:00
|
|
|
'priority': 12
|
2016-01-29 14:47:23 +03:00
|
|
|
},
|
|
|
|
'\\OC\\InputsTestBackend': {
|
|
|
|
'identifier': '\\OC\\InputsTestBackend',
|
|
|
|
'name': 'Inputs test backend',
|
|
|
|
'configuration': {
|
2016-02-01 19:44:58 +03:00
|
|
|
'field_text': {
|
|
|
|
'value': 'Text field'
|
|
|
|
},
|
|
|
|
'field_password': {
|
|
|
|
'value': ',Password field',
|
|
|
|
'type': 2
|
|
|
|
},
|
|
|
|
'field_bool': {
|
|
|
|
'value': 'Boolean field',
|
|
|
|
'type': 1
|
|
|
|
},
|
|
|
|
'field_hidden': {
|
|
|
|
'value': 'Hidden field',
|
|
|
|
'type': 3
|
|
|
|
},
|
|
|
|
'field_text_optional': {
|
|
|
|
'value': 'Text field optional',
|
|
|
|
'flags': 1
|
|
|
|
},
|
|
|
|
'field_password_optional': {
|
|
|
|
'value': 'Password field optional',
|
|
|
|
'flags': 1,
|
|
|
|
'type': 2
|
|
|
|
}
|
2016-01-29 14:47:23 +03:00
|
|
|
},
|
|
|
|
'authSchemes': {
|
|
|
|
'builtin': true,
|
|
|
|
},
|
|
|
|
'priority': 13
|
2014-10-31 13:41:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
|
|
|
|
$('#externalStorage #addMountPoint .authentication:first').data('mechanisms', {
|
|
|
|
'mechanism1': {
|
2015-09-15 00:21:42 +03:00
|
|
|
'identifier': 'mechanism1',
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
'name': 'Mechanism 1',
|
|
|
|
'configuration': {
|
|
|
|
},
|
|
|
|
'scheme': 'builtin',
|
2016-01-25 18:24:33 +03:00
|
|
|
'visibility': 3
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2014-10-31 13:41:07 +03:00
|
|
|
});
|
|
|
|
afterEach(function() {
|
|
|
|
select2Stub.restore();
|
|
|
|
clock.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('storage configuration', function() {
|
|
|
|
var view;
|
|
|
|
|
|
|
|
function selectBackend(backendName) {
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
view.$el.find('.selectBackend:first').val(backendName).trigger('change');
|
2014-10-31 13:41:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
var $el = $('#externalStorage');
|
2018-10-19 18:35:13 +03:00
|
|
|
view = new OCA.Files_External.Settings.MountConfigListView($el, {encryptionEnabled: false});
|
2014-10-31 13:41:07 +03:00
|
|
|
});
|
|
|
|
afterEach(function() {
|
|
|
|
view = null;
|
|
|
|
});
|
|
|
|
describe('selecting backend', function() {
|
|
|
|
it('populates the row and creates a new empty one', function() {
|
|
|
|
var $firstRow = view.$el.find('tr:first');
|
|
|
|
selectBackend('\\OC\\TestBackend');
|
|
|
|
expect($firstRow.find('.backend').text()).toEqual('Test Backend');
|
|
|
|
expect($firstRow.find('.selectBackend').length).toEqual(0);
|
|
|
|
|
|
|
|
// TODO: check "remove" button visibility
|
|
|
|
|
|
|
|
// the suggested mount point name
|
|
|
|
expect($firstRow.find('[name=mountPoint]').val()).toEqual('TestBackend');
|
|
|
|
|
|
|
|
// TODO: check that the options have been created
|
|
|
|
|
|
|
|
// TODO: check select2 call on the ".applicableUsers" element
|
|
|
|
|
|
|
|
var $emptyRow = $firstRow.next('tr');
|
|
|
|
expect($emptyRow.length).toEqual(1);
|
|
|
|
expect($emptyRow.find('.selectBackend').length).toEqual(1);
|
|
|
|
expect($emptyRow.find('.applicable select').length).toEqual(0);
|
|
|
|
|
|
|
|
// TODO: check "remove" button visibility
|
|
|
|
});
|
2016-03-17 01:06:49 +03:00
|
|
|
it('shows row even if selection row is hidden', function() {
|
|
|
|
view.$el.find('tr#addMountPoint').hide();
|
|
|
|
selectBackend('\\OC\\TestBackend');
|
|
|
|
expect(view.$el.find('tr:first').is(':visible')).toBe(true);
|
|
|
|
expect(view.$el.find('tr#addMountPoint').is(':visible')).toBe(false);
|
|
|
|
});
|
2014-10-31 13:41:07 +03:00
|
|
|
// TODO: test with personal mounts (no applicable fields)
|
|
|
|
// TODO: test suggested mount point logic
|
|
|
|
});
|
|
|
|
describe('saving storages', function() {
|
2015-03-16 16:07:53 +03:00
|
|
|
var $tr;
|
2014-10-31 13:41:07 +03:00
|
|
|
|
2015-03-16 16:07:53 +03:00
|
|
|
beforeEach(function() {
|
|
|
|
$tr = view.$el.find('tr:first');
|
|
|
|
selectBackend('\\OC\\TestBackend');
|
|
|
|
});
|
2017-03-22 16:32:26 +03:00
|
|
|
it('saves storage after clicking the save button', function() {
|
2014-10-31 13:41:07 +03:00
|
|
|
var $field1 = $tr.find('input[data-parameter=field1]');
|
|
|
|
expect($field1.length).toEqual(1);
|
|
|
|
$field1.val('test');
|
|
|
|
$field1.trigger(new $.Event('keyup', {keyCode: 97}));
|
|
|
|
|
2015-03-16 16:07:53 +03:00
|
|
|
var $mountOptionsField = $tr.find('input.mountOptions');
|
|
|
|
expect($mountOptionsField.length).toEqual(1);
|
|
|
|
$mountOptionsField.val(JSON.stringify({previews:true}));
|
|
|
|
|
2018-02-27 15:05:01 +03:00
|
|
|
var $saveButton = $tr.find('td.save .icon-checkmark');
|
2017-03-22 16:32:26 +03:00
|
|
|
$saveButton.click();
|
2014-10-31 13:41:07 +03:00
|
|
|
|
|
|
|
expect(fakeServer.requests.length).toEqual(1);
|
|
|
|
var request = fakeServer.requests[0];
|
2018-10-09 08:44:26 +03:00
|
|
|
expect(request.url).toEqual(OC.getRootPath() + '/index.php/apps/files_external/globalstorages');
|
2015-03-16 16:07:53 +03:00
|
|
|
expect(JSON.parse(request.requestBody)).toEqual({
|
Authentication mechanisms for external storage backends
A backend can now specify generic authentication schemes that it
supports, instead of specifying the parameters for its authentication
method directly. This allows multiple authentication mechanisms to be
implemented for a single scheme, providing altered functionality.
This commit introduces the backend framework for this feature, and so at
this point the UI will be broken as the frontend does not specify the
required information.
Terminology:
- authentication scheme
Parameter interface for the authentication method. A backend
supporting the 'password' scheme accepts two parameters, 'user' and
'password'.
- authentication mechanism
Specific mechanism implementing a scheme. Basic mechanisms may
forward configuration options directly to the backend, more advanced
ones may lookup parameters or retrieve them from the session
New dropdown selector for external storage configurations to select the
authentication mechanism to be used.
Authentication mechanisms can have visibilities, just like backends.
The API was extended too to make it easier to add/remove visibilities.
In addition, the concept of 'allowed visibility' has been introduced, so
a backend/auth mechanism can force a maximum visibility level (e.g.
Local storage type) that cannot be overridden by configuration in the
web UI.
An authentication mechanism is a fully instantiated implementation. This
allows an implementation to have dependencies injected into it, e.g. an
\OCP\IDB for database operations.
When a StorageConfig is being prepared for mounting, the authentication
mechanism implementation has manipulateStorage() called,
which inserts the relevant authentication method options into the
storage ready for mounting.
2015-08-12 12:54:03 +03:00
|
|
|
backend: '\\OC\\TestBackend',
|
|
|
|
authMechanism: 'mechanism1',
|
2015-03-16 16:07:53 +03:00
|
|
|
backendOptions: {
|
|
|
|
'field1': 'test',
|
|
|
|
'field2': ''
|
|
|
|
},
|
2015-03-16 17:07:38 +03:00
|
|
|
mountPoint: 'TestBackend',
|
2015-03-16 16:07:53 +03:00
|
|
|
priority: 11,
|
|
|
|
applicableUsers: [],
|
|
|
|
applicableGroups: [],
|
|
|
|
mountOptions: {
|
|
|
|
'previews': true
|
2016-06-07 19:27:10 +03:00
|
|
|
},
|
|
|
|
testOnly: true
|
2014-10-31 13:41:07 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
// TODO: respond and check data-id
|
|
|
|
});
|
2018-02-27 14:27:25 +03:00
|
|
|
it('saves storage after closing mount options popovermenu', function() {
|
2018-08-02 12:45:04 +03:00
|
|
|
$tr.find('.mountOptionsToggle .icon-more').click();
|
2015-03-16 16:07:53 +03:00
|
|
|
$tr.find('[name=previews]').trigger(new $.Event('keyup', {keyCode: 97}));
|
|
|
|
$tr.find('input[data-parameter=field1]').val('test');
|
|
|
|
|
2018-02-27 14:27:25 +03:00
|
|
|
// does not save inside the popovermenu
|
2015-03-16 16:07:53 +03:00
|
|
|
expect(fakeServer.requests.length).toEqual(0);
|
|
|
|
|
|
|
|
$('body').mouseup();
|
|
|
|
|
2018-02-27 14:27:25 +03:00
|
|
|
// but after closing the popovermenu
|
2015-03-16 16:07:53 +03:00
|
|
|
expect(fakeServer.requests.length).toEqual(1);
|
|
|
|
});
|
2014-10-31 13:41:07 +03:00
|
|
|
// TODO: status indicator
|
|
|
|
});
|
2016-01-29 14:47:23 +03:00
|
|
|
describe('validate storage configuration', function() {
|
|
|
|
var $tr;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
$tr = view.$el.find('tr:first');
|
|
|
|
selectBackend('\\OC\\InputsTestBackend');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('lists missing fields in storage errors', function() {
|
|
|
|
var storage = view.getStorageConfig($tr);
|
|
|
|
|
|
|
|
expect(storage.errors).toEqual({
|
|
|
|
backendOptions: ['field_text', 'field_password']
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('highlights missing non-optional fields', function() {
|
|
|
|
_.each([
|
|
|
|
'field_text',
|
|
|
|
'field_password'
|
|
|
|
], function(param) {
|
|
|
|
expect($tr.find('input[data-parameter='+param+']').hasClass('warning-input')).toBe(true);
|
|
|
|
});
|
|
|
|
_.each([
|
|
|
|
'field_bool',
|
|
|
|
'field_hidden',
|
|
|
|
'field_text_optional',
|
|
|
|
'field_password_optional'
|
|
|
|
], function(param) {
|
|
|
|
expect($tr.find('input[data-parameter='+param+']').hasClass('warning-input')).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('validates correct storage', function() {
|
|
|
|
$tr.find('[name=mountPoint]').val('mountpoint');
|
|
|
|
|
|
|
|
$tr.find('input[data-parameter=field_text]').val('foo');
|
|
|
|
$tr.find('input[data-parameter=field_password]').val('bar');
|
|
|
|
$tr.find('input[data-parameter=field_text_optional]').val('foobar');
|
|
|
|
// don't set field_password_optional
|
|
|
|
$tr.find('input[data-parameter=field_hidden]').val('baz');
|
|
|
|
|
|
|
|
var storage = view.getStorageConfig($tr);
|
|
|
|
|
|
|
|
expect(storage.validate()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('checks missing mount point', function() {
|
|
|
|
$tr.find('[name=mountPoint]').val('');
|
|
|
|
|
|
|
|
$tr.find('input[data-parameter=field_text]').val('foo');
|
|
|
|
$tr.find('input[data-parameter=field_password]').val('bar');
|
|
|
|
|
|
|
|
var storage = view.getStorageConfig($tr);
|
|
|
|
|
|
|
|
expect(storage.validate()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
2014-10-31 13:41:07 +03:00
|
|
|
describe('update storage', function() {
|
|
|
|
// TODO
|
|
|
|
});
|
|
|
|
describe('delete storage', function() {
|
|
|
|
// TODO
|
|
|
|
});
|
|
|
|
describe('recheck storages', function() {
|
|
|
|
// TODO
|
|
|
|
});
|
2018-02-27 14:27:25 +03:00
|
|
|
describe('mount options popovermenu', function() {
|
2015-03-16 16:07:53 +03:00
|
|
|
var $tr;
|
|
|
|
var $td;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
$tr = view.$el.find('tr:first');
|
|
|
|
$td = $tr.find('.mountOptionsToggle');
|
|
|
|
selectBackend('\\OC\\TestBackend');
|
|
|
|
});
|
|
|
|
|
2018-02-27 14:27:25 +03:00
|
|
|
it('shows popovermenu when clicking on toggle button, hides when clicking outside', function() {
|
2018-08-02 12:45:04 +03:00
|
|
|
$td.find('.icon-more').click();
|
2015-03-16 16:07:53 +03:00
|
|
|
|
2018-02-27 14:27:25 +03:00
|
|
|
expect($td.find('.popovermenu.open').length).toEqual(1);
|
2015-03-16 16:07:53 +03:00
|
|
|
|
|
|
|
$('body').mouseup();
|
|
|
|
|
2018-02-27 14:27:25 +03:00
|
|
|
expect($td.find('.popovermenu.open').length).toEqual(0);
|
2015-03-16 16:07:53 +03:00
|
|
|
});
|
|
|
|
|
2015-04-02 19:31:26 +03:00
|
|
|
it('doesnt show the encryption option when encryption is disabled', function () {
|
|
|
|
view._encryptionEnabled = false;
|
2018-08-02 12:45:04 +03:00
|
|
|
$td.find('.icon-more').click();
|
2015-04-02 19:31:26 +03:00
|
|
|
|
2018-02-27 14:27:25 +03:00
|
|
|
expect($td.find('.popovermenu [name=encrypt]:visible').length).toEqual(0);
|
2015-04-02 19:31:26 +03:00
|
|
|
|
|
|
|
$('body').mouseup();
|
|
|
|
|
2018-02-27 14:27:25 +03:00
|
|
|
expect($td.find('.popovermenu.open').length).toEqual(0);
|
2015-04-02 19:31:26 +03:00
|
|
|
});
|
|
|
|
|
2015-03-16 16:07:53 +03:00
|
|
|
it('reads config from mountOptions field', function() {
|
|
|
|
$tr.find('input.mountOptions').val(JSON.stringify({previews:false}));
|
|
|
|
|
2018-08-02 12:45:04 +03:00
|
|
|
$td.find('.icon-more').click();
|
2018-02-27 14:27:25 +03:00
|
|
|
expect($td.find('.popovermenu [name=previews]').prop('checked')).toEqual(false);
|
2015-03-16 16:07:53 +03:00
|
|
|
$('body').mouseup();
|
|
|
|
|
|
|
|
$tr.find('input.mountOptions').val(JSON.stringify({previews:true}));
|
2018-08-02 12:45:04 +03:00
|
|
|
$td.find('.icon-more').click();
|
2018-02-27 14:27:25 +03:00
|
|
|
expect($td.find('.popovermenu [name=previews]').prop('checked')).toEqual(true);
|
2015-03-16 16:07:53 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('writes config into mountOptions field', function() {
|
2018-08-02 12:45:04 +03:00
|
|
|
$td.find('.icon-more').click();
|
2015-03-16 16:07:53 +03:00
|
|
|
// defaults to true
|
2018-02-27 14:27:25 +03:00
|
|
|
var $field = $td.find('.popovermenu [name=previews]');
|
2015-03-16 16:07:53 +03:00
|
|
|
expect($field.prop('checked')).toEqual(true);
|
2018-02-27 14:27:25 +03:00
|
|
|
$td.find('.popovermenu [name=filesystem_check_changes]').val(0);
|
2015-03-16 16:07:53 +03:00
|
|
|
$('body').mouseup();
|
|
|
|
|
|
|
|
expect(JSON.parse($tr.find('input.mountOptions').val())).toEqual({
|
2015-04-02 19:17:28 +03:00
|
|
|
encrypt: true,
|
2015-03-16 16:07:53 +03:00
|
|
|
previews: true,
|
2016-02-23 17:16:13 +03:00
|
|
|
enable_sharing: false,
|
2016-05-02 18:34:24 +03:00
|
|
|
filesystem_check_changes: 0,
|
2018-03-08 22:56:26 +03:00
|
|
|
encoding_compatibility: false,
|
|
|
|
readonly: false
|
2015-03-16 16:07:53 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2014-10-31 13:41:07 +03:00
|
|
|
});
|
|
|
|
describe('applicable user list', function() {
|
|
|
|
// TODO: test select2 retrieval logic
|
|
|
|
});
|
|
|
|
describe('allow user mounts section', function() {
|
|
|
|
// TODO: test allowUserMounting section
|
|
|
|
});
|
|
|
|
});
|