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

Function test_list_heads_certificate_check

test/test_remote.py:342–370  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

340
341@utils.requires_network
342def test_list_heads_certificate_check() -> None:
343 url = 'https://github.com/pygit2/empty.git'
344
345 class MyCallbacks(pygit2.RemoteCallbacks):
346 def __init__(self) -> None:
347 self.i = 0
348
349 def certificate_check(
350 self, certificate: None, valid: bool, host: str | bytes
351 ) -> bool:
352 self.i += 1
353
354 assert certificate is None
355 assert valid is True
356 assert host == b'github.com'
357 return True
358
359 # We create an in-memory repository
360 git = pygit2.Repository()
361 remote = git.remotes.create_anonymous(url)
362
363 callbacks = MyCallbacks()
364 refs = remote.list_heads(callbacks=callbacks)
365
366 # Sanity check that we indeed got some refs.
367 assert len(refs) > 0
368
369 # Make sure our certificate_check callback triggered.
370 assert callbacks.i > 0
371
372
373@pytest.fixture

Callers

nothing calls this directly

Calls 3

create_anonymousMethod · 0.80
list_headsMethod · 0.80
MyCallbacksClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…