Remove unused config access via REST

This original method to retrieve user settings has been
replaced by https://review.openstack.org/#/c/170351/.

Remove old way to prevent confusion.

Change-Id: I4fec94a78168d48fee5b21d24064200b2aefce91
Closes-Bug: #1455246
This commit is contained in:
Cindy Lu 2015-05-13 17:23:20 -07:00
parent 46ca8a7095
commit a4b48e4c05
3 changed files with 0 additions and 137 deletions

View File

@ -17,59 +17,6 @@
(function () {
'use strict';
/**
* @ngdoc service
* @name hz.api.configAPI
* @description Provides access to dashboard configuration.
*/
function ConfigAPI(apiService) {
/**
* @name hz.api.configAPI.getUserDefaults
* @description
* Get the default user configuration settings.
*
* Returns an object with user configuration settings.
*/
this.getUserDefaults = function() {
return apiService.get('/api/config/user/')
.success(function(data) {
// store config in localStorage
// should be call only when defaults are needed
// or when user wants to reset it
localStorage.user_config = angular.toJson(data);
})
.error(function () {
horizon.alert('error', gettext('Unable to retrieve user configuration.'));
});
};
/**
* @name hz.api.configAPI.getAdminDefaults
* @description
* Get the default admin configuration settings.
*
* Returns an object with admin configuration settings.
*/
this.getAdminDefaults = function() {
return apiService.get('/api/config/admin/')
.success(function(data) {
// store this in localStorage
// should be call once each page load
localStorage.admin_config = angular.toJson(data);
})
.error(function () {
horizon.alert('error', gettext('Unable to retrieve admin configuration.'));
});
};
}
// Register it with the API module so that anybody using the
// API module will have access to the Config APIs.
angular.module('hz.api')
.service('hz.api.config', ['hz.api.common.service', ConfigAPI]);
/**
* @ngdoc service
* @name hz.api.settingsService

View File

@ -16,17 +16,10 @@
from django.conf import settings
from django.views import generic
from horizon import conf
from openstack_dashboard.api.rest import urls
from openstack_dashboard.api.rest import utils as rest_utils
# properties we know are admin config
admin_configs = ['ajax_queue_limit', 'ajax_poll_interval',
'user_home', 'help_url',
'password_autocomplete', 'disable_password_reveal']
# settings that we allow to be retrieved via REST API
# these settings are available to the client and are not secured.
# *** THEY SHOULD BE TREATED WITH EXTREME CAUTION ***
@ -35,52 +28,6 @@ settings_additional = getattr(settings, 'REST_API_ADDITIONAL_SETTINGS', [])
settings_allowed = settings_required + settings_additional
# properties we know are user config
# this is a white list of keys under HORIZON_CONFIG in settings.pys
# that we want to pass onto client
user_configs = ['auto_fade_alerts', 'modal_backdrop']
@urls.register
class DefaultUserConfigs(generic.View):
"""API for retrieving user configurations.
This API returns read-only-default configuration values.
This configuration object is ideally fetched once per application life
or when a user needs to restore the default values.
Examples of user config: modal_backdrop, disable_password_reveal
"""
url_regex = r'config/user/$'
@rest_utils.ajax()
def get(self, request):
"""Get default user configurations
"""
config = {}
for key in user_configs:
config[key] = conf.HORIZON_CONFIG.get(key, None)
return config
@urls.register
class AdminConfigs(generic.View):
"""API for retrieving admin configurations.
This API returns read-only admin configuration values.
This configuration object can be fetched as needed.
Examples of admin config: help_url, user_home
"""
url_regex = r'config/admin/$'
@rest_utils.ajax()
def get(self, request):
"""Get read-only admin configurations
"""
config = {}
for key in admin_configs:
config[key] = conf.HORIZON_CONFIG.get(key, None)
return config
@urls.register
class Settings(generic.View):

View File

@ -12,10 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from horizon import conf
from openstack_dashboard.api.rest import config
from openstack_dashboard.test import helpers as test
@ -33,24 +29,6 @@ class ConfigRestTestCase(test.TestCase):
self.fail('%s contains %s when it should not' %
(response, expected_content))
def test_user_config_get(self):
user_config = {"modal_backdrop": "static"}
content = '"modal_backdrop": "static"'
with mock.patch.dict(conf.HORIZON_CONFIG, user_config):
request = self.mock_rest_request()
response = config.DefaultUserConfigs().get(request)
self.assertStatusCode(response, 200)
self.assertContains(response.content, content)
def test_admin_config_get(self):
admin_config = {"user_home": "somewhere.com"}
content = '"user_home": "somewhere.com"'
with mock.patch.dict(conf.HORIZON_CONFIG, admin_config):
request = self.mock_rest_request()
response = config.AdminConfigs().get(request)
self.assertStatusCode(response, 200)
self.assertContains(response.content, content)
def test_settings_config_get(self):
request = self.mock_rest_request()
response = config.Settings().get(request)
@ -58,12 +36,3 @@ class ConfigRestTestCase(test.TestCase):
self.assertContains(response.content, "REST_API_SETTING_1")
self.assertContains(response.content, "REST_API_SETTING_2")
self.assertNotContains(response.content, "REST_API_SECURITY")
def test_ignore_list(self):
ignore_config = {"password_validator": "someobject"}
content = '"password_validator": "someobject"'
with mock.patch.dict(conf.HORIZON_CONFIG, ignore_config):
request = self.mock_rest_request()
response = config.AdminConfigs().get(request)
self.assertStatusCode(response, 200)
self.assertNotContains(response.content, content)