diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2024-04-02 17:50:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-02 17:50:57 +0200 |
commit | eb505b128c7b9b2459f2a5d20b5740017125178b (patch) | |
tree | 9e7cd3a58877415edc8941196925e87cc835bbb9 /models/asymkey/gpg_key_test.go | |
parent | 944c76e78423405a33450eb3d07cd2b772f4a81c (diff) | |
download | gitea-eb505b128c7b9b2459f2a5d20b5740017125178b.tar.gz gitea-eb505b128c7b9b2459f2a5d20b5740017125178b.zip |
Fix missing 0 prefix of GPG key id (#30245)
Fixes #30235
If the key id "front" byte has a single digit, `%X` is missing the 0
prefix.
` 38D1A3EADDBEA9C` instead of
`038D1A3EADDBEA9C`
When using the `IssuerFingerprint` slice `%X` is enough but I changed it
to `%016X` too to be consistent.
Diffstat (limited to 'models/asymkey/gpg_key_test.go')
-rw-r--r-- | models/asymkey/gpg_key_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/models/asymkey/gpg_key_test.go b/models/asymkey/gpg_key_test.go index dee74bc281..d3fbb01d82 100644 --- a/models/asymkey/gpg_key_test.go +++ b/models/asymkey/gpg_key_test.go @@ -11,7 +11,9 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/modules/util" + "github.com/keybase/go-crypto/openpgp/packet" "github.com/stretchr/testify/assert" ) @@ -391,3 +393,13 @@ epiDVQ== assert.Equal(t, time.Unix(1586105389, 0), expire) } } + +func TestTryGetKeyIDFromSignature(t *testing.T) { + assert.Empty(t, tryGetKeyIDFromSignature(&packet.Signature{})) + assert.Equal(t, "038D1A3EADDBEA9C", tryGetKeyIDFromSignature(&packet.Signature{ + IssuerKeyId: util.ToPointer(uint64(0x38D1A3EADDBEA9C)), + })) + assert.Equal(t, "038D1A3EADDBEA9C", tryGetKeyIDFromSignature(&packet.Signature{ + IssuerFingerprint: []uint8{0xb, 0x23, 0x24, 0xc7, 0xe6, 0xfe, 0x4f, 0x3a, 0x6, 0x26, 0xc1, 0x21, 0x3, 0x8d, 0x1a, 0x3e, 0xad, 0xdb, 0xea, 0x9c}, + })) +} |