##// END OF EJS Templates
auth: expose a option to calculate how we end up having super-admin permission....
auth: expose a option to calculate how we end up having super-admin permission. This is now used only for visual display. The old way is still faster for permissions calculation. - the extended way will be used in permission summary showing a much more detailed permission summary for super-admins.

File last commit:

r1816:7c5e9070 default
r2065:adc2d1ca default
Show More
test_my_account_emails.py
93 lines | 3.9 KiB | text/x-python | PythonLexer
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2017 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# 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 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/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import pytest
from rhodecode.apps._base import ADMIN_PREFIX
from rhodecode.model.db import User, UserEmailMap
from rhodecode.tests import (
TestController, TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_EMAIL,
assert_session_flash)
from rhodecode.tests.fixture import Fixture
fixture = Fixture()
def route_path(name, **kwargs):
return {
'my_account_emails':
ADMIN_PREFIX + '/my_account/emails',
'my_account_emails_add':
ADMIN_PREFIX + '/my_account/emails/new',
'my_account_emails_delete':
ADMIN_PREFIX + '/my_account/emails/delete',
}[name].format(**kwargs)
class TestMyAccountEmails(TestController):
def test_my_account_my_emails(self):
self.log_user()
response = self.app.get(route_path('my_account_emails'))
response.mustcontain('No additional emails specified')
def test_my_account_my_emails_add_existing_email(self):
self.log_user()
response = self.app.get(route_path('my_account_emails'))
response.mustcontain('No additional emails specified')
response = self.app.post(route_path('my_account_emails_add'),
{'new_email': TEST_USER_REGULAR_EMAIL,
'csrf_token': self.csrf_token})
assert_session_flash(response, 'This e-mail address is already taken')
def test_my_account_my_emails_add_mising_email_in_form(self):
self.log_user()
response = self.app.get(route_path('my_account_emails'))
response.mustcontain('No additional emails specified')
response = self.app.post(route_path('my_account_emails_add'),
{'csrf_token': self.csrf_token})
assert_session_flash(response, 'Please enter an email address')
def test_my_account_my_emails_add_remove(self):
self.log_user()
response = self.app.get(route_path('my_account_emails'))
response.mustcontain('No additional emails specified')
response = self.app.post(route_path('my_account_emails_add'),
{'new_email': 'foo@barz.com',
'csrf_token': self.csrf_token})
response = self.app.get(route_path('my_account_emails'))
email_id = UserEmailMap.query().filter(
UserEmailMap.user == User.get_by_username(
TEST_USER_ADMIN_LOGIN)).filter(
UserEmailMap.email == 'foo@barz.com').one().email_id
response.mustcontain('foo@barz.com')
response.mustcontain('<input id="del_email_id" name="del_email_id" '
'type="hidden" value="%s" />' % email_id)
response = self.app.post(
route_path('my_account_emails_delete'), {
'del_email_id': email_id,
'csrf_token': self.csrf_token})
assert_session_flash(response, 'Email successfully deleted')
response = self.app.get(route_path('my_account_emails'))
response.mustcontain('No additional emails specified')