Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ab4120de
Commit
ab4120de
authored
Feb 22, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only validate gpg_key#fingerprint "internally"
parent
7b7cd6f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
app/models/gpg_key.rb
app/models/gpg_key.rb
+9
-5
spec/models/gpg_key_spec.rb
spec/models/gpg_key_spec.rb
+0
-2
No files found.
app/models/gpg_key.rb
View file @
ab4120de
...
...
@@ -3,17 +3,21 @@ class GpgKey < ActiveRecord::Base
belongs_to
:user
validates
:fingerprint
,
presence:
true
,
uniqueness:
true
validates
:key
,
presence:
true
,
uniqueness:
true
,
format:
{
with:
/\A
#{
KEY_PREFIX
}
((?!
#{
KEY_PREFIX
}
).)+\Z/m
with:
/\A
#{
KEY_PREFIX
}
((?!
#{
KEY_PREFIX
}
).)+\Z/m
,
message:
"is invalid. A valid public GPG key begins with '
#{
KEY_PREFIX
}
'"
}
validates
:fingerprint
,
presence:
true
,
uniqueness:
true
,
# only validate when the `key` is valid, as we don't want the user to show
# the error about the fingerprint
unless:
->
{
errors
.
has_key?
(
:key
)
}
before_validation
:extract_fingerprint
def
key
=
(
value
)
...
...
spec/models/gpg_key_spec.rb
View file @
ab4120de
...
...
@@ -6,8 +6,6 @@ describe GpgKey do
end
describe
"validation"
do
it
{
is_expected
.
to
validate_presence_of
(
:fingerprint
)
}
it
{
is_expected
.
to
validate_presence_of
(
:key
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:key
)
}
it
{
is_expected
.
to
allow_value
(
"-----BEGIN PGP PUBLIC KEY BLOCK-----
\n
key"
).
for
(
:key
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment