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
c551d38e
Commit
c551d38e
authored
Jun 04, 2021
by
Fabio Pitino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feedback from review
parent
22718b69
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
109 deletions
+0
-109
app/models/ci/job_token/scope_link.rb
app/models/ci/job_token/scope_link.rb
+0
-19
db/migrate/20210527194558_create_ci_job_token_scope_links.rb
db/migrate/20210527194558_create_ci_job_token_scope_links.rb
+0
-30
db/structure.sql
db/structure.sql
+0
-6
spec/factories/ci/job_token/scope_links.rb
spec/factories/ci/job_token/scope_links.rb
+0
-9
spec/models/ci/job_token/scope_link_spec.rb
spec/models/ci/job_token/scope_link_spec.rb
+0
-45
No files found.
app/models/ci/job_token/scope_link.rb
deleted
100644 → 0
View file @
22718b69
# frozen_string_literal: true
# The connection between a source project (which defines the job token scope)
# and a target project which is the one allowed to be accessed by the job token.
module
Ci
module
JobToken
class
ScopeLink
<
ApplicationRecord
self
.
table_name
=
'ci_job_token_scope_links'
belongs_to
:source_project
,
class_name:
'Project'
belongs_to
:target_project
,
class_name:
'Project'
belongs_to
:added_by
,
class_name:
'User'
scope
:from_project
,
->
(
project
)
{
where
(
source_project:
project
)
}
scope
:to_project
,
->
(
project
)
{
where
(
target_project:
project
)
}
end
end
end
db/migrate/20210527194558_create_ci_job_token_scope_links.rb
deleted
100644 → 0
View file @
22718b69
# frozen_string_literal: true
class
CreateCiJobTokenScopeLinks
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
unless
table_exists?
(
:ci_job_token_scope_links
)
with_lock_retries
do
create_table
:ci_job_token_scope_links
do
|
t
|
t
.
belongs_to
:source_project
,
null:
false
,
foreign_key:
{
to_table: :projects
,
on_delete: :cascade
}
t
.
belongs_to
:target_project
,
null:
false
,
foreign_key:
{
to_table: :projects
,
on_delete: :cascade
}
t
.
belongs_to
:added_by
,
foreign_key:
{
to_table: :users
,
on_delete: :nullify
}
t
.
datetime_with_timezone
:created_at
,
null:
false
t
.
index
[
:source_project_id
,
:target_project_id
],
unique:
true
,
name:
'i_ci_job_token_scope_links_on_source_and_target_project'
end
end
end
end
def
down
with_lock_retries
do
drop_table
:ci_job_token_scope_links
end
end
end
db/structure.sql
View file @
c551d38e
...
@@ -27161,9 +27161,6 @@ ALTER TABLE ONLY operations_feature_flag_scopes
...
@@ -27161,9 +27161,6 @@ ALTER TABLE ONLY operations_feature_flag_scopes
ALTER TABLE ONLY packages_helm_file_metadata
ALTER TABLE ONLY packages_helm_file_metadata
ADD CONSTRAINT fk_rails_a559865345 FOREIGN KEY (package_file_id) REFERENCES packages_package_files(id) ON DELETE CASCADE;
ADD CONSTRAINT fk_rails_a559865345 FOREIGN KEY (package_file_id) REFERENCES packages_package_files(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_job_token_scope_links
ADD CONSTRAINT fk_rails_a562b502cf FOREIGN KEY (added_by_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY cluster_projects
ALTER TABLE ONLY cluster_projects
ADD CONSTRAINT fk_rails_a5a958bca1 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE;
ADD CONSTRAINT fk_rails_a5a958bca1 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE;
...
@@ -27455,9 +27452,6 @@ ALTER TABLE ONLY ci_running_builds
...
@@ -27455,9 +27452,6 @@ ALTER TABLE ONLY ci_running_builds
ALTER TABLE ONLY jira_imports
ALTER TABLE ONLY jira_imports
ADD CONSTRAINT fk_rails_da617096ce FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
ADD CONSTRAINT fk_rails_da617096ce FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY ci_job_token_scope_links
ADD CONSTRAINT fk_rails_dae96135e0 FOREIGN KEY (target_project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY dependency_proxy_blobs
ALTER TABLE ONLY dependency_proxy_blobs
ADD CONSTRAINT fk_rails_db58bbc5d7 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ADD CONSTRAINT fk_rails_db58bbc5d7 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
spec/factories/ci/job_token/scope_links.rb
deleted
100644 → 0
View file @
22718b69
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:ci_job_token_scope_link
,
class:
'Ci::JobToken::ScopeLink'
do
source_project
factory: :project
target_project
factory: :project
added_by
factory: :user
end
end
spec/models/ci/job_token/scope_link_spec.rb
deleted
100644 → 0
View file @
22718b69
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Ci
::
JobToken
::
ScopeLink
do
it
{
is_expected
.
to
belong_to
(
:source_project
)
}
it
{
is_expected
.
to
belong_to
(
:target_project
)
}
it
{
is_expected
.
to
belong_to
(
:added_by
)
}
describe
'unique index'
do
let!
(
:link
)
{
create
(
:ci_job_token_scope_link
)
}
it
'raises an error'
do
expect
do
create
(
:ci_job_token_scope_link
,
link
.
attributes
)
end
.
to
raise_error
(
ActiveRecord
::
RecordNotUnique
)
end
end
describe
'.from_project'
do
let
(
:project
)
{
create
(
:project
)
}
subject
{
described_class
.
from_project
(
project
)
}
let!
(
:source_link
)
{
create
(
:ci_job_token_scope_link
,
source_project:
project
)
}
let!
(
:target_link
)
{
create
(
:ci_job_token_scope_link
,
target_project:
project
)
}
it
'returns only the links having the given source project'
do
expect
(
subject
).
to
contain_exactly
(
source_link
)
end
end
describe
'.to_project'
do
let
(
:project
)
{
create
(
:project
)
}
subject
{
described_class
.
to_project
(
project
)
}
let!
(
:source_link
)
{
create
(
:ci_job_token_scope_link
,
source_project:
project
)
}
let!
(
:target_link
)
{
create
(
:ci_job_token_scope_link
,
target_project:
project
)
}
it
'returns only the links having the given target project'
do
expect
(
subject
).
to
contain_exactly
(
target_link
)
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