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
675b67b1
Commit
675b67b1
authored
Oct 13, 2020
by
Drew Blessing
Committed by
Adam Hegyi
Oct 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create SamlGroupLink model
Create the model associated with the new `saml_group_links` database table.
parent
f8aa9be0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
93 additions
and
16 deletions
+93
-16
db/migrate/20201012194936_create_saml_group_links.rb
db/migrate/20201012194936_create_saml_group_links.rb
+8
-10
db/structure.sql
db/structure.sql
+4
-6
ee/app/models/ee/group.rb
ee/app/models/ee/group.rb
+7
-0
ee/app/models/saml_group_link.rb
ee/app/models/saml_group_link.rb
+10
-0
ee/changelogs/unreleased/dblessing_saml_group_links.yml
ee/changelogs/unreleased/dblessing_saml_group_links.yml
+5
-0
ee/spec/factories/saml_group_links.rb
ee/spec/factories/saml_group_links.rb
+9
-0
ee/spec/models/group_spec.rb
ee/spec/models/group_spec.rb
+25
-0
ee/spec/models/saml_group_link_spec.rb
ee/spec/models/saml_group_link_spec.rb
+25
-0
No files found.
db/migrate/20201012194936_create_saml_group_links.rb
View file @
675b67b1
...
...
@@ -8,20 +8,18 @@ class CreateSamlGroupLinks < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def
up
unless
table_exists?
(
:saml_group_links
)
with_lock_retries
do
create_table
:saml_group_links
do
|
t
|
t
.
references
:group
,
foreign_key:
{
to_table: :namespaces
,
on_delete: :cascade
},
null:
false
t
.
timestamps_with_timezone
t
.
integer
:access_level
,
null:
false
t
.
text
:group_name
,
null:
false
with_lock_retries
do
create_table
:saml_group_links
,
if_not_exists:
true
do
|
t
|
t
.
integer
:access_level
,
null:
false
,
limit:
2
t
.
references
:group
,
index:
false
,
foreign_key:
{
to_table: :namespaces
,
on_delete: :cascade
},
null:
false
t
.
timestamps_with_timezone
t
.
text
:saml_group_name
,
null:
false
t
.
index
[
:group_id
,
:group_name
],
unique:
true
end
t
.
index
[
:group_id
,
:saml_group_name
],
unique:
true
end
end
add_text_limit
:saml_group_links
,
:group_name
,
255
add_text_limit
:saml_group_links
,
:
saml_
group_name
,
255
end
def
down
...
...
db/structure.sql
View file @
675b67b1
...
...
@@ -15754,12 +15754,12 @@ ALTER SEQUENCE routes_id_seq OWNED BY routes.id;
CREATE
TABLE
saml_group_links
(
id
bigint
NOT
NULL
,
access_level
smallint
NOT
NULL
,
group_id
bigint
NOT
NULL
,
created_at
timestamp
with
time
zone
NOT
NULL
,
updated_at
timestamp
with
time
zone
NOT
NULL
,
access_level
integer
NOT
NULL
,
group_name
text
NOT
NULL
,
CONSTRAINT
check_1a5ae2ac07
CHECK
((
char_length
(
group_name
)
<=
255
))
saml_group_name
text
NOT
NULL
,
CONSTRAINT
check_1b3fc49d1e
CHECK
((
char_length
(
saml_group_name
)
<=
255
))
);
CREATE
SEQUENCE
saml_group_links_id_seq
...
...
@@ -21478,9 +21478,7 @@ CREATE INDEX index_routes_on_path_trigram ON routes USING gin (path gin_trgm_ops
CREATE
UNIQUE
INDEX
index_routes_on_source_type_and_source_id
ON
routes
USING
btree
(
source_type
,
source_id
);
CREATE
INDEX
index_saml_group_links_on_group_id
ON
saml_group_links
USING
btree
(
group_id
);
CREATE
UNIQUE
INDEX
index_saml_group_links_on_group_id_and_group_name
ON
saml_group_links
USING
btree
(
group_id
,
group_name
);
CREATE
UNIQUE
INDEX
index_saml_group_links_on_group_id_and_saml_group_name
ON
saml_group_links
USING
btree
(
group_id
,
saml_group_name
);
CREATE
INDEX
index_saml_providers_on_group_id
ON
saml_providers
USING
btree
(
group_id
);
...
...
ee/app/models/ee/group.rb
View file @
675b67b1
...
...
@@ -27,6 +27,7 @@ module EE
has_one
:scim_oauth_access_token
has_many
:ldap_group_links
,
foreign_key:
'group_id'
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:saml_group_links
,
foreign_key:
'group_id'
has_many
:hooks
,
dependent: :destroy
,
class_name:
'GroupHook'
# rubocop:disable Cop/ActiveRecordDependent
has_one
:dependency_proxy_setting
,
class_name:
'DependencyProxy::GroupSetting'
...
...
@@ -222,6 +223,12 @@ module EE
ensure_saml_discovery_token!
end
def
saml_enabled?
return
false
unless
saml_provider
saml_provider
.
persisted?
&&
saml_provider
.
enabled?
end
override
:multiple_issue_boards_available?
def
multiple_issue_boards_available?
feature_available?
(
:multiple_group_issue_boards
)
...
...
ee/app/models/saml_group_link.rb
0 → 100644
View file @
675b67b1
# frozen_string_literal: true
class
SamlGroupLink
<
ApplicationRecord
belongs_to
:group
enum
access_level:
::
Gitlab
::
Access
.
options_with_owner
validates
:group
,
:access_level
,
presence:
true
validates
:saml_group_name
,
presence:
true
,
uniqueness:
{
scope:
[
:group_id
]
},
length:
{
maximum:
255
}
end
ee/changelogs/unreleased/dblessing_saml_group_links.yml
0 → 100644
View file @
675b67b1
---
title
:
Create SamlGroupLink table and model
merge_request
:
45061
author
:
type
:
added
ee/spec/factories/saml_group_links.rb
0 → 100644
View file @
675b67b1
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:saml_group_link
do
sequence
(
:saml_group_name
)
{
|
n
|
"saml-group
#{
n
}
"
}
access_level
{
Gitlab
::
Access
::
GUEST
}
group
end
end
ee/spec/models/group_spec.rb
View file @
675b67b1
...
...
@@ -23,6 +23,7 @@ RSpec.describe Group do
it
{
is_expected
.
to
have_one
(
:deletion_schedule
)
}
it
{
is_expected
.
to
have_one
(
:group_wiki_repository
)
}
it
{
is_expected
.
to
belong_to
(
:push_rule
)
}
it
{
is_expected
.
to
have_many
(
:saml_group_links
)
}
it_behaves_like
'model with wiki'
do
let
(
:container
)
{
create
(
:group
,
:nested
,
:wiki_repo
)
}
...
...
@@ -767,6 +768,30 @@ RSpec.describe Group do
end
end
describe
'#saml_enabled?'
do
subject
{
group
.
saml_enabled?
}
context
'when a SAML provider does not exist'
do
it
{
is_expected
.
to
eq
(
false
)
}
end
context
'when a SAML provider exists and is persisted'
do
before
do
create
(
:saml_provider
,
group:
group
)
end
it
{
is_expected
.
to
eq
(
true
)
}
end
context
'when a SAML provider is not persisted'
do
before
do
build
(
:saml_provider
,
group:
group
)
end
it
{
is_expected
.
to
eq
(
false
)
}
end
end
describe
'#alpha/beta_feature_available?'
do
it_behaves_like
'an entity with alpha/beta feature support'
do
let
(
:entity
)
{
group
}
...
...
ee/spec/models/saml_group_link_spec.rb
0 → 100644
View file @
675b67b1
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
SamlGroupLink
do
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:group
)
}
end
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:group
)
}
it
{
is_expected
.
to
validate_presence_of
(
:access_level
)
}
it
{
is_expected
.
to
validate_presence_of
(
:saml_group_name
)
}
it
{
is_expected
.
to
validate_length_of
(
:saml_group_name
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
define_enum_for
(
:access_level
).
with_values
(
Gitlab
::
Access
.
options_with_owner
)
}
context
'group name uniqueness'
do
before
do
create
(
:saml_group_link
,
group:
create
(
:group
))
end
it
{
is_expected
.
to
validate_uniqueness_of
(
:saml_group_name
).
scoped_to
([
:group_id
])
}
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