Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
GitLab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
GitLab.org
GitLab
Commits
3dadb1f8
Unverified
Commit
3dadb1f8
authored
6 years ago
by
Nick Thomas
Browse files
Options
Downloads
Patches
Plain Diff
Allow SshHostKey.find_by to accept string keys
parent
2b0f4df0
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/ssh_host_key.rb
+1
-0
1 addition, 0 deletions
app/models/ssh_host_key.rb
spec/models/ssh_host_key_spec.rb
+23
-0
23 additions, 0 deletions
spec/models/ssh_host_key_spec.rb
with
24 additions
and
0 deletions
app/models/ssh_host_key.rb
+
1
−
0
View file @
3dadb1f8
...
...
@@ -26,6 +26,7 @@ def as_json(*)
self
.
reactive_cache_lifetime
=
10
.
minutes
def
self
.
find_by
(
opts
=
{})
opts
=
HashWithIndifferentAccess
.
new
(
opts
)
return
nil
unless
opts
.
key?
(
:id
)
project_id
,
url
=
opts
[
:id
].
split
(
':'
,
2
)
...
...
This diff is collapsed.
Click to expand it.
spec/models/ssh_host_key_spec.rb
+
23
−
0
View file @
3dadb1f8
...
...
@@ -56,6 +56,29 @@ def stub_ssh_keyscan(args, status: true, stdout: "", stderr: "")
end
end
describe
'.find_by'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:url
)
{
'ssh://invalid.invalid:2222'
}
let
(
:finding_id
)
{
[
project
.
id
,
url
].
join
(
':'
)
}
it
'accepts a string key'
do
result
=
described_class
.
find_by
(
'id'
=>
finding_id
)
expect
(
result
).
to
be_a
(
described_class
)
expect
(
result
.
project
).
to
eq
(
project
)
expect
(
result
.
url
.
to_s
).
to
eq
(
url
)
end
it
'accepts a symbol key'
do
result
=
described_class
.
find_by
(
id:
finding_id
)
expect
(
result
).
to
be_a
(
described_class
)
expect
(
result
.
project
).
to
eq
(
project
)
expect
(
result
.
url
.
to_s
).
to
eq
(
url
)
end
end
describe
'#fingerprints'
,
:use_clean_rails_memory_store_caching
do
it
'returns an array of indexed fingerprints when the cache is filled'
do
stub_reactive_cache
(
ssh_host_key
,
known_hosts:
known_hosts
)
...
...
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