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
437f59c2
Commit
437f59c2
authored
Mar 28, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put project and runner in before(:all)
parent
9d9ee761
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
27 deletions
+34
-27
qa/qa/specs/features/project/deploy_key_clone_spec.rb
qa/qa/specs/features/project/deploy_key_clone_spec.rb
+34
-27
No files found.
qa/qa/specs/features/project/deploy_key_clone_spec.rb
View file @
437f59c2
...
...
@@ -2,16 +2,32 @@ require 'digest/sha1'
module
QA
feature
'cloning code using a deploy key'
,
:core
,
:docker
do
let
(
:runner_name
)
{
"qa-runner-
#{
Time
.
now
.
to_i
}
"
}
def
login
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
end
before
(
:all
)
do
login
@runner_name
=
"qa-runner-
#{
Time
.
now
.
to_i
}
"
given
(
:project
)
do
Factory
::
Resource
::
Project
.
fabricate!
do
|
resource
|
@project
=
Factory
::
Resource
::
Project
.
fabricate!
do
|
resource
|
resource
.
name
=
'deploy-key-clone-project'
end
@repository_uri
=
@project
.
repository_ssh_uri
Factory
::
Resource
::
Runner
.
fabricate!
do
|
resource
|
resource
.
project
=
@project
resource
.
name
=
@runner_name
resource
.
tags
=
%w[qa docker]
resource
.
image
=
'gitlab/gitlab-runner:ubuntu'
end
end
after
do
Service
::
Runner
.
new
(
runner_name
).
remove!
after
(
:all
)
do
Service
::
Runner
.
new
(
@
runner_name
).
remove!
end
keys
=
[
...
...
@@ -22,51 +38,42 @@ module QA
keys
.
each
do
|
key
|
scenario
"user sets up a deploy key with
#{
key
.
name
}
(
#{
key
.
bits
}
) to clone code using pipelines"
do
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
Factory
::
Resource
::
Runner
.
fabricate!
do
|
resource
|
resource
.
project
=
project
resource
.
name
=
runner_name
resource
.
tags
=
%w[qa docker]
resource
.
image
=
'gitlab/gitlab-runner:ubuntu'
end
login
Factory
::
Resource
::
DeployKey
.
fabricate!
do
|
resource
|
resource
.
project
=
project
resource
.
title
=
'deploy key title'
resource
.
project
=
@
project
resource
.
title
=
"deploy key
#{
key
.
name
}
(
#{
key
.
bits
}
)"
resource
.
key
=
key
.
public_key
end
deploy_key_name
=
"DEPLOY_KEY_
#{
key
.
name
}
_
#{
key
.
bits
}
"
Factory
::
Resource
::
SecretVariable
.
fabricate!
do
|
resource
|
resource
.
project
=
project
resource
.
key
=
'DEPLOY_KEY'
resource
.
project
=
@
project
resource
.
key
=
deploy_key_name
resource
.
value
=
key
.
private_key
end
project
.
visit!
repository_uri
=
project
.
repository_ssh_uri
gitlab_ci
=
<<~
YAML
cat-config:
script:
- mkdir -p ~/.ssh
- ssh-keyscan -p
#{
repository_uri
.
port
}
#{
repository_uri
.
host
}
>> ~/.ssh/known_hosts
- ssh-keyscan -p
#{
@repository_uri
.
port
}
#{
@
repository_uri
.
host
}
>> ~/.ssh/known_hosts
- eval $(ssh-agent -s)
- echo "$
DEPLOY_KEY
" | ssh-add -
- git clone
#{
repository_uri
.
git_uri
}
- sha1sum
#{
project
.
name
}
/.gitlab-ci.yml
- echo "$
#{
deploy_key_name
}
" | ssh-add -
- git clone
#{
@
repository_uri
.
git_uri
}
- sha1sum
#{
@
project
.
name
}
/.gitlab-ci.yml
tags:
- qa
- docker
YAML
Factory
::
Repository
::
Push
.
fabricate!
do
|
resource
|
resource
.
project
=
project
resource
.
project
=
@
project
resource
.
file_name
=
'.gitlab-ci.yml'
resource
.
commit_message
=
'Add .gitlab-ci.yml'
resource
.
file_content
=
gitlab_ci
resource
.
branch_name
=
deploy_key_name
end
sha1sum
=
Digest
::
SHA1
.
hexdigest
(
gitlab_ci
)
...
...
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