Files @ 31f510a88584
Branch filter:

Location: kallithea/rhodecode/tests/functional/test_admin_settings.py

Bradley M. Kuhn
Update minified YUI to version 2.9 built from Source.

yui.2.9.js used to be a minified version of YUI 2.9 until 5143b8df576c updated
it to something else and applied more aggresive minification. We stick to a
clean but minified version 2.9.

The license of YUI is BSD 3-clause, as described on
http://yuilibrary.com/license/ .

Since the minified version combines with GPLv3'd Javascript, it is only GPLv3'd
compliant to distribute this Object Code version with the Corresponding Source
(or offer therefor).

This yui.2.9.js is built from Source this way:
git clone https://github.com/yui/builder
git clone https://github.com/yui/yui2
cd yui2/
git checkout hudson-yui2-2800
ln -sf JumpToPageDropDown.js src/paginator/js/JumpToPageDropdown.js # work around inconsistent casing
rm -f tmp.js
for m in yahoo event dom connection animation dragdrop element datasource autocomplete container event-delegate json datatable paginator; do
rm -f build/$m/$m.js; ( cd src/$m && ant build deploybuild ) && sed -e 's,@VERSION@,2.9.0,g' -e 's,@BUILD@,2800,g' build/$m/$m.js >> tmp.js
done
java -jar ../builder/componentbuild/lib/yuicompressor/yuicompressor-2.4.4.jar tmp.js -o yui.2.9.js

The source is mirrored and available on https://kallithea-scm.org/repos/mirror .
# -*- coding: utf-8 -*-

from rhodecode.lib.auth import get_crypt_password, check_password
from rhodecode.model.db import User, RhodeCodeSetting, Repository, RhodeCodeUi
from rhodecode.tests import *
from rhodecode.tests.fixture import Fixture
from rhodecode.lib import helpers as h
from rhodecode.model.user import UserModel
from rhodecode.model.scm import ScmModel
from rhodecode.model.meta import Session

fixture = Fixture()


