(gpgsigned: Repository)
| 85 | |
| 86 | |
| 87 | def test_commit_signing(gpgsigned: Repository) -> None: |
| 88 | repo = gpgsigned |
| 89 | message = 'a simple commit which works' |
| 90 | author = Signature( |
| 91 | name='Ben Burkert', |
| 92 | email='ben@benburkert.com', |
| 93 | time=1358451456, |
| 94 | offset=-480, |
| 95 | ) |
| 96 | committer = Signature( |
| 97 | name='Ben Burkert', |
| 98 | email='ben@benburkert.com', |
| 99 | time=1358451456, |
| 100 | offset=-480, |
| 101 | ) |
| 102 | tree = '4b825dc642cb6eb9a060e54bf8d69288fbee4904' |
| 103 | parent = '8496071c1b46c854b31185ea97743be6a8774479' |
| 104 | |
| 105 | # create commit string |
| 106 | commit_string = repo.create_commit_string( |
| 107 | author, committer, message, tree, [parent] |
| 108 | ) |
| 109 | assert commit_string == content |
| 110 | |
| 111 | # create/retrieve signed commit |
| 112 | oid = repo.create_commit_with_signature(content, gpgsig) |
| 113 | commit = repo.get(oid) |
| 114 | assert isinstance(commit, Commit) |
| 115 | signature, payload = commit.gpg_signature |
| 116 | |
| 117 | # validate signed commit |
| 118 | assert content == payload.decode('utf-8') |
| 119 | assert gpgsig == signature.decode('utf-8') |
| 120 | assert gpgsig_content == commit.read_raw().decode('utf-8') |
| 121 | |
| 122 | # perform sanity checks |
| 123 | assert ObjectType.COMMIT == commit.type |
| 124 | assert '6569fdf71dbd99081891154641869c537784a3ba' == commit.id |
| 125 | assert commit.message_encoding is None |
| 126 | assert message == commit.message |
| 127 | assert 1358451456 == commit.commit_time |
| 128 | assert committer == commit.committer |
| 129 | assert author == commit.author |
| 130 | assert tree == commit.tree.id |
| 131 | assert Oid(hex=tree) == commit.tree_id |
| 132 | assert 1 == len(commit.parents) |
| 133 | assert parent == commit.parents[0].id |
| 134 | assert Oid(hex=parent) == commit.parent_ids[0] |
| 135 | |
| 136 | |
| 137 | def test_get_gpg_signature_when_unsigned(gpgsigned: Repository) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…