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