class TestAdminSettingsController(TestController):

    def test_index_main(self):
        self.log_user()
        response = self.app.get(url('admin_settings'))

    def test_index_mapping(self):
        self.log_user()
        response = self.app.get(url('admin_settings_mapping'))

    def test_index_global(self):
        self.log_user()
        response = self.app.get(url('admin_settings_global'))

    def test_index_visual(self):
        self.log_user()
        response = self.app.get(url('admin_settings_visual'))

    def test_index_email(self):
        self.log_user()
        response = self.app.get(url('admin_settings_email'))

    def test_index_hooks(self):
        self.log_user()
        response = self.app.get(url('admin_settings_hooks'))

    def test_create_custom_hook(self):
        self.log_user()
        response = self.app.post(url('admin_settings_hooks'),
                                params=dict(new_hook_ui_key='test_hooks_1',
                                            new_hook_ui_value='cd /tmp'))

        response = response.follow()
        response.mustcontain('test_hooks_1')
        response.mustcontain('cd /tmp')

    def test_create_custom_hook_delete(self):
        self.log_user()
        response = self.app.post(url('admin_settings_hooks'),
                                params=dict(new_hook_ui_key='test_hooks_2',
                                            new_hook_ui_value='cd /tmp2'))

        response = response.follow()
        response.mustcontain('test_hooks_2')
        response.mustcontain('cd /tmp2')

        hook_id = RhodeCodeUi.get_by_key('test_hooks_2').ui_id
        ## delete
        self.app.post(url('admin_settings_hooks'),
                        params=dict(hook_id=hook_id))
        response = self.app.get(url('admin_settings_hooks'))
        response.mustcontain(no=['test_hooks_2'])
        response.mustcontain(no=['cd /tmp2'])

    def test_index_search(self):
        self.log_user()
        response = self.app.get(url('admin_settings_search'))

    def test_index_system(self):
        self.log_user()
        response = self.app.get(url('admin_settings_system'))

    def test_ga_code_active(self):
        self.log_user()
        old_title = 'RhodeCode'
        old_realm = 'RhodeCode authentication'
        new_ga_code = 'ga-test-123456789'
        response = self.app.post(url('admin_settings_global'),
                        params=dict(rhodecode_title=old_title,
                                 rhodecode_realm=old_realm,
                                 rhodecode_ga_code=new_ga_code,
                                 rhodecode_captcha_private_key='',
                                 rhodecode_captcha_public_key='',
                                 ))

        self.checkSessionFlash(response, 'Updated application settings')

        self.assertEqual(RhodeCodeSetting
                         .get_app_settings()['rhodecode_ga_code'], new_ga_code)

        response = response.follow()
        response.mustcontain("""_gaq.push(['_setAccount', '%s']);""" % new_ga_code)

    def test_ga_code_inactive(self):
        self.log_user()
        old_title = 'RhodeCode'
        old_realm = 'RhodeCode authentication'
        new_ga_code = ''
        response = self.app.post(url('admin_settings_global'),
                        params=dict(rhodecode_title=old_title,
                                 rhodecode_realm=old_realm,
                                 rhodecode_ga_code=new_ga_code,
                                 rhodecode_captcha_private_key='',
                                 rhodecode_captcha_public_key='',
                                 ))

        self.checkSessionFlash(response, 'Updated application settings')
        self.assertEqual(RhodeCodeSetting
                        .get_app_settings()['rhodecode_ga_code'], new_ga_code)

        response = response.follow()
        response.mustcontain(no=["_gaq.push(['_setAccount', '%s']);" % new_ga_code])

    def test_captcha_activate(self):
        self.log_user()
        old_title = 'RhodeCode'
        old_realm = 'RhodeCode authentication'
        new_ga_code = ''
        response = self.app.post(url('admin_settings_global'),
                        params=dict(rhodecode_title=old_title,
                                 rhodecode_realm=old_realm,
                                 rhodecode_ga_code=new_ga_code,
                                 rhodecode_captcha_private_key='1234567890',
                                 rhodecode_captcha_public_key='1234567890',
                                 ))

        self.checkSessionFlash(response, 'Updated application settings')
        self.assertEqual(RhodeCodeSetting
                        .get_app_settings()['rhodecode_captcha_private_key'], '1234567890')

        response = self.app.get(url('register'))
        response.mustcontain('captcha')

    def test_captcha_deactivate(self):
        self.log_user()
        old_title = 'RhodeCode'
        old_realm = 'RhodeCode authentication'
        new_ga_code = ''
        response = self.app.post(url('admin_settings_global'),
                        params=dict(rhodecode_title=old_title,
                                 rhodecode_realm=old_realm,
                                 rhodecode_ga_code=new_ga_code,
                                 rhodecode_captcha_private_key='',
                                 rhodecode_captcha_public_key='1234567890',
                                 ))

        self.checkSessionFlash(response, 'Updated application settings')
        self.assertEqual(RhodeCodeSetting
                        .get_app_settings()['rhodecode_captcha_private_key'], '')

        response = self.app.get(url('register'))
        response.mustcontain(no=['captcha'])

    def test_title_change(self):
        self.log_user()
        old_title = 'RhodeCode'
        new_title = old_title + '_changed'
        old_realm = 'RhodeCode authentication'

        for new_title in ['Changed', 'Żółwik', old_title]:
            response = self.app.post(url('admin_settings_global'),
                        params=dict(rhodecode_title=new_title,
                                 rhodecode_realm=old_realm,
                                 rhodecode_ga_code='',
                                 rhodecode_captcha_private_key='',
                                 rhodecode_captcha_public_key='',
                                ))

            self.checkSessionFlash(response, 'Updated application settings')
            self.assertEqual(RhodeCodeSetting
                             .get_app_settings()['rhodecode_title'],
                             new_title.decode('utf-8'))

            response = response.follow()
            response.mustcontain("""<div class="branding">- %s</div>""" % new_title)