diff options
author | Antoine GIRARD <sapk@users.noreply.github.com> | 2017-03-16 02:27:35 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-03-16 09:27:35 +0800 |
commit | ca1c3f1926eff992a2458f26cb24ed2f35265b05 (patch) | |
tree | a0c859357539aebf4c3ce521fc8b5d1e6a870364 /models/gpg_key_test.go | |
parent | 43c5469f81851c084fa6ac84d8379ae949c3a05c (diff) | |
download | gitea-ca1c3f1926eff992a2458f26cb24ed2f35265b05.tar.gz gitea-ca1c3f1926eff992a2458f26cb24ed2f35265b05.zip |
Implement GPG api (#710)
* Implement GPG API
* Better handle error
* Apply review recommendation + simplify database operations
* Remove useless comments
Diffstat (limited to 'models/gpg_key_test.go')
-rw-r--r-- | models/gpg_key_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/models/gpg_key_test.go b/models/gpg_key_test.go new file mode 100644 index 0000000000..1ef5838e31 --- /dev/null +++ b/models/gpg_key_test.go @@ -0,0 +1,48 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package models + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCheckArmoredGPGKeyString(t *testing.T) { + testGPGArmor := `-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQENBFh91QoBCADciaDd7aqegYkn4ZIG7J0p1CRwpqMGjxFroJEMg6M1ZiuEVTRv +z49P4kcr1+98NvFmcNc+x5uJgvPCwr/N8ZW5nqBUs2yrklbFF4MeQomyZJJegP8m +/dsRT3BwIT8YMUtJuCj0iqD9vuKYfjrztcMgC1sYwcE9E9OlA0pWBvUdU2i0TIB1 +vOq6slWGvHHa5l5gPfm09idlVxfH5+I+L1uIMx5ovbiVVU5x2f1AR1T18f0t2TVN +0agFTyuoYE1ATmvJHmMcsfgM1Gpd9hIlr9vlupT2kKTPoNzVzsJsOU6Ku/Lf/bac +mF+TfSbRCtmG7dkYZ4metLj7zG/WkW8IvJ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K62/MuyLdr+FdCl68F3ewuT2iu/MDv+D4HPqA47zma9xVgZ9ZNwJOpv3fCOo +RfY66UjGEnfgYifgtI5S84/mp2jaSc9UNvlZB6RSf8cfbJUL74kS2lq+xzSlf0yP +Av844q/BfRuVsJsK1NDNG09LC30B0l3LKBqlrRmRTUMHtgchdX2dY+p7GPOoSzlR +MkM/fdpyc2hY7Dl/+qFmN5MG5yGmMpQcX+RNNR222ibNC1D3wg== +=i9b7 +-----END PGP PUBLIC KEY BLOCK-----` + + key, err := checkArmoredGPGKeyString(testGPGArmor) + assert.Nil(t, err, "Could not parse a valid GPG armored key", key) + //TODO verify value of key +} |