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
0355488d
Commit
0355488d
authored
Jun 22, 2017
by
Rubén Dávila Santos
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'normalise-license-md5' into 'master'
Normalise license MD5 values See merge request !2205
parents
5514552c
39318708
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
app/models/license.rb
app/models/license.rb
+6
-0
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+1
-1
spec/models/license_spec.rb
spec/models/license_spec.rb
+20
-0
No files found.
app/models/license.rb
View file @
0355488d
...
...
@@ -135,6 +135,12 @@ class License < ActiveRecord::Base
self
.
data
=
file
.
read
end
def
md5
normalized_data
=
self
.
data
.
gsub
(
"
\r\n
"
,
"
\n
"
).
gsub
(
/\n+$/
,
''
)
+
"
\n
"
Digest
::
MD5
.
hexdigest
(
normalized_data
)
end
def
license
return
nil
unless
self
.
data
...
...
lib/gitlab/usage_data.rb
View file @
0355488d
...
...
@@ -82,7 +82,7 @@ module Gitlab
if
license
usage_data
[
:edition
]
=
license_edition
(
license
.
plan
)
usage_data
[
:license_md5
]
=
Digest
::
MD5
.
hexdigest
(
license
.
data
)
usage_data
[
:license_md5
]
=
license
.
md5
usage_data
[
:historical_max_users
]
=
::
HistoricalData
.
max_historical_user_count
usage_data
[
:licensee
]
=
license
.
licensee
usage_data
[
:license_user_count
]
=
license
.
restricted_user_count
...
...
spec/models/license_spec.rb
View file @
0355488d
...
...
@@ -315,6 +315,26 @@ describe License do
end
end
describe
"#md5"
do
it
"returns the same MD5 for licenses with carriage returns and those without"
do
other_license
=
build
(
:license
,
data:
license
.
data
.
gsub
(
"
\n
"
,
"
\r\n
"
))
expect
(
other_license
.
md5
).
to
eq
(
license
.
md5
)
end
it
"returns the same MD5 for licenses with trailing newlines and those without"
do
other_license
=
build
(
:license
,
data:
license
.
data
.
chomp
)
expect
(
other_license
.
md5
).
to
eq
(
license
.
md5
)
end
it
"returns the same MD5 for licenses with multiple trailing newlines and those with a single trailing newline"
do
other_license
=
build
(
:license
,
data:
"
#{
license
.
data
}
\n\n\n
"
)
expect
(
other_license
.
md5
).
to
eq
(
license
.
md5
)
end
end
describe
"#license"
do
context
"when no data is provided"
do
before
do
...
...
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