Mercurial > kallithea
comparison rhodecode/tests/scripts/test_vcs_operations.py @ 3131:21307b019ad4 beta
added integration tests for IP restriction option
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 03 Jan 2013 00:44:06 +0100 |
parents | 15dc5b2ff672 |
children | 3472d8f37e6d |
comparison
equal
deleted
inserted
replaced
3130:e054a6685b17 | 3131:21307b019ad4 |
---|---|
37 | 37 |
38 from rhodecode.tests import * | 38 from rhodecode.tests import * |
39 from rhodecode.model.db import User, Repository, UserLog | 39 from rhodecode.model.db import User, Repository, UserLog |
40 from rhodecode.model.meta import Session | 40 from rhodecode.model.meta import Session |
41 from rhodecode.model.repo import RepoModel | 41 from rhodecode.model.repo import RepoModel |
42 from rhodecode.model.user import UserModel | |
42 | 43 |
43 DEBUG = True | 44 DEBUG = True |
44 HOST = '127.0.0.1:5000' # test host | 45 HOST = '127.0.0.1:5000' # test host |
45 | 46 |
46 | 47 |
418 # #assert ('remote: Released lock on repo `%s`' % GIT_REPO) in stdout | 419 # #assert ('remote: Released lock on repo `%s`' % GIT_REPO) in stdout |
419 # #we need to cleanup the Session Here ! | 420 # #we need to cleanup the Session Here ! |
420 # Session.remove() | 421 # Session.remove() |
421 # r = Repository.get_by_repo_name(GIT_REPO) | 422 # r = Repository.get_by_repo_name(GIT_REPO) |
422 # assert r.locked == [None, None] | 423 # assert r.locked == [None, None] |
424 | |
425 def test_ip_restriction_hg(self): | |
426 user_model = UserModel() | |
427 new_ip = user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') | |
428 Session().commit() | |
429 clone_url = _construct_url(HG_REPO) | |
430 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 | |
439 assert 'requesting all changes' in stdout | |
440 assert 'adding changesets' in stdout | |
441 assert 'adding manifests' in stdout | |
442 assert 'adding file changes' in stdout | |
443 | |
444 assert stderr == '' | |
445 | |
446 def test_ip_restriction_git(self): | |
447 user_model = UserModel() | |
448 new_ip = user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') | |
449 Session().commit() | |
450 clone_url = _construct_url(GIT_REPO) | |
451 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 | |
460 assert 'Cloning into' in stdout | |
461 assert stderr == '' |