Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed ip restriction tests when runned multiple times.

Added sleep to fix cache issues

--HG--
branch : beta
extra : amend_source : d9fd20b957f6d5acc54fe8f28556704c08d5c00b
  • Loading branch information...
commit 799dfa3a01b19e37131000c1a726bdac8449d52f 1 parent 9916bff
@marcinkuzminski authored
Showing with 34 additions and 25 deletions.
  1. +28 −19 rhodecode/tests/scripts/test_vcs_operations.py
  2. +6 −6 test.ini
View
47 rhodecode/tests/scripts/test_vcs_operations.py
@@ -29,6 +29,7 @@
import os
import tempfile
import unittest
+import time
from os.path import join as jn
from os.path import dirname as dn
@@ -36,7 +37,7 @@
from subprocess import Popen, PIPE
from rhodecode.tests import *
-from rhodecode.model.db import User, Repository, UserLog
+from rhodecode.model.db import User, Repository, UserLog, UserIpMap
from rhodecode.model.meta import Session
from rhodecode.model.repo import RepoModel
from rhodecode.model.user import UserModel
@@ -424,17 +425,21 @@ def test_push_unlocks_repository_hg(self):
def test_ip_restriction_hg(self):
user_model = UserModel()
- new_ip = user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32')
- Session().commit()
+ try:
+ user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32')
+ Session().commit()
+ clone_url = _construct_url(HG_REPO)
+ stdout, stderr = Command('/tmp').execute('hg clone', clone_url)
+ assert 'abort: HTTP Error 403: Forbidden' in stderr
+ finally:
+ #release IP restrictions
+ for ip in UserIpMap.getAll():
+ UserIpMap.delete(ip.ip_id)
+ Session().commit()
+
+ time.sleep(2)
clone_url = _construct_url(HG_REPO)
stdout, stderr = Command('/tmp').execute('hg clone', clone_url)
- assert 'abort: HTTP Error 403: Forbidden' in stderr
-
- #release IP restrictions
- clone_url = _construct_url(HG_REPO)
- user_model.delete_extra_ip(TEST_USER_ADMIN_LOGIN, new_ip.ip_id)
- Session().commit()
- stdout, stderr = Command('/tmp').execute('hg clone', clone_url)
assert 'requesting all changes' in stdout
assert 'adding changesets' in stdout
@@ -445,17 +450,21 @@ def test_ip_restriction_hg(self):
def test_ip_restriction_git(self):
user_model = UserModel()
- new_ip = user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32')
- Session().commit()
+ try:
+ user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32')
+ Session().commit()
+ clone_url = _construct_url(GIT_REPO)
+ stdout, stderr = Command('/tmp').execute('git clone', clone_url)
+ assert 'error: The requested URL returned error: 403 Forbidden' in stderr
+ finally:
+ #release IP restrictions
+ for ip in UserIpMap.getAll():
+ UserIpMap.delete(ip.ip_id)
+ Session().commit()
+
+ time.sleep(2)
clone_url = _construct_url(GIT_REPO)
stdout, stderr = Command('/tmp').execute('git clone', clone_url)
- assert 'error: The requested URL returned error: 403 Forbidden' in stderr
-
- #release IP restrictions
- clone_url = _construct_url(GIT_REPO)
- user_model.delete_extra_ip(TEST_USER_ADMIN_LOGIN, new_ip.ip_id)
- Session().commit()
- stdout, stderr = Command('/tmp').execute('git clone', clone_url)
assert 'Cloning into' in stdout
assert stderr == ''
View
12 test.ini
@@ -30,16 +30,16 @@ pdebug = false
[server:main]
##nr of threads to spawn
-#threadpool_workers = 5
+threadpool_workers = 5
##max request before thread respawn
-#threadpool_max_requests = 2
+threadpool_max_requests = 2
##option to use threads of process
-#use_threadpool = true
+use_threadpool = true
-#use = egg:Paste#http
-use = egg:waitress#main
+use = egg:Paste#http
+#use = egg:waitress#main
host = 127.0.0.1
port = 5000
@@ -295,4 +295,4 @@ datefmt = %Y-%m-%d %H:%M:%S
[formatter_color_formatter]
class=rhodecode.lib.colored_formatter.ColorFormatter
format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
-datefmt = %Y-%m-%d %H:%M:%S
+datefmt = %Y-%m-%d %H:%M:%S
Please sign in to comment.
Something went wrong with that request. Please try again.