()
| 340 | |
| 341 | @utils.requires_network |
| 342 | def 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…