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
b521c390
Commit
b521c390
authored
May 12, 2020
by
Ryan Cobb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix RSpec/LeakyConstantDeclaration violations
Additional fixes for RSpec/LeakyConstantDeclaration violations.
parent
6717786f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
60 deletions
+65
-60
.rubocop.yml
.rubocop.yml
+0
-5
spec/graphql/gitlab_schema_spec.rb
spec/graphql/gitlab_schema_spec.rb
+9
-5
spec/helpers/visibility_level_helper_spec.rb
spec/helpers/visibility_level_helper_spec.rb
+14
-14
spec/initializers/secret_token_spec.rb
spec/initializers/secret_token_spec.rb
+4
-5
spec/lib/declarative_policy_spec.rb
spec/lib/declarative_policy_spec.rb
+4
-2
spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb
...d_migration/migrate_issue_trackers_sensitive_data_spec.rb
+34
-29
No files found.
.rubocop.yml
View file @
b521c390
...
@@ -348,12 +348,7 @@ RSpec/LeakyConstantDeclaration:
...
@@ -348,12 +348,7 @@ RSpec/LeakyConstantDeclaration:
Enabled
:
true
Enabled
:
true
Exclude
:
Exclude
:
-
'
spec/db/schema_spec.rb'
-
'
spec/db/schema_spec.rb'
-
'
spec/graphql/gitlab_schema_spec.rb'
-
'
spec/helpers/visibility_level_helper_spec.rb'
-
'
spec/initializers/secret_token_spec.rb'
-
'
spec/lib/declarative_policy_spec.rb'
-
'
spec/lib/feature_spec.rb'
-
'
spec/lib/feature_spec.rb'
-
'
spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb'
-
'
spec/lib/gitlab/ci/build/credentials/factory_spec.rb'
-
'
spec/lib/gitlab/ci/build/credentials/factory_spec.rb'
-
'
spec/lib/gitlab/ci/config/entry/retry_spec.rb'
-
'
spec/lib/gitlab/ci/config/entry/retry_spec.rb'
-
'
spec/lib/gitlab/cluster/mixins/puma_cluster_spec.rb'
-
'
spec/lib/gitlab/cluster/mixins/puma_cluster_spec.rb'
...
...
spec/graphql/gitlab_schema_spec.rb
View file @
b521c390
...
@@ -191,12 +191,16 @@ describe GitlabSchema do
...
@@ -191,12 +191,16 @@ describe GitlabSchema do
context
'for other classes'
do
context
'for other classes'
do
# We cannot use an anonymous class here as `GlobalID` expects `.name` not
# We cannot use an anonymous class here as `GlobalID` expects `.name` not
# to return `nil`
# to return `nil`
class
TestGlobalId
before
do
include
GlobalID
::
Identification
stub_const
(
'TestGlobalId'
,
Class
.
new
)
attr_accessor
:id
def
initialize
(
id
)
TestGlobalId
.
class_eval
do
@id
=
id
include
GlobalID
::
Identification
attr_accessor
:id
def
initialize
(
id
)
@id
=
id
end
end
end
end
end
...
...
spec/helpers/visibility_level_helper_spec.rb
View file @
b521c390
...
@@ -146,22 +146,22 @@ describe VisibilityLevelHelper do
...
@@ -146,22 +146,22 @@ describe VisibilityLevelHelper do
using
RSpec
::
Parameterized
::
TableSyntax
using
RSpec
::
Parameterized
::
TableSyntax
PUBLIC
=
Gitlab
::
VisibilityLevel
::
PUBLIC
INTERNAL
=
Gitlab
::
VisibilityLevel
::
INTERNAL
PRIVATE
=
Gitlab
::
VisibilityLevel
::
PRIVATE
# This is a subset of all the permutations
# This is a subset of all the permutations
where
(
:requested_level
,
:max_allowed
,
:global_default_level
,
:restricted_levels
,
:expected
)
do
where
(
:requested_level
,
:max_allowed
,
:global_default_level
,
:restricted_levels
,
:expected
)
do
PUBLIC
|
PUBLIC
|
PUBLIC
|
[]
|
PUBLIC
public_vis
=
Gitlab
::
VisibilityLevel
::
PUBLIC
PUBLIC
|
PUBLIC
|
PUBLIC
|
[
PUBLIC
]
|
INTERNAL
internal
=
Gitlab
::
VisibilityLevel
::
INTERNAL
INTERNAL
|
PUBLIC
|
PUBLIC
|
[]
|
INTERNAL
private_vis
=
Gitlab
::
VisibilityLevel
::
PRIVATE
INTERNAL
|
PRIVATE
|
PRIVATE
|
[]
|
PRIVATE
PRIVATE
|
PUBLIC
|
PUBLIC
|
[]
|
PRIVATE
public_vis
|
public_vis
|
public_vis
|
[]
|
public_vis
PUBLIC
|
PRIVATE
|
INTERNAL
|
[]
|
PRIVATE
public_vis
|
public_vis
|
public_vis
|
[
public_vis
]
|
internal
PUBLIC
|
INTERNAL
|
PUBLIC
|
[]
|
INTERNAL
internal
|
public_vis
|
public_vis
|
[]
|
internal
PUBLIC
|
PRIVATE
|
PUBLIC
|
[]
|
PRIVATE
internal
|
private_vis
|
private_vis
|
[]
|
private_vis
PUBLIC
|
INTERNAL
|
INTERNAL
|
[]
|
INTERNAL
private_vis
|
public_vis
|
public_vis
|
[]
|
private_vis
PUBLIC
|
PUBLIC
|
INTERNAL
|
[]
|
PUBLIC
public_vis
|
private_vis
|
internal
|
[]
|
private_vis
public_vis
|
internal
|
public_vis
|
[]
|
internal
public_vis
|
private_vis
|
public_vis
|
[]
|
private_vis
public_vis
|
internal
|
internal
|
[]
|
internal
public_vis
|
public_vis
|
internal
|
[]
|
public_vis
end
end
before
do
before
do
...
...
spec/initializers/secret_token_spec.rb
View file @
b521c390
...
@@ -7,9 +7,8 @@ describe 'create_tokens' do
...
@@ -7,9 +7,8 @@ describe 'create_tokens' do
include
StubENV
include
StubENV
let
(
:secrets
)
{
ActiveSupport
::
OrderedOptions
.
new
}
let
(
:secrets
)
{
ActiveSupport
::
OrderedOptions
.
new
}
let
(
:hex_key
)
{
/\h{128}/
.
freeze
}
HEX_KEY
=
/\h{128}/
.
freeze
let
(
:rsa_key
)
{
/\A-----BEGIN RSA PRIVATE KEY-----\n.+\n-----END RSA PRIVATE KEY-----\n\Z/m
.
freeze
}
RSA_KEY
=
/\A-----BEGIN RSA PRIVATE KEY-----\n.+\n-----END RSA PRIVATE KEY-----\n\Z/m
.
freeze
before
do
before
do
allow
(
File
).
to
receive
(
:write
)
allow
(
File
).
to
receive
(
:write
)
...
@@ -35,7 +34,7 @@ describe 'create_tokens' do
...
@@ -35,7 +34,7 @@ describe 'create_tokens' do
keys
=
secrets
.
values_at
(
:secret_key_base
,
:otp_key_base
,
:db_key_base
)
keys
=
secrets
.
values_at
(
:secret_key_base
,
:otp_key_base
,
:db_key_base
)
expect
(
keys
.
uniq
).
to
eq
(
keys
)
expect
(
keys
.
uniq
).
to
eq
(
keys
)
expect
(
keys
).
to
all
(
match
(
HEX_KEY
))
expect
(
keys
).
to
all
(
match
(
hex_key
))
end
end
it
'generates an RSA key for openid_connect_signing_key'
do
it
'generates an RSA key for openid_connect_signing_key'
do
...
@@ -44,7 +43,7 @@ describe 'create_tokens' do
...
@@ -44,7 +43,7 @@ describe 'create_tokens' do
keys
=
secrets
.
values_at
(
:openid_connect_signing_key
)
keys
=
secrets
.
values_at
(
:openid_connect_signing_key
)
expect
(
keys
.
uniq
).
to
eq
(
keys
)
expect
(
keys
.
uniq
).
to
eq
(
keys
)
expect
(
keys
).
to
all
(
match
(
RSA_KEY
))
expect
(
keys
).
to
all
(
match
(
rsa_key
))
end
end
it
'warns about the secrets to add to secrets.yml'
do
it
'warns about the secrets to add to secrets.yml'
do
...
...
spec/lib/declarative_policy_spec.rb
View file @
b521c390
...
@@ -23,8 +23,10 @@ describe DeclarativePolicy do
...
@@ -23,8 +23,10 @@ describe DeclarativePolicy do
end
end
context
'when found policy class does not inherit base'
do
context
'when found policy class does not inherit base'
do
class
Foo
;
end
before
do
class
FooPolicy
;
end
stub_const
(
'Foo'
,
Class
.
new
)
stub_const
(
'FooPolicy'
,
Class
.
new
)
end
it
'raises error if inferred class does not inherit Base'
do
it
'raises error if inferred class does not inherit Base'
do
instance
=
Foo
.
new
instance
=
Foo
.
new
...
...
spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb
View file @
b521c390
...
@@ -4,40 +4,45 @@ require 'spec_helper'
...
@@ -4,40 +4,45 @@ require 'spec_helper'
describe
Gitlab
::
BackgroundMigration
::
MigrateIssueTrackersSensitiveData
,
schema:
20200130145430
do
describe
Gitlab
::
BackgroundMigration
::
MigrateIssueTrackersSensitiveData
,
schema:
20200130145430
do
let
(
:services
)
{
table
(
:services
)
}
let
(
:services
)
{
table
(
:services
)
}
# we need to define the classes due to encryption
before
do
class
IssueTrackerData
<
ApplicationRecord
# we need to define the classes due to encryption
self
.
table_name
=
'issue_tracker_data'
stub_const
(
'IssueTrackerData'
,
Class
.
new
(
ApplicationRecord
))
stub_const
(
'JiraTrackerData'
,
Class
.
new
(
ApplicationRecord
))
def
self
.
encryption_options
{
IssueTrackerData
.
class_eval
do
key:
Settings
.
attr_encrypted_db_key_base_32
,
self
.
table_name
=
'issue_tracker_data'
encode:
true
,
mode: :per_attribute_iv
,
def
self
.
encryption_options
algorithm:
'aes-256-gcm'
{
}
key:
Settings
.
attr_encrypted_db_key_base_32
,
encode:
true
,
mode: :per_attribute_iv
,
algorithm:
'aes-256-gcm'
}
end
attr_encrypted
:project_url
,
encryption_options
attr_encrypted
:issues_url
,
encryption_options
attr_encrypted
:new_issue_url
,
encryption_options
end
end
attr_encrypted
:project_url
,
encryption_options
JiraTrackerData
.
class_eval
do
attr_encrypted
:issues_url
,
encryption_options
self
.
table_name
=
'jira_tracker_data'
attr_encrypted
:new_issue_url
,
encryption_options
end
class
JiraTrackerData
<
ApplicationRecord
def
self
.
encryption_options
self
.
table_name
=
'jira_tracker_data'
{
key:
Settings
.
attr_encrypted_db_key_base_32
,
encode:
true
,
mode: :per_attribute_iv
,
algorithm:
'aes-256-gcm'
}
end
def
self
.
encryption_options
attr_encrypted
:url
,
encryption_options
{
attr_encrypted
:api_url
,
encryption_options
key:
Settings
.
attr_encrypted_db_key_base_32
,
attr_encrypted
:username
,
encryption_options
encode:
true
,
attr_encrypted
:password
,
encryption_options
mode: :per_attribute_iv
,
algorithm:
'aes-256-gcm'
}
end
end
attr_encrypted
:url
,
encryption_options
attr_encrypted
:api_url
,
encryption_options
attr_encrypted
:username
,
encryption_options
attr_encrypted
:password
,
encryption_options
end
end
let
(
:url
)
{
'http://base-url.tracker.com'
}
let
(
:url
)
{
'http://base-url.tracker.com'
}
...
...
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