Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pygit2/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ def git_remote_callbacks(payload):
# Plug callbacks
cdata.credentials = C._credentials_cb
cdata.update_tips = C._update_tips_cb
cdata.certificate_check = C._certificate_check_cb
# Payload
handle = ffi.new_handle(payload)
cdata.payload = handle
Expand Down
30 changes: 30 additions & 0 deletions test/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,36 @@ def update_tips(self, name, old, new):
assert callbacks.i > 0


@utils.requires_network
def test_ls_remotes_certificate_check():
url = 'https://github.com/pygit2/empty.git'

class MyCallbacks(pygit2.RemoteCallbacks):
def __init__(self):
self.i = 0

def certificate_check(self, certificate, valid, host):
self.i += 1

assert certificate is None
assert valid is True
assert host == b'github.com'
return True

# We create an in-memory repository
git = pygit2.Repository()
remote = git.remotes.create_anonymous(url)

callbacks = MyCallbacks()
refs = remote.ls_remotes(callbacks=callbacks)

# Sanity check that we indeed got some refs.
assert len(refs) > 0

# Make sure our certificate_check callback triggered.
assert callbacks.i > 0


@pytest.fixture
def origin(tmp_path):
with utils.TemporaryRepository('barerepo.zip', tmp_path) as path:
Expand Down
Loading