Show More
@@ -29,6 +29,7 b'' | |||
|
29 | 29 | import os |
|
30 | 30 | import tempfile |
|
31 | 31 | import unittest |
|
32 | import time | |
|
32 | 33 | from os.path import join as jn |
|
33 | 34 | from os.path import dirname as dn |
|
34 | 35 | |
@@ -36,7 +37,7 b' from tempfile import _RandomNameSequence' | |||
|
36 | 37 | from subprocess import Popen, PIPE |
|
37 | 38 | |
|
38 | 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 | 41 | from rhodecode.model.meta import Session |
|
41 | 42 | from rhodecode.model.repo import RepoModel |
|
42 | 43 | from rhodecode.model.user import UserModel |
@@ -424,17 +425,21 b' class TestVCSOperations(unittest.TestCas' | |||
|
424 | 425 | |
|
425 | 426 | def test_ip_restriction_hg(self): |
|
426 | 427 | user_model = UserModel() |
|
427 | new_ip = user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') | |
|
428 | Session().commit() | |
|
428 | try: | |
|
429 | user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') | |
|
430 | Session().commit() | |
|
431 | clone_url = _construct_url(HG_REPO) | |
|
432 | stdout, stderr = Command('/tmp').execute('hg clone', clone_url) | |
|
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() | |
|
439 | ||
|
440 | time.sleep(2) | |
|
429 | 441 | clone_url = _construct_url(HG_REPO) |
|
430 | 442 | stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
|
431 | assert 'abort: HTTP Error 403: Forbidden' in stderr | |
|
432 | ||
|
433 | #release IP restrictions | |
|
434 | 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) | |
|
438 | 443 | |
|
439 | 444 | assert 'requesting all changes' in stdout |
|
440 | 445 | assert 'adding changesets' in stdout |
@@ -445,17 +450,21 b' class TestVCSOperations(unittest.TestCas' | |||
|
445 | 450 | |
|
446 | 451 | def test_ip_restriction_git(self): |
|
447 | 452 | user_model = UserModel() |
|
448 | new_ip = user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') | |
|
449 | Session().commit() | |
|
453 | try: | |
|
454 | user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') | |
|
455 | Session().commit() | |
|
456 | clone_url = _construct_url(GIT_REPO) | |
|
457 | stdout, stderr = Command('/tmp').execute('git clone', clone_url) | |
|
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() | |
|
464 | ||
|
465 | time.sleep(2) | |
|
450 | 466 | clone_url = _construct_url(GIT_REPO) |
|
451 | 467 | stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
|
452 | assert 'error: The requested URL returned error: 403 Forbidden' in stderr | |
|
453 | ||
|
454 | #release IP restrictions | |
|
455 | 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) | |
|
459 | 468 | |
|
460 | 469 | assert 'Cloning into' in stdout |
|
461 | 470 | assert stderr == '' |
@@ -30,16 +30,16 b' pdebug = false' | |||
|
30 | 30 | |
|
31 | 31 | [server:main] |
|
32 | 32 | ##nr of threads to spawn |
|
33 |
|
|
|
33 | threadpool_workers = 5 | |
|
34 | 34 | |
|
35 | 35 | ##max request before thread respawn |
|
36 |
|
|
|
36 | threadpool_max_requests = 2 | |
|
37 | 37 | |
|
38 | 38 | ##option to use threads of process |
|
39 |
|
|
|
39 | use_threadpool = true | |
|
40 | 40 | |
|
41 |
|
|
|
42 | use = egg:waitress#main | |
|
41 | use = egg:Paste#http | |
|
42 | #use = egg:waitress#main | |
|
43 | 43 | host = 127.0.0.1 |
|
44 | 44 | port = 5000 |
|
45 | 45 | |
@@ -295,4 +295,4 b' datefmt = %Y-%m-%d %H:%M:%S' | |||
|
295 | 295 | [formatter_color_formatter] |
|
296 | 296 | class=rhodecode.lib.colored_formatter.ColorFormatter |
|
297 | 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