changeset 2714:a2eaa0054430 beta

fixed error when disabled anonymous access lead to error on server
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 14 Aug 2012 01:02:53 +0200
parents 3cfcbac0718d
children 298bac3757a7
files rhodecode/lib/auth.py rhodecode/tests/functional/test_home.py
diffstat 2 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/auth.py	Sat Aug 11 18:16:31 2012 +0200
+++ b/rhodecode/lib/auth.py	Tue Aug 14 01:02:53 2012 +0200
@@ -324,6 +324,7 @@
         self.email = ''
         self.is_authenticated = False
         self.admin = False
+        self.inherit_default_permissions = False
         self.permissions = {}
         self._api_key = api_key
         self.propagate_data()
--- a/rhodecode/tests/functional/test_home.py	Sat Aug 11 18:16:31 2012 +0200
+++ b/rhodecode/tests/functional/test_home.py	Tue Aug 14 01:02:53 2012 +0200
@@ -1,4 +1,7 @@
+import time
 from rhodecode.tests import *
+from rhodecode.model.meta import Session
+from rhodecode.model.db import User
 
 
 class TestHomeController(TestController):
@@ -22,3 +25,37 @@
 merge" class="tooltip" href="/vcs_test_hg/changeset/27cd5cce30c96924232"""
 """dffcd24178a07ffeb5dfc">r173:27cd5cce30c9</a>"""
 )
+
+    def test_repo_summary_with_anonymous_access_disabled(self):
+        anon = User.get_by_username('default')
+        anon.active = False
+        Session().add(anon)
+        Session().commit()
+        time.sleep(1.5)  # must sleep for cache (1s to expire)
+        try:
+            response = self.app.get(url(controller='summary',
+                                        action='index', repo_name=HG_REPO),
+                                        status=302)
+            assert 'login' in response.location
+
+        finally:
+            anon = User.get_by_username('default')
+            anon.active = True
+            Session().add(anon)
+            Session().commit()
+
+    def test_index_with_anonymous_access_disabled(self):
+        anon = User.get_by_username('default')
+        anon.active = False
+        Session().add(anon)
+        Session().commit()
+        time.sleep(1.5)  # must sleep for cache (1s to expire)
+        try:
+            response = self.app.get(url(controller='home', action='index'),
+                                    status=302)
+            assert 'login' in response.location
+        finally:
+            anon = User.get_by_username('default')
+            anon.active = True
+            Session().add(anon)
+            Session().commit()