summaryrefslogtreecommitdiffstats
path: root/models/gpg_key_test.go
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2017-06-17 13:56:40 +0300
committerLunny Xiao <xiaolunwen@gmail.com>2017-06-17 18:56:40 +0800
commit1a906f800deed6d21eb8d8737c3577746ae7388b (patch)
tree74bc6c21fa03667739be89302ec2f7a79393fa5f /models/gpg_key_test.go
parent6678593b3c612e77707f6197ebfb9524eb9a88d7 (diff)
downloadgitea-1a906f800deed6d21eb8d8737c3577746ae7388b.tar.gz
gitea-1a906f800deed6d21eb8d8737c3577746ae7388b.zip
Fix GPG email checking to be case insensitive (#1988)
Diffstat (limited to 'models/gpg_key_test.go')
-rw-r--r--models/gpg_key_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/models/gpg_key_test.go b/models/gpg_key_test.go
index cc70096d0b..687e0cd594 100644
--- a/models/gpg_key_test.go
+++ b/models/gpg_key_test.go
@@ -183,3 +183,42 @@ Unknown GPG key with good email
err = verifySign(goodSig, goodHash, cannotsignkey)
assert.Error(t, err, "Validate a bad signature with a kay that can not sign")
}
+
+func TestCheckGPGUserEmail(t *testing.T) {
+ testEmailWithUpperCaseLetters := `-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1
+
+mQENBFlEBvMBCADe+EQcfv/aKbMFy7YB8e/DE+hY39sfjvdvSgeXtNhfmYvIOUjT
+ORMCvce2Oxzb3HTI0rjYsJpzo9jEQ53dB3vdr0ne5Juby6N7QPjof3NR+ko50Ki2
+0ilOjYuA0v6VHLIn70UBa9NEf+XDuE7P+Lbtl2L9B9OMXtcTAZoA3cJySgtNFNIG
+AVefPi8LeOcekL39wxJEA8OzdCyO5oENEwAG1tzjy9DDNJf74/dBBh2NiXeSeMxZ
+RYeYzqEa2UTDP1fkUl7d2/hV36cKZWZr+l4SQ5bM7HeLj2SsfabLfqKoVWgkfAzQ
+VwtkbRpzMiDLMte2ZAyTJUc+77YbFoyAmOcjABEBAAG0HFVzZXIgT25lIDxV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FlVk0W0bLBrs3fTDw1lS/N8HpyQb+5ryQmiIb2a48aygCS/h2qeRlX1d
+Q0KHb+QcycSgbDx0ZAvdIacuKvBBcbxrsmFUI4LR+oIup0G9gUc0roPvr014jYQL
+7f8r/8fpcN8t+I/41QHCs6L/BEIdTHW3rTQ6
+=zHo9
+-----END PGP PUBLIC KEY BLOCK-----`
+
+ key, err := AddGPGKey(1, testEmailWithUpperCaseLetters)
+ assert.NoError(t, err)
+
+ assert.Len(t, key.Emails, 1)
+ assert.Equal(t, "user1@example.com", key.Emails[0].Email)
+}