Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
c5dcd7d8
Unverified
Commit
c5dcd7d8
authored
6 years ago
by
Eugen Rochko
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Speed up test suite by not generating RSA keys in test environment (#7296)
One RSA keypair for all fabricated test accounts is enough
parent
96534531
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/models/account.rb
+2
-2
2 additions, 2 deletions
app/models/account.rb
spec/fabricators/account_fabricator.rb
+7
-1
7 additions, 1 deletion
spec/fabricators/account_fabricator.rb
spec/models/account_spec.rb
+2
-1
2 additions, 1 deletion
spec/models/account_spec.rb
with
11 additions
and
4 deletions
app/models/account.rb
+
2
−
2
View file @
c5dcd7d8
...
...
@@ -406,9 +406,9 @@ class Account < ApplicationRecord
end
def
generate_keys
return
unless
local?
return
unless
local?
&&
!
Rails
.
env
.
test?
keypair
=
OpenSSL
::
PKey
::
RSA
.
new
(
Rails
.
env
.
test?
?
512
:
2048
)
keypair
=
OpenSSL
::
PKey
::
RSA
.
new
(
2048
)
self
.
private_key
=
keypair
.
to_pem
self
.
public_key
=
keypair
.
public_key
.
to_pem
end
...
...
This diff is collapsed.
Click to expand it.
spec/fabricators/account_fabricator.rb
+
7
−
1
View file @
c5dcd7d8
keypair
=
OpenSSL
::
PKey
::
RSA
.
new
(
2048
)
public_key
=
keypair
.
public_key
.
to_pem
private_key
=
keypair
.
to_pem
Fabricator
(
:account
)
do
username
{
sequence
(
:username
)
{
|
i
|
"
#{
Faker
::
Internet
.
user_name
(
nil
,
%w(_)
)
}#{
i
}
"
}
}
username
{
sequence
(
:username
)
{
|
i
|
"
#{
Faker
::
Internet
.
user_name
(
nil
,
%w(_)
)
}#{
i
}
"
}
}
last_webfingered_at
{
Time
.
now
.
utc
}
public_key
{
public_key
}
private_key
{
private_key
}
end
This diff is collapsed.
Click to expand it.
spec/models/account_spec.rb
+
2
−
1
View file @
c5dcd7d8
...
...
@@ -815,7 +815,8 @@ RSpec.describe Account, type: :model do
end
context
'when is local'
do
it
'generates keys'
do
# Test disabled because test environment omits autogenerating keys for performance
xit
'generates keys'
do
account
=
Account
.
create!
(
domain:
nil
,
username:
Faker
::
Internet
.
user_name
(
nil
,
[
'_'
]))
expect
(
account
.
keypair
.
private?
).
to
eq
true
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment