MCPcopy Create free account
hub / github.com/libgit2/pygit2 / test_fetch_certificate_check

Function test_fetch_certificate_check

test/test_credentials.py:176–199  ·  view source on GitHub ↗
(testrepo: Repository)

Source from the content-addressed store, hash-verified

174
175@utils.requires_network
176def test_fetch_certificate_check(testrepo: Repository) -> None:
177 class MyCallbacks(pygit2.RemoteCallbacks):
178 def certificate_check(
179 self, certificate: None, valid: bool, host: bytes
180 ) -> bool:
181 assert certificate is None
182 assert valid is True
183 assert host == b'github.com'
184 return False
185
186 url = 'https://github.com/libgit2/pygit2.git'
187 remote = testrepo.remotes.create('https', url)
188 with pytest.raises(pygit2.GitError) as exc:
189 remote.fetch(callbacks=MyCallbacks())
190
191 # libgit2 uses different error message for Linux and Windows
192 value = str(exc.value)
193 if platform.system() == 'Windows':
194 assert value == 'user cancelled certificate check' # winhttp
195 else:
196 assert value == 'user rejected certificate for github.com' # httpclient
197
198 # TODO Add GitError.error_code
199 # assert exc.value.error_code == pygit2.GIT_ERROR_HTTP
200
201
202@utils.requires_network

Callers

nothing calls this directly

Calls 3

fetchMethod · 0.80
MyCallbacksClass · 0.70
createMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…