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
156c40d6
Commit
156c40d6
authored
Jul 18, 2017
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect repository size limit setting through a license check
parent
9bd93670
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
101 additions
and
32 deletions
+101
-32
app/models/ee/project.rb
app/models/ee/project.rb
+2
-0
app/models/license.rb
app/models/license.rb
+5
-2
app/views/admin/application_settings/_form.html.haml
app/views/admin/application_settings/_form.html.haml
+3
-8
app/views/admin/application_settings/_repository_size_limit_setting.html.haml
...ication_settings/_repository_size_limit_setting.html.haml
+12
-0
app/views/admin/groups/_form.html.haml
app/views/admin/groups/_form.html.haml
+1
-1
app/views/groups/_repository_size_limit_setting.html.haml
app/views/groups/_repository_size_limit_setting.html.haml
+0
-8
app/views/groups/edit.html.haml
app/views/groups/edit.html.haml
+1
-1
app/views/projects/edit.html.haml
app/views/projects/edit.html.haml
+1
-7
app/views/shared/_repository_size_limit_setting.html.haml
app/views/shared/_repository_size_limit_setting.html.haml
+18
-0
spec/factories/licenses.rb
spec/factories/licenses.rb
+15
-4
spec/models/ee/project_spec.rb
spec/models/ee/project_spec.rb
+43
-1
No files found.
app/models/ee/project.rb
View file @
156c40d6
...
...
@@ -414,6 +414,8 @@ module EE
end
def
size_limit_enabled?
return
false
unless
License
.
feature_available?
(
:repository_size_limit
)
actual_size_limit
!=
0
end
...
...
app/models/license.rb
View file @
156c40d6
...
...
@@ -25,7 +25,8 @@ class License < ActiveRecord::Base
OBJECT_STORAGE_FEATURE
=
'GitLab_ObjectStorage'
.
freeze
PROTECTED_REFS_FOR_USERS_FEATURE
=
'GitLab_RefPermissionsForUsers'
.
freeze
PUSH_RULES_FEATURE
=
'GitLab_PushRules'
.
freeze
RELATED_ISSUES_FEATURE
=
'RelatedIssues'
.
freeze
RELATED_ISSUES_FEATURE
=
'GitLab_RelatedIssues'
.
freeze
REPOSITORY_SIZE_LIMIT_FEATURE
=
'GitLab_RepositorySizeLimit'
.
freeze
SERVICE_DESK_FEATURE
=
'GitLab_ServiceDesk'
.
freeze
VARIABLE_ENVIRONMENT_SCOPE_FEATURE
=
'GitLab_VariableEnvironmentScope'
.
freeze
...
...
@@ -36,6 +37,7 @@ class License < ActiveRecord::Base
geo:
GEO_FEATURE
,
object_storage:
OBJECT_STORAGE_FEATURE
,
related_issues:
RELATED_ISSUES_FEATURE
,
repository_size_limit:
REPOSITORY_SIZE_LIMIT_FEATURE
,
service_desk:
SERVICE_DESK_FEATURE
,
variable_environment_scope:
VARIABLE_ENVIRONMENT_SCOPE_FEATURE
,
...
...
@@ -85,7 +87,8 @@ class License < ActiveRecord::Base
{
MULTIPLE_ISSUE_BOARDS_FEATURE
=>
1
},
{
PUSH_RULES_FEATURE
=>
1
},
{
PROTECTED_REFS_FOR_USERS_FEATURE
=>
1
},
{
RELATED_ISSUES_FEATURE
=>
1
}
{
RELATED_ISSUES_FEATURE
=>
1
},
{
REPOSITORY_SIZE_LIMIT_FEATURE
=>
1
}
].
freeze
EEP_FEATURES
=
[
...
...
app/views/admin/application_settings/_form.html.haml
View file @
156c40d6
...
...
@@ -65,14 +65,9 @@
=
f
.
label
:max_attachment_size
,
'Maximum attachment size (MB)'
,
class:
'control-label col-sm-2'
.col-sm-10
=
f
.
number_field
:max_attachment_size
,
class:
'form-control'
.form-group
=
f
.
label
:repository_size_limit
,
class:
'control-label col-sm-2'
do
Size limit per repository (MB)
.col-sm-10
=
f
.
number_field
:repository_size_limit
,
value:
f
.
object
.
repository_size_limit
.
try
(
:to_mb
),
class:
'form-control'
,
min:
0
%span
.help-block
#repository_size_limit_help_block
Includes LFS objects. It can be overridden per group, or per project. 0 for unlimited.
=
link_to
icon
(
'question-circle'
),
help_page_path
(
"user/admin_area/settings/account_and_limit_settings"
)
=
render
'repository_size_limit_setting'
,
form:
f
.form-group
=
f
.
label
:session_expire_delay
,
'Session duration (minutes)'
,
class:
'control-label col-sm-2'
.col-sm-10
...
...
app/views/admin/application_settings/_repository_size_limit_setting.html.haml
0 → 100644
View file @
156c40d6
-
return
unless
License
.
feature_available?
(
:repository_size_limit
)
-
form
=
local_assigns
.
fetch
(
:form
)
.form-group
=
form
.
label
:repository_size_limit
,
class:
'control-label col-sm-2'
do
Size limit per repository (MB)
.col-sm-10
=
form
.
number_field
:repository_size_limit
,
value:
form
.
object
.
repository_size_limit
.
try
(
:to_mb
),
class:
'form-control'
,
min:
0
%span
.help-block
#repository_size_limit_help_block
Includes LFS objects. It can be overridden per group, or per project. 0 for unlimited.
=
link_to
icon
(
'question-circle'
),
help_page_path
(
"user/admin_area/settings/account_and_limit_settings"
)
app/views/admin/groups/_form.html.haml
View file @
156c40d6
...
...
@@ -2,7 +2,7 @@
=
form_errors
(
@group
)
=
render
'shared/group_form'
,
f:
f
=
render
'
groups/repository_size_limit_setting'
,
f:
f
=
render
'
shared/repository_size_limit_setting'
,
form:
f
,
type: :group
-
if
current_application_settings
.
should_check_namespace_plan?
=
render
'admin/namespace_plan'
,
f:
f
...
...
app/views/groups/_repository_size_limit_setting.html.haml
deleted
100644 → 0
View file @
9bd93670
-
if
current_user
.
admin?
.form-group
=
f
.
label
:repository_size_limit
,
class:
'control-label'
do
Repository size limit (MB)
.col-sm-10
=
f
.
number_field
:repository_size_limit
,
value:
f
.
object
.
repository_size_limit
.
try
(
:to_mb
),
class:
'form-control'
,
min:
0
%span
.help-block
#repository_size_limit_help_block
=
size_limit_message_for_group
(
@group
)
app/views/groups/edit.html.haml
View file @
156c40d6
...
...
@@ -7,7 +7,7 @@
=
form_errors
(
@group
)
=
render
'shared/group_form'
,
f:
f
=
render
'
repository_size_limit_setting'
,
f:
f
=
render
'
shared/repository_size_limit_setting'
,
form:
f
,
type: :group
.form-group
.col-sm-offset-2.col-sm-10
...
...
app/views/projects/edit.html.haml
View file @
156c40d6
...
...
@@ -37,13 +37,7 @@
=
f
.
label
:default_branch
,
"Default Branch"
,
class:
'label-light'
=
f
.
select
(
:default_branch
,
@project
.
repository
.
branch_names
,
{},
{
class:
'select2 select-wide'
})
-
if
current_user
.
admin?
.form-group
=
f
.
label
:repository_size_limit
,
class:
'label-light'
do
Repository size limit (MB)
=
f
.
number_field
:repository_size_limit
,
value:
f
.
object
.
repository_size_limit
.
try
(
:to_mb
),
class:
'form-control'
,
min:
0
%span
.help-block
#repository_size_limit_help_block
=
size_limit_message
(
@project
)
=
render
'shared/repository_size_limit_setting'
,
form:
f
,
type: :project
.form-group
=
f
.
label
:tag_list
,
"Tags"
,
class:
'label-light'
...
...
app/views/shared/_repository_size_limit_setting.html.haml
0 → 100644
View file @
156c40d6
-
return
unless
current_user
.
admin?
&&
License
.
feature_available?
(
:repository_size_limit
)
-
form
=
local_assigns
.
fetch
(
:form
)
-
type
=
local_assigns
.
fetch
(
:type
)
-
label_class
=
(
type
==
:project
)
?
'label-light'
:
'control-label'
.form-group
=
form
.
label
:repository_size_limit
,
class:
label_class
do
Repository size limit (MB)
-
if
type
==
:project
=
form
.
number_field
:repository_size_limit
,
value:
form
.
object
.
repository_size_limit
.
try
(
:to_mb
),
class:
'form-control'
,
min:
0
%span
.help-block
#repository_size_limit_help_block
=
size_limit_message
(
@project
)
-
elsif
type
==
:group
.col-sm-10
=
form
.
number_field
:repository_size_limit
,
value:
form
.
object
.
repository_size_limit
.
try
(
:to_mb
),
class:
'form-control'
,
min:
0
%span
.help-block
#repository_size_limit_help_block
=
size_limit_message_for_group
(
@group
)
spec/factories/licenses.rb
View file @
156c40d6
...
...
@@ -2,19 +2,26 @@ FactoryGirl.define do
factory
:gitlab_license
,
class:
"Gitlab::License"
do
starts_at
{
Date
.
today
-
1
.
month
}
expires_at
{
Date
.
today
+
11
.
months
}
notify_users_at
{
|
l
|
l
.
expires_at
}
notify_admins_at
{
|
l
|
l
.
expires_at
}
licensee
do
{
"Name"
=>
generate
(
:name
)
}
end
restrictions
do
{
add_ons:
{
'GitLab_FileLocks'
=>
1
,
'GitLab_Auditor_User'
=>
1
}
},
plan:
plan
}
end
notify_users_at
{
|
l
|
l
.
expires_at
}
notify_admins_at
{
|
l
|
l
.
expires_at
}
transient
do
plan
License
::
STARTER_PLAN
end
trait
:trial
do
restrictions
do
...
...
@@ -24,7 +31,11 @@ FactoryGirl.define do
end
factory
:license
do
data
{
build
(
:gitlab_license
).
export
}
transient
do
plan
nil
end
data
{
build
(
:gitlab_license
,
plan:
plan
).
export
}
end
factory
:trial_license
,
class:
License
do
...
...
spec/models/ee/project_spec.rb
View file @
156c40d6
...
...
@@ -322,8 +322,50 @@ describe Project, models: true do
end
end
describe
'#size_limit_enabled?'
do
let
(
:project
)
{
create
(
:empty_project
)
}
context
'when repository_size_limit is not configured'
do
it
'is disabled'
do
expect
(
project
.
size_limit_enabled?
).
to
be_falsey
end
end
context
'when repository_size_limit is configured'
do
before
do
project
.
update_attributes
(
repository_size_limit:
1024
)
end
context
'with an EES license'
do
let!
(
:license
)
{
create
(
:license
,
plan:
License
::
STARTER_PLAN
)
}
it
'is enabled'
do
expect
(
project
.
size_limit_enabled?
).
to
be_truthy
end
end
context
'with an EEP license'
do
let!
(
:license
)
{
create
(
:license
,
plan:
License
::
PREMIUM_PLAN
)
}
it
'is enabled'
do
expect
(
project
.
size_limit_enabled?
).
to
be_truthy
end
end
context
'without a License'
do
before
do
License
.
destroy_all
end
it
'is disabled'
do
expect
(
project
.
size_limit_enabled?
).
to
be_falsey
end
end
end
end
describe
'#service_desk_enabled?'
do
let!
(
:license
)
{
create
(
:license
,
data:
build
(
:gitlab_license
,
restrictions:
{
plan:
License
::
PREMIUM_PLAN
}).
export
)
}
let!
(
:license
)
{
create
(
:license
,
plan:
License
::
PREMIUM_PLAN
)
}
let
(
:namespace
)
{
create
(
:namespace
)
}
subject
(
:project
)
{
build
(
:empty_project
,
:private
,
namespace:
namespace
,
service_desk_enabled:
true
)
}
...
...
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