Show More
@@ -29,6 +29,7 b'' | |||||
29 | import os |
|
29 | import os | |
30 | import tempfile |
|
30 | import tempfile | |
31 | import unittest |
|
31 | import unittest | |
|
32 | import time | |||
32 | from os.path import join as jn |
|
33 | from os.path import join as jn | |
33 | from os.path import dirname as dn |
|
34 | from os.path import dirname as dn | |
34 |
|
35 | |||
@@ -36,7 +37,7 b' from tempfile import _RandomNameSequence' | |||||
36 | from subprocess import Popen, PIPE |
|
37 | from subprocess import Popen, PIPE | |
37 |
|
38 | |||
38 | from rhodecode.tests import * |
|
39 | from rhodecode.tests import * | |
39 | from rhodecode.model.db import User, Repository, UserLog |
|
40 | from rhodecode.model.db import User, Repository, UserLog, UserIpMap | |
40 | from rhodecode.model.meta import Session |
|
41 | from rhodecode.model.meta import Session | |
41 | from rhodecode.model.repo import RepoModel |
|
42 | from rhodecode.model.repo import RepoModel | |
42 | from rhodecode.model.user import UserModel |
|
43 | from rhodecode.model.user import UserModel | |
@@ -424,16 +425,20 b' class TestVCSOperations(unittest.TestCas' | |||||
424 |
|
425 | |||
425 | def test_ip_restriction_hg(self): |
|
426 | def test_ip_restriction_hg(self): | |
426 | user_model = UserModel() |
|
427 | user_model = UserModel() | |
427 | new_ip = user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') |
|
428 | try: | |
|
429 | user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') | |||
428 | Session().commit() |
|
430 | Session().commit() | |
429 | clone_url = _construct_url(HG_REPO) |
|
431 | clone_url = _construct_url(HG_REPO) | |
430 | stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
|
432 | stdout, stderr = Command('/tmp').execute('hg clone', clone_url) | |
431 | assert 'abort: HTTP Error 403: Forbidden' in stderr |
|
433 | assert 'abort: HTTP Error 403: Forbidden' in stderr | |
|
434 | finally: | |||
|
435 | #release IP restrictions | |||
|
436 | for ip in UserIpMap.getAll(): | |||
|
437 | UserIpMap.delete(ip.ip_id) | |||
|
438 | Session().commit() | |||
432 |
|
439 | |||
433 | #release IP restrictions |
|
440 | time.sleep(2) | |
434 | clone_url = _construct_url(HG_REPO) |
|
441 | clone_url = _construct_url(HG_REPO) | |
435 | user_model.delete_extra_ip(TEST_USER_ADMIN_LOGIN, new_ip.ip_id) |
|
|||
436 | Session().commit() |
|
|||
437 | stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
|
442 | stdout, stderr = Command('/tmp').execute('hg clone', clone_url) | |
438 |
|
443 | |||
439 | assert 'requesting all changes' in stdout |
|
444 | assert 'requesting all changes' in stdout | |
@@ -445,16 +450,20 b' class TestVCSOperations(unittest.TestCas' | |||||
445 |
|
450 | |||
446 | def test_ip_restriction_git(self): |
|
451 | def test_ip_restriction_git(self): | |
447 | user_model = UserModel() |
|
452 | user_model = UserModel() | |
448 | new_ip = user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') |
|
453 | try: | |
|
454 | user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') | |||
449 | Session().commit() |
|
455 | Session().commit() | |
450 | clone_url = _construct_url(GIT_REPO) |
|
456 | clone_url = _construct_url(GIT_REPO) | |
451 | stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
|
457 | stdout, stderr = Command('/tmp').execute('git clone', clone_url) | |
452 | assert 'error: The requested URL returned error: 403 Forbidden' in stderr |
|
458 | assert 'error: The requested URL returned error: 403 Forbidden' in stderr | |
|
459 | finally: | |||
|
460 | #release IP restrictions | |||
|
461 | for ip in UserIpMap.getAll(): | |||
|
462 | UserIpMap.delete(ip.ip_id) | |||
|
463 | Session().commit() | |||
453 |
|
464 | |||
454 | #release IP restrictions |
|
465 | time.sleep(2) | |
455 | clone_url = _construct_url(GIT_REPO) |
|
466 | clone_url = _construct_url(GIT_REPO) | |
456 | user_model.delete_extra_ip(TEST_USER_ADMIN_LOGIN, new_ip.ip_id) |
|
|||
457 | Session().commit() |
|
|||
458 | stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
|
467 | stdout, stderr = Command('/tmp').execute('git clone', clone_url) | |
459 |
|
468 | |||
460 | assert 'Cloning into' in stdout |
|
469 | assert 'Cloning into' in stdout |
@@ -30,16 +30,16 b' pdebug = false' | |||||
30 |
|
30 | |||
31 | [server:main] |
|
31 | [server:main] | |
32 | ##nr of threads to spawn |
|
32 | ##nr of threads to spawn | |
33 |
|
|
33 | threadpool_workers = 5 | |
34 |
|
34 | |||
35 | ##max request before thread respawn |
|
35 | ##max request before thread respawn | |
36 |
|
|
36 | threadpool_max_requests = 2 | |
37 |
|
37 | |||
38 | ##option to use threads of process |
|
38 | ##option to use threads of process | |
39 |
|
|
39 | use_threadpool = true | |
40 |
|
40 | |||
41 |
|
|
41 | use = egg:Paste#http | |
42 | use = egg:waitress#main |
|
42 | #use = egg:waitress#main | |
43 | host = 127.0.0.1 |
|
43 | host = 127.0.0.1 | |
44 | port = 5000 |
|
44 | port = 5000 | |
45 |
|
45 | |||
@@ -295,4 +295,4 b' datefmt = %Y-%m-%d %H:%M:%S' | |||||
295 | [formatter_color_formatter] |
|
295 | [formatter_color_formatter] | |
296 | class=rhodecode.lib.colored_formatter.ColorFormatter |
|
296 | class=rhodecode.lib.colored_formatter.ColorFormatter | |
297 | format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s |
|
297 | format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s | |
298 | datefmt = %Y-%m-%d %H:%M:%S No newline at end of file |
|
298 | datefmt = %Y-%m-%d %H:%M:%S |
General Comments 0
You need to be logged in to leave comments.
Login now