##// END OF EJS Templates
hooks: expose user agent in the variables submitted to pull/push hooks.
marcink -
r1710:7173cb6f default
parent child Browse files
Show More
@@ -162,6 +162,10 b' def get_access_path(environ):'
162 162 return path
163 163
164 164
165 def get_user_agent(environ):
166 return environ.get('HTTP_USER_AGENT')
167
168
165 169 def vcs_operation_context(
166 170 environ, repo_name, username, action, scm, check_locking=True,
167 171 is_shadow_repo=False):
@@ -200,6 +204,7 b' def vcs_operation_context('
200 204 'make_lock': make_lock,
201 205 'locked_by': locked_by,
202 206 'server_url': utils2.get_server_url(environ),
207 'user_agent': get_user_agent(environ),
203 208 'hooks': get_enabled_hook_classes(ui_settings),
204 209 'is_shadow_repo': is_shadow_repo,
205 210 }
@@ -43,6 +43,7 b' def scm_extras(user_regular, repo_stub):'
43 43 'config': '',
44 44 'server_url': 'http://example.com',
45 45 'make_lock': None,
46 'user-agent': 'some-client',
46 47 'locked_by': [None],
47 48 'commit_ids': ['a' * 40] * 3,
48 49 'is_shadow_repo': False,
@@ -34,8 +34,9 b' from rhodecode.model import db'
34 34 ('scm', 'stub_scm'),
35 35 ('hooks', ['stub_hook']),
36 36 ('config', 'stub_ini_filename'),
37 ('ip', 'fake_ip'),
37 ('ip', '1.2.3.4'),
38 38 ('server_url', 'https://example.com'),
39 ('user_agent', 'client-text-v1.1'),
39 40 # TODO: johbo: Commpare locking parameters with `_get_rc_scm_extras`
40 41 # in hooks_utils.
41 42 ('make_lock', None),
@@ -71,7 +72,6 b' def test_vcs_operation_context_can_skip_'
71 72
72 73 @patch.object(
73 74 base, 'get_enabled_hook_classes', Mock(return_value=['stub_hook']))
74 @patch.object(base, 'get_ip_addr', Mock(return_value="fake_ip"))
75 75 @patch('rhodecode.lib.utils2.get_server_url',
76 76 Mock(return_value='https://example.com'))
77 77 def call_vcs_operation_context(**kwargs_override):
@@ -87,7 +87,9 b' def call_vcs_operation_context(**kwargs_'
87 87 'rhodecode.CONFIG', {'__file__': 'stub_ini_filename'})
88 88 settings_patch = patch.object(base, 'VcsSettingsModel')
89 89 with config_file_patch, settings_patch as settings_mock:
90 result = base.vcs_operation_context(environ={}, **kwargs)
90 result = base.vcs_operation_context(
91 environ={'HTTP_USER_AGENT': 'client-text-v1.1',
92 'REMOTE_ADDR': '1.2.3.4'}, **kwargs)
91 93 settings_mock.assert_called_once_with(repo='stub_repo_name')
92 94 return result
93 95
@@ -39,6 +39,7 b' def test_post_push_truncates_commits(use'
39 39 'config': '',
40 40 'server_url': 'http://example.com',
41 41 'make_lock': None,
42 'user_agent': 'some-client',
42 43 'locked_by': [None],
43 44 'commit_ids': ['abcde12345' * 4] * 30000,
44 45 'is_shadow_repo': False,
@@ -72,6 +73,7 b' def hook_extras(user_regular, repo_stub)'
72 73 'config': '',
73 74 'server_url': 'http://example.com',
74 75 'make_lock': None,
76 'user_agent': 'some-client',
75 77 'locked_by': [None],
76 78 'commit_ids': [],
77 79 'is_shadow_repo': False,
General Comments 0
You need to be logged in to leave comments. Login now