Mercurial > kallithea
annotate kallithea/tests/other/test_vcs_operations.py @ 8988:511b20a6475d stable
tests: skip reading Git system and global configuration in test_vcs_operations
The parent changeset reduced the dependency on global configuration and made it
possible to run tests without any global git configuration. But it is still
unfortunate to even look at the global configuration when running tests.
Global configuration is already disabled for Mercurial by setting HGRCPATH.
Now do something similar for Git. According to the git man page,
GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM set to /dev/null will make Git skip
reading the configuration files on all platforms.
Note that the GIT_CONFIG variables were introduced in Git 2.32.0, so this will
not work with all the Git versions supported by Kallithea.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Thu, 30 Mar 2023 03:22:35 +0200 |
parents | d6d3cb5991e2 |
children |
rev | line source |
---|---|
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
1 # -*- coding: utf-8 -*- |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
2 # This program is free software: you can redistribute it and/or modify |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
3 # it under the terms of the GNU General Public License as published by |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
4 # the Free Software Foundation, either version 3 of the License, or |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
5 # (at your option) any later version. |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
6 # |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
7 # This program is distributed in the hope that it will be useful, |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
10 # GNU General Public License for more details. |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
11 # |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
12 # You should have received a copy of the GNU General Public License |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
13 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
14 """ |
6631
d7cdef68240b
tests: use webserver fixture for running vcs tests, removing need for serving manually
domruf <dominikruf@gmail.com>
parents:
6629
diff
changeset
|
15 Test suite for vcs push/pull operations. |
5063
55f855431f77
tests: rename test_vcs_operations.py to avoid automatic pick-up
Mads Kiilerich <madski@unity3d.com>
parents:
4527
diff
changeset
|
16 |
6631
d7cdef68240b
tests: use webserver fixture for running vcs tests, removing need for serving manually
domruf <dominikruf@gmail.com>
parents:
6629
diff
changeset
|
17 The tests need Git > 1.8.1. |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
18 |
4211
1948ede028ef
RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4208
diff
changeset
|
19 This file was forked by the Kallithea project in July 2014. |
1948ede028ef
RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4208
diff
changeset
|
20 Original author and date, and relevant copyright and licensing information is below: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
21 :created_on: Dec 30, 2010 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
22 :author: marcink |
4211
1948ede028ef
RhodeCode GmbH is not the sole author of this work
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4208
diff
changeset
|
23 :copyright: (c) 2013 RhodeCode GmbH, and others. |
4208
ad38f9f93b3b
Correct licensing information in individual files.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4206
diff
changeset
|
24 :license: GPLv3, see LICENSE.md for more details. |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
25 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
26 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
27 |
7811
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
7776
diff
changeset
|
28 import json |
5967
5c549b26231a
tests: set LANG and LANGUAGE - vcs tests expect messages to be in english
domruf <dominikruf@gmail.com>
parents:
5966
diff
changeset
|
29 import os |
5394
0b9aadc314de
tests: fix failing test_ip_restriction_git with some git versions
Søren Løvborg <sorenl@unity3d.com>
parents:
5388
diff
changeset
|
30 import re |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
31 import tempfile |
3180
3472d8f37e6d
fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents:
3131
diff
changeset
|
32 import time |
8188
22b40db44a41
py3: migrate from urllib2 to urllib
Mads Kiilerich <mads@kiilerich.com>
parents:
8181
diff
changeset
|
33 import urllib.request |
7811
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
7776
diff
changeset
|
34 from subprocess import PIPE, Popen |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
35 from tempfile import _RandomNameSequence |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
36 |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
37 import pytest |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
38 |
8667
072c0352dd36
imports: always use CONFIG as kallithea.CONFIG
Mads Kiilerich <mads@kiilerich.com>
parents:
8600
diff
changeset
|
39 import kallithea |
8206
7172f3b0042b
tests: minor updates for how py3 strings/bytes are different
Mads Kiilerich <mads@kiilerich.com>
parents:
8188
diff
changeset
|
40 from kallithea.lib.utils2 import ascii_bytes, safe_str |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
41 from kallithea.model import db, meta |
7811
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
7776
diff
changeset
|
42 from kallithea.model.ssh_key import SshKeyModel |
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
7776
diff
changeset
|
43 from kallithea.model.user import UserModel |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
44 from kallithea.tests import base |
5983
a69bcf8b28b3
tests: use forks when modifying repositories in vcs tests
domruf <dominikruf@gmail.com>
parents:
5982
diff
changeset
|
45 from kallithea.tests.fixture import Fixture |
7811
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
7776
diff
changeset
|
46 |
1596
089ef495e9dd
fixed test_hg_push operations
Marcin Kuzminski <marcin@python-works.com>
parents:
1532
diff
changeset
|
47 |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
48 DEBUG = True |
5388
5f9321340e44
tests: avoid collision with dev servers - use port 4999 for testing
Mads Kiilerich <madski@unity3d.com>
parents:
5376
diff
changeset
|
49 HOST = '127.0.0.1:4999' # test host |
2527
95624ce4465f
orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
50 |
5983
a69bcf8b28b3
tests: use forks when modifying repositories in vcs tests
domruf <dominikruf@gmail.com>
parents:
5982
diff
changeset
|
51 fixture = Fixture() |
a69bcf8b28b3
tests: use forks when modifying repositories in vcs tests
domruf <dominikruf@gmail.com>
parents:
5982
diff
changeset
|
52 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
53 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
54 # Parameterize different kinds of VCS testing - both the kind of VCS and the |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
55 # access method (HTTP/SSH) |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
56 |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
57 # Mixin for using HTTP and SSH URLs |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
58 class HttpVcsTest(object): |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
59 @staticmethod |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
60 def repo_url_param(webserver, repo_name, **kwargs): |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
61 return webserver.repo_url(repo_name, **kwargs) |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
62 |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
63 class SshVcsTest(object): |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
64 public_keys = { |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
65 base.TEST_USER_REGULAR_LOGIN: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== kallithea@localhost', |
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
66 base.TEST_USER_ADMIN_LOGIN: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUq== kallithea@localhost', |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
67 } |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
68 |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
69 @classmethod |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
70 def repo_url_param(cls, webserver, repo_name, username=base.TEST_USER_ADMIN_LOGIN, password=base.TEST_USER_ADMIN_PASS, client_ip=base.IP_ADDR): |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
71 user = db.User.get_by_username(username) |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
72 if user.ssh_keys: |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
73 ssh_key = user.ssh_keys[0] |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
74 else: |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
75 sshkeymodel = SshKeyModel() |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
76 ssh_key = sshkeymodel.create(user, 'test key', cls.public_keys[user.username]) |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
77 meta.Session().commit() |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
78 |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
79 return cls._ssh_param(repo_name, user, ssh_key, client_ip) |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
80 |
7733
460cfae11203
tests: fix merge error in test_vcs_operations mixins for Mercurial and Git - don't hardcode webserver repo_url_param
Mads Kiilerich <mads@kiilerich.com>
parents:
7683
diff
changeset
|
81 # Mixins for using Mercurial and Git |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
82 class HgVcsTest(object): |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
83 repo_type = 'hg' |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
84 repo_name = base.HG_REPO |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
85 |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
86 class GitVcsTest(object): |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
87 repo_type = 'git' |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
88 repo_name = base.GIT_REPO |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
89 |
7733
460cfae11203
tests: fix merge error in test_vcs_operations mixins for Mercurial and Git - don't hardcode webserver repo_url_param
Mads Kiilerich <mads@kiilerich.com>
parents:
7683
diff
changeset
|
90 # Combine mixins to give the combinations we want to parameterize tests with |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
91 class HgHttpVcsTest(HgVcsTest, HttpVcsTest): |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
92 pass |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
93 |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
94 class GitHttpVcsTest(GitVcsTest, HttpVcsTest): |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
95 pass |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
96 |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
97 class HgSshVcsTest(HgVcsTest, SshVcsTest): |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
98 @staticmethod |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
99 def _ssh_param(repo_name, user, ssh_key, client_ip): |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
100 # Specify a custom ssh command on the command line |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
101 return r"""--config ui.ssh="bash -c 'SSH_ORIGINAL_COMMAND=\"\$2\" SSH_CONNECTION=\"%s 1024 127.0.0.1 22\" kallithea-cli ssh-serve -c %s %s %s' --" ssh://someuser@somehost/%s""" % ( |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
102 client_ip, |
8667
072c0352dd36
imports: always use CONFIG as kallithea.CONFIG
Mads Kiilerich <mads@kiilerich.com>
parents:
8600
diff
changeset
|
103 kallithea.CONFIG['__file__'], |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
104 user.user_id, |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
105 ssh_key.user_ssh_key_id, |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
106 repo_name) |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
107 |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
108 class GitSshVcsTest(GitVcsTest, SshVcsTest): |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
109 @staticmethod |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
110 def _ssh_param(repo_name, user, ssh_key, client_ip): |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
111 # Set a custom ssh command in the global environment |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
112 os.environ['GIT_SSH_COMMAND'] = r"""bash -c 'SSH_ORIGINAL_COMMAND="$2" SSH_CONNECTION="%s 1024 127.0.0.1 22" kallithea-cli ssh-serve -c %s %s %s' --""" % ( |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
113 client_ip, |
8667
072c0352dd36
imports: always use CONFIG as kallithea.CONFIG
Mads Kiilerich <mads@kiilerich.com>
parents:
8600
diff
changeset
|
114 kallithea.CONFIG['__file__'], |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
115 user.user_id, |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
116 ssh_key.user_ssh_key_id) |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
117 return "ssh://someuser@somehost/%s""" % repo_name |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
118 |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
119 parametrize_vcs_test = base.parametrize('vt', [ |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
120 HgHttpVcsTest, |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
121 GitHttpVcsTest, |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
122 HgSshVcsTest, |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
123 GitSshVcsTest, |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
124 ]) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
125 parametrize_vcs_test_hg = base.parametrize('vt', [ |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
126 HgHttpVcsTest, |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
127 HgSshVcsTest, |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
128 ]) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
129 parametrize_vcs_test_http = base.parametrize('vt', [ |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
130 HgHttpVcsTest, |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
131 GitHttpVcsTest, |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
132 ]) |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
133 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
134 class Command(object): |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
135 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
136 def __init__(self, cwd): |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
137 self.cwd = cwd |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
138 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
139 def execute(self, *args, **environ): |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
140 """ |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
141 Runs command on the system with given ``args`` using simple space |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
142 join without safe quoting. |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
143 """ |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
144 command = ' '.join(args) |
6628
fa5788feed0f
tests: check returncode from executing external commands
domruf <dominikruf@gmail.com>
parents:
6609
diff
changeset
|
145 ignoreReturnCode = environ.pop('ignoreReturnCode', False) |
910
811fa5d45de8
Rewrite simehg for enabling cloning with raw url for anonymous access + some optimizations for making less queries when authenticating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
909
diff
changeset
|
146 if DEBUG: |
7844
a8e6bb9ee9ea
future: use Python print function
Mads Kiilerich <mads@kiilerich.com>
parents:
7843
diff
changeset
|
147 print('*** CMD %s ***' % command) |
5967
5c549b26231a
tests: set LANG and LANGUAGE - vcs tests expect messages to be in english
domruf <dominikruf@gmail.com>
parents:
5966
diff
changeset
|
148 testenv = dict(os.environ) |
5c549b26231a
tests: set LANG and LANGUAGE - vcs tests expect messages to be in english
domruf <dominikruf@gmail.com>
parents:
5966
diff
changeset
|
149 testenv['LANG'] = 'en_US.UTF-8' |
5c549b26231a
tests: set LANG and LANGUAGE - vcs tests expect messages to be in english
domruf <dominikruf@gmail.com>
parents:
5966
diff
changeset
|
150 testenv['LANGUAGE'] = 'en_US:en' |
6740
f6076c096692
tests: vcs: remove influence of user's hg settings
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
6658
diff
changeset
|
151 testenv['HGPLAIN'] = '' |
f6076c096692
tests: vcs: remove influence of user's hg settings
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
6658
diff
changeset
|
152 testenv['HGRCPATH'] = '' |
8988
511b20a6475d
tests: skip reading Git system and global configuration in test_vcs_operations
Manuel Jacob <me@manueljacob.de>
parents:
8987
diff
changeset
|
153 testenv['GIT_CONFIG_SYSTEM'] = '/dev/null' |
511b20a6475d
tests: skip reading Git system and global configuration in test_vcs_operations
Manuel Jacob <me@manueljacob.de>
parents:
8987
diff
changeset
|
154 testenv['GIT_CONFIG_GLOBAL'] = '/dev/null' |
8987
d6d3cb5991e2
tests: stabilize Git committer in test_vcs_operations
Mads Kiilerich <mads@kiilerich.com>
parents:
8870
diff
changeset
|
155 testenv['GIT_COMMITTER_NAME'] = base.TEST_USER_ADMIN_LOGIN |
d6d3cb5991e2
tests: stabilize Git committer in test_vcs_operations
Mads Kiilerich <mads@kiilerich.com>
parents:
8870
diff
changeset
|
156 testenv['GIT_COMMITTER_EMAIL'] = base.TEST_USER_ADMIN_EMAIL |
d6d3cb5991e2
tests: stabilize Git committer in test_vcs_operations
Mads Kiilerich <mads@kiilerich.com>
parents:
8870
diff
changeset
|
157 testenv['GIT_AUTHOR_NAME'] = base.TEST_USER_REGULAR_LOGIN |
d6d3cb5991e2
tests: stabilize Git committer in test_vcs_operations
Mads Kiilerich <mads@kiilerich.com>
parents:
8870
diff
changeset
|
158 testenv['GIT_AUTHOR_EMAIL'] = base.TEST_USER_REGULAR_EMAIL |
5981
3fff45b4c8ed
tests: set EMAIL for Git commit test_push_on_locked_repo_by_other_user_git - it _is_ necessary on some machines
domruf <dominikruf@gmail.com>
parents:
5970
diff
changeset
|
159 testenv.update(environ) |
5967
5c549b26231a
tests: set LANG and LANGUAGE - vcs tests expect messages to be in english
domruf <dominikruf@gmail.com>
parents:
5966
diff
changeset
|
160 p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE, cwd=self.cwd, env=testenv) |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
161 stdout, stderr = p.communicate() |
910
811fa5d45de8
Rewrite simehg for enabling cloning with raw url for anonymous access + some optimizations for making less queries when authenticating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
909
diff
changeset
|
162 if DEBUG: |
5970
10d7b01af4f0
tests: make debug output from manual_test_vcs_operations Command.execute less noisy
Mads Kiilerich <madski@unity3d.com>
parents:
5969
diff
changeset
|
163 if stdout: |
7844
a8e6bb9ee9ea
future: use Python print function
Mads Kiilerich <mads@kiilerich.com>
parents:
7843
diff
changeset
|
164 print('stdout:', stdout) |
5970
10d7b01af4f0
tests: make debug output from manual_test_vcs_operations Command.execute less noisy
Mads Kiilerich <madski@unity3d.com>
parents:
5969
diff
changeset
|
165 if stderr: |
7844
a8e6bb9ee9ea
future: use Python print function
Mads Kiilerich <mads@kiilerich.com>
parents:
7843
diff
changeset
|
166 print('stderr:', stderr) |
6628
fa5788feed0f
tests: check returncode from executing external commands
domruf <dominikruf@gmail.com>
parents:
6609
diff
changeset
|
167 if not ignoreReturnCode: |
fa5788feed0f
tests: check returncode from executing external commands
domruf <dominikruf@gmail.com>
parents:
6609
diff
changeset
|
168 assert p.returncode == 0 |
8206
7172f3b0042b
tests: minor updates for how py3 strings/bytes are different
Mads Kiilerich <mads@kiilerich.com>
parents:
8188
diff
changeset
|
169 return safe_str(stdout), safe_str(stderr) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
170 |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
171 |
6658
6304efbe37a3
tests: put all temporary files in one top directory
Mads Kiilerich <mads@kiilerich.com>
parents:
6633
diff
changeset
|
172 def _get_tmp_dir(prefix='vcs_operations-', suffix=''): |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
173 return tempfile.mkdtemp(dir=base.TESTS_TMP_PATH, prefix=prefix, suffix=suffix) |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
174 |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
175 |
7182
736f058d6172
tests: split _add_files_and_push in two
domruf <dominikruf@gmail.com>
parents:
7181
diff
changeset
|
176 def _add_files(vcs, dest_dir, files_no=3): |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
177 """ |
6865
94bbb7eb5b64
codingstyle: replace upper-case variable names with lower-case ones
Lars Kruse <devel@sumpfralle.de>
parents:
6864
diff
changeset
|
178 Generate some files, add it to dest_dir repo and push back |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
179 vcs is git or hg and defines what VCS we want to make those files for |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
180 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
181 :param vcs: |
6865
94bbb7eb5b64
codingstyle: replace upper-case variable names with lower-case ones
Lars Kruse <devel@sumpfralle.de>
parents:
6864
diff
changeset
|
182 :param dest_dir: |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
183 """ |
8177
e26c0616e003
py3: use global next() function instead of .next() method
Mads Kiilerich <mads@kiilerich.com>
parents:
8156
diff
changeset
|
184 added_file = '%ssetup.py' % next(_RandomNameSequence()) |
7181
07bf8445a393
tests: slight cleanup of test_vcs_operations _add_files_and_push
Mads Kiilerich <mads@kiilerich.com>
parents:
7178
diff
changeset
|
185 open(os.path.join(dest_dir, added_file), 'a').close() |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
186 Command(dest_dir).execute(vcs, 'add', added_file) |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
187 |
5981
3fff45b4c8ed
tests: set EMAIL for Git commit test_push_on_locked_repo_by_other_user_git - it _is_ necessary on some machines
domruf <dominikruf@gmail.com>
parents:
5970
diff
changeset
|
188 email = 'me@example.com' |
5966
04c82eb326fb
tests: avoid unicode in test case on Windows - the Windows command line can't easily handle "exotic" characters
domruf <dominikruf@gmail.com>
parents:
5965
diff
changeset
|
189 if os.name == 'nt': |
5981
3fff45b4c8ed
tests: set EMAIL for Git commit test_push_on_locked_repo_by_other_user_git - it _is_ necessary on some machines
domruf <dominikruf@gmail.com>
parents:
5970
diff
changeset
|
190 author_str = 'User <%s>' % email |
5966
04c82eb326fb
tests: avoid unicode in test case on Windows - the Windows command line can't easily handle "exotic" characters
domruf <dominikruf@gmail.com>
parents:
5965
diff
changeset
|
191 else: |
5981
3fff45b4c8ed
tests: set EMAIL for Git commit test_push_on_locked_repo_by_other_user_git - it _is_ necessary on some machines
domruf <dominikruf@gmail.com>
parents:
5970
diff
changeset
|
192 author_str = 'User ǝɯɐᴎ <%s>' % email |
8181
21f7b699d467
py3: automatic migration with 2to3 -f xrange
Mads Kiilerich <mads@kiilerich.com>
parents:
8177
diff
changeset
|
193 for i in range(files_no): |
5965
894ab347d808
tests: use double quotes in command lines - single quotes in command lines are not considered quotes on Windows
domruf <dominikruf@gmail.com>
parents:
5922
diff
changeset
|
194 cmd = """echo "added_line%s" >> %s""" % (i, added_file) |
7181
07bf8445a393
tests: slight cleanup of test_vcs_operations _add_files_and_push
Mads Kiilerich <mads@kiilerich.com>
parents:
7178
diff
changeset
|
195 Command(dest_dir).execute(cmd) |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
196 if vcs == 'hg': |
5965
894ab347d808
tests: use double quotes in command lines - single quotes in command lines are not considered quotes on Windows
domruf <dominikruf@gmail.com>
parents:
5922
diff
changeset
|
197 cmd = """hg commit -m "committed new %s" -u "%s" "%s" """ % ( |
3480
bc7fb3e8d77e
again they channged git return commands :/ and i need to fix the tests. Now running agains 1.8.1
Marcin Kuzminski <marcin@python-works.com>
parents:
3199
diff
changeset
|
198 i, author_str, added_file |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
199 ) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
200 elif vcs == 'git': |
5968
7db1bcf1d95b
tests: drop setting EMAIL environment variable before git commit - it doesn't work on Windows and seems unnecessary
Mads Kiilerich <madski@unity3d.com>
parents:
5967
diff
changeset
|
201 cmd = """git commit -m "committed new %s" --author "%s" "%s" """ % ( |
3480
bc7fb3e8d77e
again they channged git return commands :/ and i need to fix the tests. Now running agains 1.8.1
Marcin Kuzminski <marcin@python-works.com>
parents:
3199
diff
changeset
|
202 i, author_str, added_file |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
203 ) |
8987
d6d3cb5991e2
tests: stabilize Git committer in test_vcs_operations
Mads Kiilerich <mads@kiilerich.com>
parents:
8870
diff
changeset
|
204 Command(dest_dir).execute(cmd) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
205 |
7678
731a8466fb11
tests: refactor vcs _add_files_and_push - pass url_fixture
Mads Kiilerich <mads@kiilerich.com>
parents:
7677
diff
changeset
|
206 def _add_files_and_push(webserver, vt, dest_dir, clone_url, ignoreReturnCode=False, files_no=3): |
731a8466fb11
tests: refactor vcs _add_files_and_push - pass url_fixture
Mads Kiilerich <mads@kiilerich.com>
parents:
7677
diff
changeset
|
207 _add_files(vt.repo_type, dest_dir, files_no=files_no) |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
208 # PUSH it back |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
209 stdout = stderr = None |
7678
731a8466fb11
tests: refactor vcs _add_files_and_push - pass url_fixture
Mads Kiilerich <mads@kiilerich.com>
parents:
7677
diff
changeset
|
210 if vt.repo_type == 'hg': |
7754
76e2072b88f6
tests: push with force in test_vcs_operations.py _add_files_and_push
Mads Kiilerich <mads@kiilerich.com>
parents:
7748
diff
changeset
|
211 stdout, stderr = Command(dest_dir).execute('hg push -f --verbose', clone_url, ignoreReturnCode=ignoreReturnCode) |
7678
731a8466fb11
tests: refactor vcs _add_files_and_push - pass url_fixture
Mads Kiilerich <mads@kiilerich.com>
parents:
7677
diff
changeset
|
212 elif vt.repo_type == 'git': |
7754
76e2072b88f6
tests: push with force in test_vcs_operations.py _add_files_and_push
Mads Kiilerich <mads@kiilerich.com>
parents:
7748
diff
changeset
|
213 stdout, stderr = Command(dest_dir).execute('git push -f --verbose', clone_url, "master", ignoreReturnCode=ignoreReturnCode) |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
214 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
215 return stdout, stderr |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
216 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
217 |
7677
cffb5e5bf7d6
tests: refactor test_vcs_operations _add_files - make clone_url mandatory
Mads Kiilerich <mads@kiilerich.com>
parents:
7676
diff
changeset
|
218 def _check_outgoing(vcs, cwd, clone_url): |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
219 if vcs == 'hg': |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
220 # hg removes the password from default URLs, so we have to provide it here via the clone_url |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
221 return Command(cwd).execute('hg -q outgoing', clone_url, ignoreReturnCode=True) |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
222 elif vcs == 'git': |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
223 Command(cwd).execute('git remote update') |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
224 return Command(cwd).execute('git log origin/master..master') |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
225 |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
226 |
1047 | 227 def set_anonymous_access(enable=True): |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
228 user = db.User.get_default_user() |
1047 | 229 user.active = enable |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
230 meta.Session().commit() |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
231 if enable != db.User.get_default_user().active: |
1596
089ef495e9dd
fixed test_hg_push operations
Marcin Kuzminski <marcin@python-works.com>
parents:
1532
diff
changeset
|
232 raise Exception('Cannot set anonymous access') |
1047 | 233 |
2527
95624ce4465f
orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
234 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
235 #============================================================================== |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
236 # TESTS |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
237 #============================================================================== |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
238 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
239 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
240 def _check_proper_git_push(stdout, stderr): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
241 assert 'fatal' not in stderr |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
242 assert 'rejected' not in stderr |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
243 assert 'Pushing to' in stderr |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
244 assert 'master -> master' in stderr |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
245 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
246 |
6603
fd9b2d83d52b
tests: add context fixture to fix test_ip_restriction_hg/git
domruf <dominikruf@gmail.com>
parents:
6554
diff
changeset
|
247 @pytest.mark.usefixtures("test_context_fixture") |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
248 class TestVCSOperations(base.TestController): |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
249 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
250 @classmethod |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
251 def setup_class(cls): |
6864
7691290837d2
codingstyle: trivial whitespace fixes
Lars Kruse <devel@sumpfralle.de>
parents:
6787
diff
changeset
|
252 # DISABLE ANONYMOUS ACCESS |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
253 set_anonymous_access(False) |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
254 |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
255 @pytest.fixture() |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
256 def testhook_cleanup(self): |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
257 yield |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
258 # remove hook |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
259 for hook in ['prechangegroup', 'pretxnchangegroup', 'preoutgoing', 'changegroup', 'outgoing', 'incoming']: |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
260 entry = db.Ui.get_by_key('hooks', '%s.testhook' % hook) |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
261 if entry: |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
262 meta.Session().delete(entry) |
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
263 meta.Session().commit() |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
264 |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
265 @pytest.fixture(scope="module") |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
266 def testfork(self): |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
267 # create fork so the repo stays untouched |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
268 git_fork_name = '%s_fork%s' % (base.GIT_REPO, next(_RandomNameSequence())) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
269 fixture.create_fork(base.GIT_REPO, git_fork_name) |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
270 hg_fork_name = '%s_fork%s' % (base.HG_REPO, next(_RandomNameSequence())) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
271 fixture.create_fork(base.HG_REPO, hg_fork_name) |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
272 return {'git': git_fork_name, 'hg': hg_fork_name} |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
273 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
274 @parametrize_vcs_test |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
275 def test_clone_repo_by_admin(self, webserver, vt): |
7679
7f8fb30891e5
tests: create clone_url in VcsTest as repo_url_param - it will soon create more than just a URL when it will be used for ssh testing
Mads Kiilerich <mads@kiilerich.com>
parents:
7678
diff
changeset
|
276 clone_url = vt.repo_url_param(webserver, vt.repo_name) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
277 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir()) |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
278 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
279 if vt.repo_type == 'git': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
280 assert 'Cloning into' in stdout + stderr |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
281 assert stderr == '' or stdout == '' |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
282 elif vt.repo_type == 'hg': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
283 assert 'requesting all changes' in stdout |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
284 assert 'adding changesets' in stdout |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
285 assert 'adding manifests' in stdout |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
286 assert 'adding file changes' in stdout |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
287 assert stderr == '' |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
288 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
289 @parametrize_vcs_test_http |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
290 def test_clone_wrong_credentials(self, webserver, vt): |
7679
7f8fb30891e5
tests: create clone_url in VcsTest as repo_url_param - it will soon create more than just a URL when it will be used for ssh testing
Mads Kiilerich <mads@kiilerich.com>
parents:
7678
diff
changeset
|
291 clone_url = vt.repo_url_param(webserver, vt.repo_name, password='bad!') |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
292 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
293 if vt.repo_type == 'git': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
294 assert 'fatal: Authentication failed' in stderr |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
295 elif vt.repo_type == 'hg': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
296 assert 'abort: authorization failed' in stderr |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
297 |
6631
d7cdef68240b
tests: use webserver fixture for running vcs tests, removing need for serving manually
domruf <dominikruf@gmail.com>
parents:
6629
diff
changeset
|
298 def test_clone_git_dir_as_hg(self, webserver): |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
299 clone_url = HgHttpVcsTest.repo_url_param(webserver, base.GIT_REPO) |
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
300 stdout, stderr = Command(base.TESTS_TMP_PATH).execute('hg clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
301 assert 'HTTP Error 404: Not Found' in stderr or "not a valid repository" in stdout and 'abort:' in stderr |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
302 |
6631
d7cdef68240b
tests: use webserver fixture for running vcs tests, removing need for serving manually
domruf <dominikruf@gmail.com>
parents:
6629
diff
changeset
|
303 def test_clone_hg_repo_as_git(self, webserver): |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
304 clone_url = GitHttpVcsTest.repo_url_param(webserver, base.HG_REPO) |
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
305 stdout, stderr = Command(base.TESTS_TMP_PATH).execute('git clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3829
diff
changeset
|
306 assert 'not found' in stderr |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
307 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
308 @parametrize_vcs_test |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
309 def test_clone_non_existing_path(self, webserver, vt): |
7679
7f8fb30891e5
tests: create clone_url in VcsTest as repo_url_param - it will soon create more than just a URL when it will be used for ssh testing
Mads Kiilerich <mads@kiilerich.com>
parents:
7678
diff
changeset
|
310 clone_url = vt.repo_url_param(webserver, 'trololo') |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
311 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
312 if vt.repo_type == 'git': |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
313 assert 'not found' in stderr or 'abort: Access to %r denied' % 'trololo' in stderr |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
314 elif vt.repo_type == 'hg': |
8600
62469662c660
mercurial: support Mercurial 5.5
Mads Kiilerich <mads@kiilerich.com>
parents:
8587
diff
changeset
|
315 assert 'HTTP Error 404: Not Found' in stderr or 'abort: no suitable response from remote hg' in stderr and 'remote: abort: Access to %r denied' % 'trololo' in stdout + stderr |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
316 |
7680
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
317 @parametrize_vcs_test |
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
318 def test_push_new_repo(self, webserver, vt): |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
319 # Clear the log so we know what is added |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
320 db.UserLog.query().delete() |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
321 meta.Session().commit() |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
322 |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
323 # Create an empty server repo using the API |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
324 repo_name = 'new_%s_%s' % (vt.repo_type, next(_RandomNameSequence())) |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
325 usr = db.User.get_by_username(base.TEST_USER_ADMIN_LOGIN) |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
326 params = { |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
327 "id": 7, |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
328 "api_key": usr.api_key, |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
329 "method": 'create_repo', |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
330 "args": dict(repo_name=repo_name, |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
331 owner=base.TEST_USER_ADMIN_LOGIN, |
7680
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
332 repo_type=vt.repo_type), |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
333 } |
8188
22b40db44a41
py3: migrate from urllib2 to urllib
Mads Kiilerich <mads@kiilerich.com>
parents:
8181
diff
changeset
|
334 req = urllib.request.Request( |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
335 'http://%s:%s/_admin/api' % webserver.server_address, |
8080
e7dbe089e10d
py3: start using ascii_str and ascii_bytes - we will need it later
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
336 data=ascii_bytes(json.dumps(params)), |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
337 headers={'content-type': 'application/json'}) |
8188
22b40db44a41
py3: migrate from urllib2 to urllib
Mads Kiilerich <mads@kiilerich.com>
parents:
8181
diff
changeset
|
338 response = urllib.request.urlopen(req) |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
339 result = json.loads(response.read()) |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
340 # Expect something like: |
7680
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
341 # {u'result': {u'msg': u'Created new repository `new_XXX`', u'task': None, u'success': True}, u'id': 7, u'error': None} |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
342 assert result['result']['success'] |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
343 |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
344 # Create local clone of the empty server repo |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
345 local_clone_dir = _get_tmp_dir() |
7680
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
346 clone_url = vt.repo_url_param(webserver, repo_name) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
347 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, local_clone_dir) |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
348 |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
349 # Make 3 commits and push to the empty server repo. |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
350 # The server repo doesn't have any other heads than the |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
351 # refs/heads/master we are pushing, but the `git log` in the push hook |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
352 # should still list the 3 commits. |
7680
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
353 stdout, stderr = _add_files_and_push(webserver, vt, local_clone_dir, clone_url=clone_url) |
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
354 if vt.repo_type == 'git': |
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
355 _check_proper_git_push(stdout, stderr) |
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
356 elif vt.repo_type == 'hg': |
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
357 assert 'pushing to ' in stdout |
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
358 assert 'remote: added ' in stdout |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
359 |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
360 # Verify that we got the right events in UserLog. Expect something like: |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
361 # <UserLog('id:new_git_XXX:started_following_repo')> |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
362 # <UserLog('id:new_git_XXX:user_created_repo')> |
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
363 # <UserLog('id:new_git_XXX:pull')> |
7363
6af08d44daa8
git: fix push to empty repo (Issue 323)
Mads Kiilerich <mads@kiilerich.com>
parents:
7350
diff
changeset
|
364 # <UserLog('id:new_git_XXX:push:aed9d4c1732a1927da3be42c47eb9afdc200d427,d38b083a07af10a9f44193486959a96a23db78da,4841ff9a2b385bec995f4679ef649adb3f437622')> |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
365 meta.Session.close() # make sure SA fetches all new log entries (apparently only needed for MariaDB/MySQL ...) |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
366 action_parts = [ul.action.split(':', 1) for ul in db.UserLog.query().order_by(db.UserLog.user_log_id)] |
7680
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
367 assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == ([ |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
368 ('started_following_repo', 0), |
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
369 ('user_created_repo', 0), |
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
370 ('pull', 0), |
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
371 ('push', 3)] |
7680
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
372 if vt.repo_type == 'git' else [ |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
373 ('started_following_repo', 0), |
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
374 ('user_created_repo', 0), |
7680
1660b2c71e03
tests: make test_vcs_operations test_push_new_repo work on hg
Mads Kiilerich <mads@kiilerich.com>
parents:
7679
diff
changeset
|
375 # (u'pull', 0), # Mercurial outgoing hook is not called for empty clones |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
376 ('push', 3)]) |
7350
30b5b58cb2dc
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
377 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
378 @parametrize_vcs_test |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
379 def test_push_new_file(self, webserver, testfork, vt): |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
380 db.UserLog.query().delete() |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
381 meta.Session().commit() |
7681
ea799beea5dd
tests: better coverage of UserLog action logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7680
diff
changeset
|
382 |
6865
94bbb7eb5b64
codingstyle: replace upper-case variable names with lower-case ones
Lars Kruse <devel@sumpfralle.de>
parents:
6864
diff
changeset
|
383 dest_dir = _get_tmp_dir() |
7679
7f8fb30891e5
tests: create clone_url in VcsTest as repo_url_param - it will soon create more than just a URL when it will be used for ssh testing
Mads Kiilerich <mads@kiilerich.com>
parents:
7678
diff
changeset
|
384 clone_url = vt.repo_url_param(webserver, vt.repo_name) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
385 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
386 |
7679
7f8fb30891e5
tests: create clone_url in VcsTest as repo_url_param - it will soon create more than just a URL when it will be used for ssh testing
Mads Kiilerich <mads@kiilerich.com>
parents:
7678
diff
changeset
|
387 clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type]) |
7678
731a8466fb11
tests: refactor vcs _add_files_and_push - pass url_fixture
Mads Kiilerich <mads@kiilerich.com>
parents:
7677
diff
changeset
|
388 stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, clone_url=clone_url) |
1047 | 389 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
390 if vt.repo_type == 'git': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
391 _check_proper_git_push(stdout, stderr) |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
392 elif vt.repo_type == 'hg': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
393 assert 'pushing to' in stdout |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
394 assert 'Repository size' in stdout |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
395 assert 'Last revision is now' in stdout |
3617
b5c3680e7c76
added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents:
3480
diff
changeset
|
396 |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
397 meta.Session.close() # make sure SA fetches all new log entries (apparently only needed for MariaDB/MySQL ...) |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
398 action_parts = [ul.action.split(':', 1) for ul in db.UserLog.query().order_by(db.UserLog.user_log_id)] |
7681
ea799beea5dd
tests: better coverage of UserLog action logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7680
diff
changeset
|
399 assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == \ |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
400 [('pull', 0), ('push', 3)] |
7681
ea799beea5dd
tests: better coverage of UserLog action logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7680
diff
changeset
|
401 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
402 @parametrize_vcs_test |
7744
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
403 def test_pull(self, webserver, testfork, vt): |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
404 db.UserLog.query().delete() |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
405 meta.Session().commit() |
7744
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
406 |
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
407 dest_dir = _get_tmp_dir() |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
408 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'init', dest_dir) |
7744
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
409 |
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
410 clone_url = vt.repo_url_param(webserver, vt.repo_name) |
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
411 stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url) |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
412 meta.Session.close() # make sure SA fetches all new log entries (apparently only needed for MariaDB/MySQL ...) |
7744
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
413 |
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
414 if vt.repo_type == 'git': |
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
415 assert 'FETCH_HEAD' in stderr |
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
416 elif vt.repo_type == 'hg': |
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
417 assert 'new changesets' in stdout |
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
418 |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
419 action_parts = [ul.action for ul in db.UserLog.query().order_by(db.UserLog.user_log_id)] |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
420 assert action_parts == ['pull'] |
7744
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
421 |
8146
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
422 # Test handling of URLs with extra '/' around repo_name |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
423 stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url.replace('/' + vt.repo_name, '/./%s/' % vt.repo_name), ignoreReturnCode=True) |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
424 if issubclass(vt, HttpVcsTest): |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
425 if vt.repo_type == 'git': |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
426 # NOTE: when pulling from http://hostname/./vcs_test_git/ , the git client will normalize that and issue an HTTP request to /vcs_test_git/info/refs |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
427 assert 'Already up to date.' in stdout |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
428 else: |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
429 assert vt.repo_type == 'hg' |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
430 assert "abort: HTTP Error 404: Not Found" in stderr |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
431 else: |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
432 assert issubclass(vt, SshVcsTest) |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
433 if vt.repo_type == 'git': |
8148
7163feda7140
ssh: ignore trailing '/' after repo name in URLs (Issue #352)
Mads Kiilerich <mads@kiilerich.com>
parents:
8146
diff
changeset
|
434 assert "abort: Access to './%s' denied" % vt.repo_name in stderr |
8146
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
435 else: |
8600
62469662c660
mercurial: support Mercurial 5.5
Mads Kiilerich <mads@kiilerich.com>
parents:
8587
diff
changeset
|
436 assert "abort: Access to './%s' denied" % vt.repo_name in stdout + stderr |
8146
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
437 |
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
438 stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url.replace('/' + vt.repo_name, '/%s/' % vt.repo_name), ignoreReturnCode=True) |
8148
7163feda7140
ssh: ignore trailing '/' after repo name in URLs (Issue #352)
Mads Kiilerich <mads@kiilerich.com>
parents:
8146
diff
changeset
|
439 if vt.repo_type == 'git': |
7163feda7140
ssh: ignore trailing '/' after repo name in URLs (Issue #352)
Mads Kiilerich <mads@kiilerich.com>
parents:
8146
diff
changeset
|
440 assert 'Already up to date.' in stdout |
8146
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
441 else: |
8148
7163feda7140
ssh: ignore trailing '/' after repo name in URLs (Issue #352)
Mads Kiilerich <mads@kiilerich.com>
parents:
8146
diff
changeset
|
442 assert vt.repo_type == 'hg' |
7163feda7140
ssh: ignore trailing '/' after repo name in URLs (Issue #352)
Mads Kiilerich <mads@kiilerich.com>
parents:
8146
diff
changeset
|
443 assert "no changes found" in stdout |
7163feda7140
ssh: ignore trailing '/' after repo name in URLs (Issue #352)
Mads Kiilerich <mads@kiilerich.com>
parents:
8146
diff
changeset
|
444 assert "denied" not in stderr |
7163feda7140
ssh: ignore trailing '/' after repo name in URLs (Issue #352)
Mads Kiilerich <mads@kiilerich.com>
parents:
8146
diff
changeset
|
445 assert "denied" not in stdout |
7163feda7140
ssh: ignore trailing '/' after repo name in URLs (Issue #352)
Mads Kiilerich <mads@kiilerich.com>
parents:
8146
diff
changeset
|
446 assert "404" not in stdout |
8146
042554aec0ac
tests: add coverage for SSH and HTTP URLs with extra '/'
Mads Kiilerich <mads@kiilerich.com>
parents:
7844
diff
changeset
|
447 |
7744
b5fe8bc0b939
tests: introduce test_vcs_operations test_pull with explicit testing of pull operations and their logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7743
diff
changeset
|
448 @parametrize_vcs_test |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
449 def test_push_invalidates_cache(self, webserver, testfork, vt): |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
450 pre_cached_tip = [repo.get_api_data()['last_changeset']['short_id'] for repo in db.Repository.query().filter(db.Repository.repo_name == testfork[vt.repo_type])] |
7683
b8551ceab448
tests: verify in vcs test_push_invalidates_cache that the push hook actually updates the cache
Mads Kiilerich <mads@kiilerich.com>
parents:
7682
diff
changeset
|
451 |
6865
94bbb7eb5b64
codingstyle: replace upper-case variable names with lower-case ones
Lars Kruse <devel@sumpfralle.de>
parents:
6864
diff
changeset
|
452 dest_dir = _get_tmp_dir() |
7679
7f8fb30891e5
tests: create clone_url in VcsTest as repo_url_param - it will soon create more than just a URL when it will be used for ssh testing
Mads Kiilerich <mads@kiilerich.com>
parents:
7678
diff
changeset
|
453 clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type]) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
454 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
455 |
7678
731a8466fb11
tests: refactor vcs _add_files_and_push - pass url_fixture
Mads Kiilerich <mads@kiilerich.com>
parents:
7677
diff
changeset
|
456 stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, files_no=1, clone_url=clone_url) |
3617
b5c3680e7c76
added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents:
3480
diff
changeset
|
457 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
458 if vt.repo_type == 'git': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
459 _check_proper_git_push(stdout, stderr) |
7683
b8551ceab448
tests: verify in vcs test_push_invalidates_cache that the push hook actually updates the cache
Mads Kiilerich <mads@kiilerich.com>
parents:
7682
diff
changeset
|
460 |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
461 meta.Session.close() # expire session to make sure SA fetches new Repository instances after last_changeset has been updated by server side hook in another process |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
462 post_cached_tip = [repo.get_api_data()['last_changeset']['short_id'] for repo in db.Repository.query().filter(db.Repository.repo_name == testfork[vt.repo_type])] |
7683
b8551ceab448
tests: verify in vcs test_push_invalidates_cache that the push hook actually updates the cache
Mads Kiilerich <mads@kiilerich.com>
parents:
7682
diff
changeset
|
463 assert pre_cached_tip != post_cached_tip |
b8551ceab448
tests: verify in vcs test_push_invalidates_cache that the push hook actually updates the cache
Mads Kiilerich <mads@kiilerich.com>
parents:
7682
diff
changeset
|
464 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
465 @parametrize_vcs_test_http |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
466 def test_push_wrong_credentials(self, webserver, vt): |
6865
94bbb7eb5b64
codingstyle: replace upper-case variable names with lower-case ones
Lars Kruse <devel@sumpfralle.de>
parents:
6864
diff
changeset
|
467 dest_dir = _get_tmp_dir() |
7679
7f8fb30891e5
tests: create clone_url in VcsTest as repo_url_param - it will soon create more than just a URL when it will be used for ssh testing
Mads Kiilerich <mads@kiilerich.com>
parents:
7678
diff
changeset
|
468 clone_url = vt.repo_url_param(webserver, vt.repo_name) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
469 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
2527
95624ce4465f
orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
470 |
7677
cffb5e5bf7d6
tests: refactor test_vcs_operations _add_files - make clone_url mandatory
Mads Kiilerich <mads@kiilerich.com>
parents:
7676
diff
changeset
|
471 clone_url = webserver.repo_url(vt.repo_name, username='bad', password='name') |
7678
731a8466fb11
tests: refactor vcs _add_files_and_push - pass url_fixture
Mads Kiilerich <mads@kiilerich.com>
parents:
7677
diff
changeset
|
472 stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, |
7677
cffb5e5bf7d6
tests: refactor test_vcs_operations _add_files - make clone_url mandatory
Mads Kiilerich <mads@kiilerich.com>
parents:
7676
diff
changeset
|
473 clone_url=clone_url, ignoreReturnCode=True) |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
474 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
475 if vt.repo_type == 'git': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
476 assert 'fatal: Authentication failed' in stderr |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
477 elif vt.repo_type == 'hg': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
478 assert 'abort: authorization failed' in stderr |
2527
95624ce4465f
orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
479 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
480 @parametrize_vcs_test |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
481 def test_push_with_readonly_credentials(self, webserver, vt): |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
482 db.UserLog.query().delete() |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
483 meta.Session().commit() |
7681
ea799beea5dd
tests: better coverage of UserLog action logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7680
diff
changeset
|
484 |
7178
b752e8e27e76
tests: add test_push_with_readonly_credentials
domruf <dominikruf@gmail.com>
parents:
6865
diff
changeset
|
485 dest_dir = _get_tmp_dir() |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
486 clone_url = vt.repo_url_param(webserver, vt.repo_name, username=base.TEST_USER_REGULAR_LOGIN, password=base.TEST_USER_REGULAR_PASS) |
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
487 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
7178
b752e8e27e76
tests: add test_push_with_readonly_credentials
domruf <dominikruf@gmail.com>
parents:
6865
diff
changeset
|
488 |
7678
731a8466fb11
tests: refactor vcs _add_files_and_push - pass url_fixture
Mads Kiilerich <mads@kiilerich.com>
parents:
7677
diff
changeset
|
489 stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, ignoreReturnCode=True, clone_url=clone_url) |
7178
b752e8e27e76
tests: add test_push_with_readonly_credentials
domruf <dominikruf@gmail.com>
parents:
6865
diff
changeset
|
490 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
491 if vt.repo_type == 'git': |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
492 assert 'The requested URL returned error: 403' in stderr or 'abort: Push access to %r denied' % str(vt.repo_name) in stderr |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
493 elif vt.repo_type == 'hg': |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
494 assert 'abort: HTTP Error 403: Forbidden' in stderr or 'abort: push failed on remote' in stderr and 'remote: Push access to %r denied' % str(vt.repo_name) in stdout |
7178
b752e8e27e76
tests: add test_push_with_readonly_credentials
domruf <dominikruf@gmail.com>
parents:
6865
diff
changeset
|
495 |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
496 meta.Session.close() # make sure SA fetches all new log entries (apparently only needed for MariaDB/MySQL ...) |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
497 action_parts = [ul.action.split(':', 1) for ul in db.UserLog.query().order_by(db.UserLog.user_log_id)] |
7681
ea799beea5dd
tests: better coverage of UserLog action logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7680
diff
changeset
|
498 assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == \ |
8224
e63bcce18fef
py3: automatic migration with 2to3 -f unicode
Mads Kiilerich <mads@kiilerich.com>
parents:
8206
diff
changeset
|
499 [('pull', 0)] |
7681
ea799beea5dd
tests: better coverage of UserLog action logging
Mads Kiilerich <mads@kiilerich.com>
parents:
7680
diff
changeset
|
500 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
501 @parametrize_vcs_test |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
502 def test_push_back_to_wrong_url(self, webserver, vt): |
6865
94bbb7eb5b64
codingstyle: replace upper-case variable names with lower-case ones
Lars Kruse <devel@sumpfralle.de>
parents:
6864
diff
changeset
|
503 dest_dir = _get_tmp_dir() |
7679
7f8fb30891e5
tests: create clone_url in VcsTest as repo_url_param - it will soon create more than just a URL when it will be used for ssh testing
Mads Kiilerich <mads@kiilerich.com>
parents:
7678
diff
changeset
|
504 clone_url = vt.repo_url_param(webserver, vt.repo_name) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
505 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
506 |
6865
94bbb7eb5b64
codingstyle: replace upper-case variable names with lower-case ones
Lars Kruse <devel@sumpfralle.de>
parents:
6864
diff
changeset
|
507 stdout, stderr = _add_files_and_push( |
7678
731a8466fb11
tests: refactor vcs _add_files_and_push - pass url_fixture
Mads Kiilerich <mads@kiilerich.com>
parents:
7677
diff
changeset
|
508 webserver, vt, dest_dir, clone_url='http://%s:%s/tmp' % ( |
6865
94bbb7eb5b64
codingstyle: replace upper-case variable names with lower-case ones
Lars Kruse <devel@sumpfralle.de>
parents:
6864
diff
changeset
|
509 webserver.server_address[0], webserver.server_address[1]), |
94bbb7eb5b64
codingstyle: replace upper-case variable names with lower-case ones
Lars Kruse <devel@sumpfralle.de>
parents:
6864
diff
changeset
|
510 ignoreReturnCode=True) |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
511 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
512 if vt.repo_type == 'git': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
513 assert 'not found' in stderr |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
514 elif vt.repo_type == 'hg': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
515 assert 'HTTP Error 404: Not Found' in stderr |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
516 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
517 @parametrize_vcs_test |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
518 def test_ip_restriction(self, webserver, vt): |
3131
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
519 user_model = UserModel() |
3180
3472d8f37e6d
fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents:
3131
diff
changeset
|
520 try: |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
521 # Add IP constraint that excludes the test context: |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
522 user_model.add_extra_ip(base.TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
523 meta.Session().commit() |
7277
0cf121eae2fe
tests: fix caching issue in test_ip_restriction_git
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
7265
diff
changeset
|
524 # IP permissions are cached, need to wait for the cache in the server process to expire |
0cf121eae2fe
tests: fix caching issue in test_ip_restriction_git
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
7265
diff
changeset
|
525 time.sleep(1.5) |
7679
7f8fb30891e5
tests: create clone_url in VcsTest as repo_url_param - it will soon create more than just a URL when it will be used for ssh testing
Mads Kiilerich <mads@kiilerich.com>
parents:
7678
diff
changeset
|
526 clone_url = vt.repo_url_param(webserver, vt.repo_name) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
527 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
528 if vt.repo_type == 'git': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
529 # The message apparently changed in Git 1.8.3, so match it loosely. |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
530 assert re.search(r'\b403\b', stderr) or 'abort: User test_admin from 127.0.0.127 cannot be authorized' in stderr |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
531 elif vt.repo_type == 'hg': |
8600
62469662c660
mercurial: support Mercurial 5.5
Mads Kiilerich <mads@kiilerich.com>
parents:
8587
diff
changeset
|
532 assert 'abort: HTTP Error 403: Forbidden' in stderr or 'remote: abort: User test_admin from 127.0.0.127 cannot be authorized' in stdout + stderr |
3180
3472d8f37e6d
fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents:
3131
diff
changeset
|
533 finally: |
6864
7691290837d2
codingstyle: trivial whitespace fixes
Lars Kruse <devel@sumpfralle.de>
parents:
6787
diff
changeset
|
534 # release IP restrictions |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
535 for ip in db.UserIpMap.query(): |
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
536 db.UserIpMap.delete(ip.ip_id) |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
537 meta.Session().commit() |
7277
0cf121eae2fe
tests: fix caching issue in test_ip_restriction_git
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
7265
diff
changeset
|
538 # IP permissions are cached, need to wait for the cache in the server process to expire |
0cf121eae2fe
tests: fix caching issue in test_ip_restriction_git
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
7265
diff
changeset
|
539 time.sleep(1.5) |
6140
ee88c8c07111
tests: remove sleep hack to expire sql_cache_short
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
6116
diff
changeset
|
540 |
7679
7f8fb30891e5
tests: create clone_url in VcsTest as repo_url_param - it will soon create more than just a URL when it will be used for ssh testing
Mads Kiilerich <mads@kiilerich.com>
parents:
7678
diff
changeset
|
541 clone_url = vt.repo_url_param(webserver, vt.repo_name) |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
542 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir()) |
3131
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
543 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
544 if vt.repo_type == 'git': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
545 assert 'Cloning into' in stdout + stderr |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
546 assert stderr == '' or stdout == '' |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
547 elif vt.repo_type == 'hg': |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
548 assert 'requesting all changes' in stdout |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
549 assert 'adding changesets' in stdout |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
550 assert 'adding manifests' in stdout |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
551 assert 'adding file changes' in stdout |
6140
ee88c8c07111
tests: remove sleep hack to expire sql_cache_short
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
6116
diff
changeset
|
552 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
553 assert stderr == '' |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
554 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
555 @parametrize_vcs_test_hg # git hooks doesn't work like hg hooks |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
556 def test_custom_hooks_preoutgoing(self, testhook_cleanup, webserver, testfork, vt): |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
557 # set prechangegroup to failing hook (returns True) |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
558 db.Ui.create_or_update_hook('preoutgoing.testhook', 'python:kallithea.tests.fixture.failing_test_hook') |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
559 meta.Session().commit() |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
560 # clone repo |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
561 clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type], username=base.TEST_USER_ADMIN_LOGIN, password=base.TEST_USER_ADMIN_PASS) |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
562 dest_dir = _get_tmp_dir() |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
563 stdout, stderr = Command(base.TESTS_TMP_PATH) \ |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
564 .execute(vt.repo_type, 'clone', clone_url, dest_dir, ignoreReturnCode=True) |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
565 if vt.repo_type == 'hg': |
8870
01e123180339
hg: support Mercurial 5.8
Mads Kiilerich <mads@kiilerich.com>
parents:
8687
diff
changeset
|
566 assert 'preoutgoing.testhook hook failed' in stdout + stderr |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
567 elif vt.repo_type == 'git': |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
568 assert 'error: 406' in stderr |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
569 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
570 @parametrize_vcs_test_hg # git hooks doesn't work like hg hooks |
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
571 def test_custom_hooks_prechangegroup(self, testhook_cleanup, webserver, testfork, vt): |
7743
310f557d06ca
tests: minor clean-up of test_vcs_operations test_custom_hooks_prechangegroup - the test is Mercurial only
Mads Kiilerich <mads@kiilerich.com>
parents:
7733
diff
changeset
|
572 # set prechangegroup to failing hook (returns exit code 1) |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
573 db.Ui.create_or_update_hook('prechangegroup.testhook', 'python:kallithea.tests.fixture.failing_test_hook') |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
574 meta.Session().commit() |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
575 # clone repo |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
576 clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type], username=base.TEST_USER_ADMIN_LOGIN, password=base.TEST_USER_ADMIN_PASS) |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
577 dest_dir = _get_tmp_dir() |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
578 stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
579 |
7678
731a8466fb11
tests: refactor vcs _add_files_and_push - pass url_fixture
Mads Kiilerich <mads@kiilerich.com>
parents:
7677
diff
changeset
|
580 stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, clone_url, |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
581 ignoreReturnCode=True) |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
582 assert 'failing_test_hook failed' in stdout + stderr |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
583 assert 'Traceback' not in stdout + stderr |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
584 assert 'prechangegroup.testhook hook failed' in stdout + stderr |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
585 # there are still outgoing changesets |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
586 stdout, stderr = _check_outgoing(vt.repo_type, dest_dir, clone_url) |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
587 assert stdout != '' |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
588 |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
589 # set prechangegroup hook to exception throwing method |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
590 db.Ui.create_or_update_hook('prechangegroup.testhook', 'python:kallithea.tests.fixture.exception_test_hook') |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
591 meta.Session().commit() |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
592 # re-try to push |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
593 stdout, stderr = Command(dest_dir).execute('%s push' % vt.repo_type, clone_url, ignoreReturnCode=True) |
7743
310f557d06ca
tests: minor clean-up of test_vcs_operations test_custom_hooks_prechangegroup - the test is Mercurial only
Mads Kiilerich <mads@kiilerich.com>
parents:
7733
diff
changeset
|
594 if vt is HgHttpVcsTest: |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
595 # like with 'hg serve...' 'HTTP Error 500: INTERNAL SERVER ERROR' should be returned |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
596 assert 'HTTP Error 500: INTERNAL SERVER ERROR' in stderr |
7776
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
597 elif vt is HgSshVcsTest: |
8f3cf5d00d7f
tests: run vcs tests on ssh too
Mads Kiilerich <mads@kiilerich.com>
parents:
7754
diff
changeset
|
598 assert 'remote: Exception: exception_test_hook threw an exception' in stdout |
7743
310f557d06ca
tests: minor clean-up of test_vcs_operations test_custom_hooks_prechangegroup - the test is Mercurial only
Mads Kiilerich <mads@kiilerich.com>
parents:
7733
diff
changeset
|
599 else: assert False |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
600 # there are still outgoing changesets |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
601 stdout, stderr = _check_outgoing(vt.repo_type, dest_dir, clone_url) |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
602 assert stdout != '' |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
603 |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
604 # set prechangegroup hook to method that returns False |
8687
5e46f73f0d1c
model: always import the whole db module - drop "from" imports
Mads Kiilerich <mads@kiilerich.com>
parents:
8686
diff
changeset
|
605 db.Ui.create_or_update_hook('prechangegroup.testhook', 'python:kallithea.tests.fixture.passing_test_hook') |
8686
b095e2fbba44
model: always import whole meta module - also when referencing Session
Mads Kiilerich <mads@kiilerich.com>
parents:
8667
diff
changeset
|
606 meta.Session().commit() |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
607 # re-try to push |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
608 stdout, stderr = Command(dest_dir).execute('%s push' % vt.repo_type, clone_url, ignoreReturnCode=True) |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
609 assert 'passing_test_hook succeeded' in stdout + stderr |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
610 assert 'Traceback' not in stdout + stderr |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
611 assert 'prechangegroup.testhook hook failed' not in stdout + stderr |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
612 # no more outgoing changesets |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
613 stdout, stderr = _check_outgoing(vt.repo_type, dest_dir, clone_url) |
7187
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
614 assert stdout == '' |
522cfb2be9e1
tests: add custom hook tests
domruf <dominikruf@gmail.com>
parents:
7182
diff
changeset
|
615 assert stderr == '' |
7197
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
616 |
7676
902cbe668001
tests: run the same vcs tests both for hg and git using http ... and soon also ssh
domruf <dominikruf@gmail.com>
parents:
7672
diff
changeset
|
617 def test_add_submodule_git(self, webserver, testfork): |
7197
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
618 dest_dir = _get_tmp_dir() |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
619 clone_url = GitHttpVcsTest.repo_url_param(webserver, base.GIT_REPO) |
7197
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
620 |
7679
7f8fb30891e5
tests: create clone_url in VcsTest as repo_url_param - it will soon create more than just a URL when it will be used for ssh testing
Mads Kiilerich <mads@kiilerich.com>
parents:
7678
diff
changeset
|
621 fork_url = GitHttpVcsTest.repo_url_param(webserver, testfork['git']) |
7197
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
622 |
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
623 # add submodule |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
624 stdout, stderr = Command(base.TESTS_TMP_PATH).execute('git clone', fork_url, dest_dir) |
7197
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
625 stdout, stderr = Command(dest_dir).execute('git submodule add', clone_url, 'testsubmodule') |
8987
d6d3cb5991e2
tests: stabilize Git committer in test_vcs_operations
Mads Kiilerich <mads@kiilerich.com>
parents:
8870
diff
changeset
|
626 stdout, stderr = Command(dest_dir).execute('git commit -am "added testsubmodule pointing to', clone_url, '"') |
7197
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
627 stdout, stderr = Command(dest_dir).execute('git push', fork_url, 'master') |
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
628 |
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
629 # check for testsubmodule link in files page |
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
630 self.log_user() |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
631 response = self.app.get(base.url(controller='files', action='index', |
7264
760e65b33a2b
tests: use testfork fixture for test_vcs_operations tests
domruf <dominikruf@gmail.com>
parents:
7203
diff
changeset
|
632 repo_name=testfork['git'], |
7197
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
633 revision='tip', |
47c8221a6169
git: add a bit of submodule test coverage
domruf <dominikruf@gmail.com>
parents:
7196
diff
changeset
|
634 f_path='/')) |
7748
fd03ac0708cf
files: keep _repo_files_url as "global" const variable
Mads Kiilerich <mads@kiilerich.com>
parents:
7744
diff
changeset
|
635 # check _repo_files_url that will be used to reload as AJAX |
fd03ac0708cf
files: keep _repo_files_url as "global" const variable
Mads Kiilerich <mads@kiilerich.com>
parents:
7744
diff
changeset
|
636 response.mustcontain('var _repo_files_url = ("/%s/files/");' % testfork['git']) |
fd03ac0708cf
files: keep _repo_files_url as "global" const variable
Mads Kiilerich <mads@kiilerich.com>
parents:
7744
diff
changeset
|
637 |
7203
43c9da9eed11
git: open submodule links in a new tab
domruf <dominikruf@gmail.com>
parents:
7202
diff
changeset
|
638 response.mustcontain('<a class="submodule-dir" href="%s" target="_blank"><i class="icon-file-submodule"></i><span>testsubmodule @ ' % clone_url) |
7198
1c56ba483b84
git: additional submodule redirection test coverage
Mads Kiilerich <mads@kiilerich.com>
parents:
7197
diff
changeset
|
639 |
1c56ba483b84
git: additional submodule redirection test coverage
Mads Kiilerich <mads@kiilerich.com>
parents:
7197
diff
changeset
|
640 # check that following a submodule link actually works - and redirects |
8109
e527cc2ce8dc
cleanup: get rid of most "import *"
Mads Kiilerich <mads@kiilerich.com>
parents:
8080
diff
changeset
|
641 response = self.app.get(base.url(controller='files', action='index', |
7264
760e65b33a2b
tests: use testfork fixture for test_vcs_operations tests
domruf <dominikruf@gmail.com>
parents:
7203
diff
changeset
|
642 repo_name=testfork['git'], |
7198
1c56ba483b84
git: additional submodule redirection test coverage
Mads Kiilerich <mads@kiilerich.com>
parents:
7197
diff
changeset
|
643 revision='tip', |
1c56ba483b84
git: additional submodule redirection test coverage
Mads Kiilerich <mads@kiilerich.com>
parents:
7197
diff
changeset
|
644 f_path='/testsubmodule'), |
7202
48f7c2aed3b7
git: fix links to nodes that are submodule links
domruf <dominikruf@gmail.com>
parents:
7200
diff
changeset
|
645 status=302) |
48f7c2aed3b7
git: fix links to nodes that are submodule links
domruf <dominikruf@gmail.com>
parents:
7200
diff
changeset
|
646 assert response.location == clone_url |