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
14f3df00
Commit
14f3df00
authored
Oct 08, 2020
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add code review remarks
Add cr remarks Add cr remarks Add cr remarks
parent
6d3752fe
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
11 deletions
+23
-11
app/models/group.rb
app/models/group.rb
+2
-2
app/models/namespace_setting.rb
app/models/namespace_setting.rb
+3
-3
locale/gitlab.pot
locale/gitlab.pot
+6
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+2
-2
spec/models/namespace_setting_spec.rb
spec/models/namespace_setting_spec.rb
+10
-4
No files found.
app/models/group.rb
View file @
14f3df00
...
@@ -591,13 +591,13 @@ class Group < Namespace
...
@@ -591,13 +591,13 @@ class Group < Namespace
end
end
def
two_factor_authentication_allowed
def
two_factor_authentication_allowed
return
if
parent_id
.
nil
?
return
unless
has_parent
?
return
unless
require_two_factor_authentication
return
unless
require_two_factor_authentication
ancestor_settings
=
ancestors
.
find_by
(
parent_id:
nil
).
namespace_settings
ancestor_settings
=
ancestors
.
find_by
(
parent_id:
nil
).
namespace_settings
return
if
ancestor_settings
.
allow_mfa_for_subgroups
return
if
ancestor_settings
.
allow_mfa_for_subgroups
errors
.
add
(
:require_two_factor_authentication
,
"require two factor authentication is forbidden by a parent group"
)
errors
.
add
(
:require_two_factor_authentication
,
_
(
'is forbidden by a top-level group'
)
)
end
end
def
members_from_self_and_ancestor_group_shares
def
members_from_self_and_ancestor_group_shares
...
...
app/models/namespace_setting.rb
View file @
14f3df00
...
@@ -4,7 +4,7 @@ class NamespaceSetting < ApplicationRecord
...
@@ -4,7 +4,7 @@ class NamespaceSetting < ApplicationRecord
belongs_to
:namespace
,
inverse_of: :namespace_settings
belongs_to
:namespace
,
inverse_of: :namespace_settings
validate
:default_branch_name_content
validate
:default_branch_name_content
validate
:allow_mfa_for_group
,
on: :update
,
if: :allow_mfa_for_subgroups_changed?
validate
:allow_mfa_for_group
NAMESPACE_SETTINGS_PARAMS
=
[
:default_branch_name
].
freeze
NAMESPACE_SETTINGS_PARAMS
=
[
:default_branch_name
].
freeze
...
@@ -19,8 +19,8 @@ class NamespaceSetting < ApplicationRecord
...
@@ -19,8 +19,8 @@ class NamespaceSetting < ApplicationRecord
end
end
def
allow_mfa_for_group
def
allow_mfa_for_group
if
namespace
&
.
parent_id
if
namespace
&
.
subgroup?
&&
allow_mfa_for_subgroups
==
false
errors
.
add
(
:allow_mfa_for_subgroups
,
"allow MFA setting is not allowed since group is not top-level group."
)
errors
.
add
(
:allow_mfa_for_subgroups
,
_
(
'is not allowed since the group is not top-level group.'
)
)
end
end
end
end
end
end
...
...
locale/gitlab.pot
View file @
14f3df00
...
@@ -30837,6 +30837,9 @@ msgstr ""
...
@@ -30837,6 +30837,9 @@ msgstr ""
msgid "is blocked by"
msgid "is blocked by"
msgstr ""
msgstr ""
msgid "is forbidden by a top-level group"
msgstr ""
msgid "is invalid because there is downstream lock"
msgid "is invalid because there is downstream lock"
msgstr ""
msgstr ""
...
@@ -30852,6 +30855,9 @@ msgstr ""
...
@@ -30852,6 +30855,9 @@ msgstr ""
msgid "is not a valid X509 certificate."
msgid "is not a valid X509 certificate."
msgstr ""
msgstr ""
msgid "is not allowed since the group is not top-level group."
msgstr ""
msgid "is not allowed. Try again with a different email address, or contact your GitLab admin."
msgid "is not allowed. Try again with a different email address, or contact your GitLab admin."
msgstr ""
msgstr ""
...
...
spec/models/group_spec.rb
View file @
14f3df00
...
@@ -235,7 +235,7 @@ RSpec.describe Group do
...
@@ -235,7 +235,7 @@ RSpec.describe Group do
end
end
context
'for a child group'
do
context
'for a child group'
do
let
_it_be
(
:sub_group
)
{
create
(
:group
,
parent:
group
)
}
let
(
:sub_group
)
{
create
(
:group
,
parent:
group
)
}
it
'is valid when parent group allows'
do
it
'is valid when parent group allows'
do
sub_group
.
require_two_factor_authentication
=
true
sub_group
.
require_two_factor_authentication
=
true
...
@@ -248,7 +248,7 @@ RSpec.describe Group do
...
@@ -248,7 +248,7 @@ RSpec.describe Group do
sub_group
.
require_two_factor_authentication
=
true
sub_group
.
require_two_factor_authentication
=
true
expect
(
sub_group
).
to
be_invalid
expect
(
sub_group
).
to
be_invalid
expect
(
sub_group
.
errors
[
:require_two_factor_authentication
]).
to
include
(
'
require two factor authentication is forbidden by a parent
group'
)
expect
(
sub_group
.
errors
[
:require_two_factor_authentication
]).
to
include
(
'
is forbidden by a top-level
group'
)
end
end
end
end
end
end
...
...
spec/models/namespace_setting_spec.rb
View file @
14f3df00
...
@@ -47,19 +47,25 @@ RSpec.describe NamespaceSetting, type: :model do
...
@@ -47,19 +47,25 @@ RSpec.describe NamespaceSetting, type: :model do
end
end
describe
'#allow_mfa_for_group'
do
describe
'#allow_mfa_for_group'
do
let
(
:settings
)
{
group
.
namespace_settings
}
context
'group is top-level group'
do
context
'group is top-level group'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:group
)
{
create
(
:group
)
}
it
'is valid when updated'
do
it
'is valid'
do
expect
(
group
.
namespace_settings
.
update
(
allow_mfa_for_subgroups:
false
)).
to
eq
(
true
)
settings
.
allow_mfa_for_subgroups
=
false
expect
(
settings
).
to
be_valid
end
end
end
end
context
'group is a subgroup'
do
context
'group is a subgroup'
do
let
(
:group
)
{
create
(
:group
,
parent:
create
(
:group
))
}
let
(
:group
)
{
create
(
:group
,
parent:
create
(
:group
))
}
it
'is invalid when updated'
do
it
'is invalid'
do
expect
(
group
.
namespace_settings
.
update
(
allow_mfa_for_subgroups:
false
)).
to
eq
(
false
)
settings
.
allow_mfa_for_subgroups
=
false
expect
(
settings
).
to
be_invalid
end
end
end
end
end
end
...
...
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