##// END OF EJS Templates
fix(tests): fixed svn tests cases when interactive prompt was displayed
super-admin -
r5469:e7062d28 default
parent child Browse files
Show More
@@ -158,8 +158,14 b' def _add_files_and_push(vcs, dest, clone'
158 f'{git_ident} && git push --verbose --tags {clone_url} {target_branch}'
158 f'{git_ident} && git push --verbose --tags {clone_url} {target_branch}'
159 )
159 )
160 elif vcs == 'svn':
160 elif vcs == 'svn':
161 username = kwargs.pop('username', '')
162 password = kwargs.pop('password', '')
163 auth = ''
164 if username and password:
165 auth = f'--username {username} --password {password}'
166
161 stdout, stderr = Command(cwd).execute(
167 stdout, stderr = Command(cwd).execute(
162 f'svn ci -m "pushing to {target_branch}"'
168 f'svn commit --no-auth-cache --non-interactive {auth} -m "pushing to {target_branch}"'
163 )
169 )
164
170
165 return stdout, stderr
171 return stdout, stderr
@@ -41,6 +41,14 b' from rhodecode.tests.vcs_operations impo'
41 _add_files_and_push, SVN_REPO_WITH_GROUP)
41 _add_files_and_push, SVN_REPO_WITH_GROUP)
42
42
43
43
44 def get_cli_flags(username, password):
45 flags = '--no-auth-cache --non-interactive'
46 auth = ''
47 if username and password:
48 auth = f'--username {username} --password {password}'
49 return flags, auth
50
51
44 @pytest.mark.usefixtures("disable_locking", "disable_anonymous_user")
52 @pytest.mark.usefixtures("disable_locking", "disable_anonymous_user")
45 class TestVCSOperations(object):
53 class TestVCSOperations(object):
46
54
@@ -50,8 +58,11 b' class TestVCSOperations(object):'
50
58
51 cmd = Command('/tmp')
59 cmd = Command('/tmp')
52
60
53 auth = f'--non-interactive --username={username} --password={password}'
61 flags, auth = get_cli_flags(username, password)
54 stdout, stderr = cmd.execute(f'svn checkout {auth}', clone_url, tmpdir.strpath)
62
63 stdout, stderr = Command('/tmp').execute(
64 f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
65
55 _check_proper_clone(stdout, stderr, 'svn')
66 _check_proper_clone(stdout, stderr, 'svn')
56 cmd.assert_returncode_success()
67 cmd.assert_returncode_success()
57
68
@@ -61,8 +72,12 b' class TestVCSOperations(object):'
61
72
62 clone_url = rc_web_server.repo_clone_url('_%s' % repo_id)
73 clone_url = rc_web_server.repo_clone_url('_%s' % repo_id)
63 cmd = Command('/tmp')
74 cmd = Command('/tmp')
64 auth = f'--non-interactive --username={username} --password={password}'
75
65 stdout, stderr = cmd.execute(f'svn checkout {auth}', clone_url, tmpdir.strpath)
76 flags, auth = get_cli_flags(username, password)
77
78 stdout, stderr = Command('/tmp').execute(
79 f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
80
66 _check_proper_clone(stdout, stderr, 'svn')
81 _check_proper_clone(stdout, stderr, 'svn')
67 cmd.assert_returncode_success()
82 cmd.assert_returncode_success()
68
83
@@ -70,9 +85,11 b' class TestVCSOperations(object):'
70 clone_url = rc_web_server.repo_clone_url(SVN_REPO_WITH_GROUP)
85 clone_url = rc_web_server.repo_clone_url(SVN_REPO_WITH_GROUP)
71 username, password = rc_web_server.repo_clone_credentials()
86 username, password = rc_web_server.repo_clone_credentials()
72
87
73 cmd = Command('/tmp')
88 flags, auth = get_cli_flags(username, password)
74 auth = f'--non-interactive --username={username} --password={password}'
89
75 stdout, stderr = cmd.execute(f'svn checkout {auth}', clone_url, tmpdir.strpath)
90 stdout, stderr = Command('/tmp').execute(
91 f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
92
76 _check_proper_clone(stdout, stderr, 'svn')
93 _check_proper_clone(stdout, stderr, 'svn')
77 cmd.assert_returncode_success()
94 cmd.assert_returncode_success()
78
95
@@ -81,14 +98,20 b' class TestVCSOperations(object):'
81 username, password = rc_web_server.repo_clone_credentials()
98 username, password = rc_web_server.repo_clone_credentials()
82 password = 'bad-password'
99 password = 'bad-password'
83
100
84 auth = f'--non-interactive --username={username} --password={password}'
101 flags, auth = get_cli_flags(username, password)
102
85 stdout, stderr = Command('/tmp').execute(
103 stdout, stderr = Command('/tmp').execute(
86 f'svn checkout {auth}', clone_url, tmpdir.strpath)
104 f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
87 assert 'fatal: Authentication failed' in stderr
105 assert 'fatal: Authentication failed' in stderr
88
106
89 def test_clone_svn_with_slashes(self, rc_web_server, tmpdir):
107 def test_clone_svn_with_slashes(self, rc_web_server, tmpdir):
90 clone_url = rc_web_server.repo_clone_url('//' + SVN_REPO)
108 clone_url = rc_web_server.repo_clone_url('//' + SVN_REPO)
91 stdout, stderr = Command('/tmp').execute('svn checkout', clone_url)
109 username, password = '', ''
110 flags, auth = get_cli_flags(username, password)
111
112 stdout, stderr = Command('/tmp').execute(
113 f'svn checkout {flags} {auth}', clone_url)
114
92 assert 'not found' in stderr
115 assert 'not found' in stderr
93
116
94 def test_clone_existing_path_svn_not_in_database(
117 def test_clone_existing_path_svn_not_in_database(
@@ -96,10 +119,10 b' class TestVCSOperations(object):'
96 db_name = fs_repo_only('not-in-db-git', repo_type='git')
119 db_name = fs_repo_only('not-in-db-git', repo_type='git')
97 clone_url = rc_web_server.repo_clone_url(db_name)
120 clone_url = rc_web_server.repo_clone_url(db_name)
98 username, password = '', ''
121 username, password = '', ''
99 auth = f'--non-interactive --username={username} --password={password}'
122 flags, auth = get_cli_flags(username, password)
100
123
101 stdout, stderr = Command('/tmp').execute(
124 stdout, stderr = Command('/tmp').execute(
102 f'svn checkout {auth}', clone_url, tmpdir.strpath)
125 f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
103 assert 'not found' in stderr
126 assert 'not found' in stderr
104
127
105 def test_clone_existing_path_svn_not_in_database_different_scm(
128 def test_clone_existing_path_svn_not_in_database_different_scm(
@@ -108,9 +131,10 b' class TestVCSOperations(object):'
108 clone_url = rc_web_server.repo_clone_url(db_name)
131 clone_url = rc_web_server.repo_clone_url(db_name)
109
132
110 username, password = '', ''
133 username, password = '', ''
111 auth = f'--non-interactive --username={username} --password={password}'
134 flags, auth = get_cli_flags(username, password)
135
112 stdout, stderr = Command('/tmp').execute(
136 stdout, stderr = Command('/tmp').execute(
113 f'svn checkout {auth}', clone_url, tmpdir.strpath)
137 f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
114 assert 'not found' in stderr
138 assert 'not found' in stderr
115
139
116 def test_clone_non_existing_store_path_svn(self, rc_web_server, tmpdir, user_util):
140 def test_clone_non_existing_store_path_svn(self, rc_web_server, tmpdir, user_util):
@@ -121,57 +145,60 b' class TestVCSOperations(object):'
121 RepoModel()._delete_filesystem_repo(repo)
145 RepoModel()._delete_filesystem_repo(repo)
122
146
123 username, password = '', ''
147 username, password = '', ''
124 auth = f'--non-interactive --username={username} --password={password}'
148 flags, auth = get_cli_flags(username, password)
149
125 stdout, stderr = Command('/tmp').execute(
150 stdout, stderr = Command('/tmp').execute(
126 f'svn checkout {auth}', clone_url, tmpdir.strpath)
151 f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
127 assert 'not found' in stderr
152 assert 'not found' in stderr
128
153
129 def test_push_new_file_svn(self, rc_web_server, tmpdir):
154 def test_push_new_file_svn(self, rc_web_server, tmpdir):
130 clone_url = rc_web_server.repo_clone_url(SVN_REPO)
155 clone_url = rc_web_server.repo_clone_url(SVN_REPO)
131 username, password = '', ''
156 username, password = '', ''
132 auth = f'--non-interactive --username={username} --password={password}'
157 flags, auth = get_cli_flags(username, password)
133
158
134 stdout, stderr = Command('/tmp').execute(
159 stdout, stderr = Command('/tmp').execute(
135 f'svn checkout {auth}', clone_url, tmpdir.strpath)
160 f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
136
161
137 # commit some stuff into this repo
162 # commit some stuff into this repo
138 stdout, stderr = _add_files_and_push(
163 stdout, stderr = _add_files_and_push(
139 'svn', tmpdir.strpath, clone_url=clone_url)
164 'svn', tmpdir.strpath, clone_url=clone_url, username=username, password=password)
140
165
141 _check_proper_svn_push(stdout, stderr)
166 _check_proper_svn_push(stdout, stderr)
142
167
143 def test_push_wrong_credentials_svn(self, rc_web_server, tmpdir):
168 def test_push_wrong_credentials_svn(self, rc_web_server, tmpdir):
144 clone_url = rc_web_server.repo_clone_url(SVN_REPO)
169 clone_url = rc_web_server.repo_clone_url(SVN_REPO)
145
170
146 username, password = '', ''
171 username, password = rc_web_server.repo_clone_credentials()
147 auth = f'--non-interactive --username={username} --password={password}'
172 flags, auth = get_cli_flags(username, password)
173
148 stdout, stderr = Command('/tmp').execute(
174 stdout, stderr = Command('/tmp').execute(
149 f'svn checkout {auth}', clone_url, tmpdir.strpath)
175 f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
150
176
151 push_url = rc_web_server.repo_clone_url(
177 push_url = rc_web_server.repo_clone_url(
152 SVN_REPO, user='bad', passwd='name')
178 SVN_REPO, user='bad', passwd='name')
153 stdout, stderr = _add_files_and_push(
179 stdout, stderr = _add_files_and_push(
154 'svn', tmpdir.strpath, clone_url=push_url)
180 'svn', tmpdir.strpath, clone_url=push_url, username=username, password=password)
155
181
156 assert 'fatal: Authentication failed' in stderr
182 assert 'fatal: Authentication failed' in stderr
157
183
158 def test_push_back_to_wrong_url_svn(self, rc_web_server, tmpdir):
184 def test_push_back_to_wrong_url_svn(self, rc_web_server, tmpdir):
159 clone_url = rc_web_server.repo_clone_url(SVN_REPO)
185 clone_url = rc_web_server.repo_clone_url(SVN_REPO)
160 username, password = '', ''
186 username, password = '', ''
161 auth = f'--non-interactive --username={username} --password={password}'
187 flags, auth = get_cli_flags(username, password)
162 Command('/tmp').execute(
188
163 f'svn checkout {auth}', clone_url, tmpdir.strpath)
189 stdout, stderr = Command('/tmp').execute(
190 f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
164
191
165 stdout, stderr = _add_files_and_push(
192 stdout, stderr = _add_files_and_push(
166 'svn', tmpdir.strpath,
193 'svn', tmpdir.strpath,
167 clone_url=rc_web_server.repo_clone_url('not-existing'))
194 clone_url=rc_web_server.repo_clone_url('not-existing'), username=username, password=password)
168
195
169 assert 'not found' in stderr
196 assert 'not found' in stderr
170
197
171 def test_ip_restriction_svn(self, rc_web_server, tmpdir):
198 def test_ip_restriction_svn(self, rc_web_server, tmpdir):
172 user_model = UserModel()
199 user_model = UserModel()
173 username, password = '', ''
200 username, password = '', ''
174 auth = f'--non-interactive --username={username} --password={password}'
201 flags, auth = get_cli_flags(username, password)
175
202
176 try:
203 try:
177 user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32')
204 user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32')
@@ -180,7 +207,7 b' class TestVCSOperations(object):'
180 clone_url = rc_web_server.repo_clone_url(SVN_REPO)
207 clone_url = rc_web_server.repo_clone_url(SVN_REPO)
181
208
182 stdout, stderr = Command('/tmp').execute(
209 stdout, stderr = Command('/tmp').execute(
183 f'svn checkout {auth}', clone_url, tmpdir.strpath)
210 f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
184 msg = "The requested URL returned error: 403"
211 msg = "The requested URL returned error: 403"
185 assert msg in stderr
212 assert msg in stderr
186 finally:
213 finally:
@@ -192,6 +219,6 b' class TestVCSOperations(object):'
192 time.sleep(2)
219 time.sleep(2)
193
220
194 cmd = Command('/tmp')
221 cmd = Command('/tmp')
195 stdout, stderr = cmd.execute(f'svn checkout {auth}', clone_url, tmpdir.strpath)
222 stdout, stderr = cmd.execute(f'svn checkout {flags} {auth}', clone_url, tmpdir.strpath)
196 cmd.assert_returncode_success()
223 cmd.assert_returncode_success()
197 _check_proper_clone(stdout, stderr, 'svn')
224 _check_proper_clone(stdout, stderr, 'svn')
General Comments 0
You need to be logged in to leave comments. Login now