Commit 020fe75e authored by Mark Lapierre's avatar Mark Lapierre Committed by Ramya Authappan

Update SSH E2E test

- Tests pushing multiple branches and tags together
- Renames the file to be consistent with similar tests
- Makes both smoke tests
parent 2bef64c0
...@@ -102,6 +102,10 @@ module QA ...@@ -102,6 +102,10 @@ module QA
git_lfs_track_result.to_s + git_add_result.to_s git_lfs_track_result.to_s + git_add_result.to_s
end end
def add_tag(tag_name)
run("git tag #{tag_name}").to_s
end
def delete_tag(tag_name) def delete_tag(tag_name)
run(%Q{git push origin --delete #{tag_name}}, max_attempts: 3).to_s run(%Q{git push origin --delete #{tag_name}}, max_attempts: 3).to_s
end end
...@@ -122,6 +126,10 @@ module QA ...@@ -122,6 +126,10 @@ module QA
run("git push --all").to_s run("git push --all").to_s
end end
def push_tags_and_branches(branches)
run("git push --tags origin #{branches.join(' ')}").to_s
end
def merge(branch) def merge(branch)
run("git merge #{branch}") run("git merge #{branch}")
end end
......
...@@ -103,6 +103,20 @@ module QA ...@@ -103,6 +103,20 @@ module QA
response.any? { |file| file[:path] == file_path } response.any? { |file| file[:path] == file_path }
end end
def has_branches?(branches)
branches.all? do |branch|
response = get(Runtime::API::Request.new(api_client, "#{api_repository_branches_path}/#{branch}").url)
response.code == HTTP_STATUS_OK
end
end
def has_tags?(tags)
tags.all? do |tag|
response = get(Runtime::API::Request.new(api_client, "#{api_repository_tags_path}/#{tag}").url)
response.code == HTTP_STATUS_OK
end
end
def api_get_path def api_get_path
"/projects/#{CGI.escape(path_with_namespace)}" "/projects/#{CGI.escape(path_with_namespace)}"
end end
...@@ -131,6 +145,10 @@ module QA ...@@ -131,6 +145,10 @@ module QA
"#{api_get_path}/repository/branches" "#{api_get_path}/repository/branches"
end end
def api_repository_tags_path
"#{api_get_path}/repository/tags"
end
def api_repository_tree_path def api_repository_tree_path
"#{api_get_path}/repository/tree" "#{api_get_path}/repository/tree"
end end
...@@ -212,6 +230,10 @@ module QA ...@@ -212,6 +230,10 @@ module QA
parse_body(get(Runtime::API::Request.new(api_client, api_repository_branches_path).url)) parse_body(get(Runtime::API::Request.new(api_client, api_repository_branches_path).url))
end end
def repository_tags
parse_body(get(Runtime::API::Request.new(api_client, api_repository_tags_path).url))
end
def repository_tree def repository_tree
parse_body(get(Runtime::API::Request.new(api_client, api_repository_tree_path).url)) parse_body(get(Runtime::API::Request.new(api_client, api_repository_tree_path).url))
end end
......
...@@ -16,7 +16,7 @@ module QA ...@@ -16,7 +16,7 @@ module QA
Flow::Login.sign_in Flow::Login.sign_in
end end
it 'creates a basic merge request' do it 'creates a basic merge request', :smoke do
Resource::MergeRequest.fabricate_via_browser_ui! do |merge_request| Resource::MergeRequest.fabricate_via_browser_ui! do |merge_request|
merge_request.project = project merge_request.project = project
merge_request.title = merge_request_title merge_request.title = merge_request_title
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module QA module QA
RSpec.describe 'Create' do RSpec.describe 'Create' do
describe 'Git push over HTTP', :ldap_no_tls do describe 'Git push over HTTP', :ldap_no_tls, :smoke do
it 'user using a personal access token pushes code to the repository' do it 'user using a personal access token pushes code to the repository' do
Flow::Login.sign_in Flow::Login.sign_in
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module QA module QA
RSpec.describe 'Create' do RSpec.describe 'Create' do
describe 'Git push over HTTP', :ldap_no_tls do describe 'Git push over HTTP', :ldap_no_tls do
it 'user pushes code to the repository' do it 'user pushes code to the repository', :smoke do
Flow::Login.sign_in Flow::Login.sign_in
Resource::Repository::ProjectPush.fabricate! do |push| Resource::Repository::ProjectPush.fabricate! do |push|
......
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
describe 'SSH key support' do
# Note: If you run these tests against GDK make sure you've enabled sshd
# See: https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/run_qa_against_gdk.md
let(:project) do
Resource::Project.fabricate! do |project|
project.name = 'ssh-tests'
end
end
before(:context) do
@key = Resource::SSHKey.fabricate_via_api! do |resource|
resource.title = "key for ssh tests #{Time.now.to_f}"
end
end
after(:context) do
@key.remove_via_api!
end
before do
Flow::Login.sign_in
end
it 'pushes code to the repository via SSH', :smoke do
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
push.ssh_key = @key
push.file_name = 'README.md'
push.file_content = '# Test Use SSH Key'
push.commit_message = 'Add README.md'
end.project.visit!
Page::Project::Show.perform do |project|
expect(project).to have_file('README.md')
expect(project).to have_readme_content('Test Use SSH Key')
end
end
it 'pushes multiple branches and tags together', :smoke do
branches = []
tags = []
Git::Repository.perform do |repository|
repository.uri = project.repository_ssh_location.uri
repository.use_ssh_key(@key)
repository.clone
repository.configure_identity('GitLab QA', 'root@gitlab.com')
1.upto(3) do |i|
branches << "branch#{i}"
tags << "tag#{i}"
repository.checkout("branch#{i}", new_branch: true)
repository.commit_file("file#{i}", SecureRandom.random_bytes(10000), "Add file#{i}")
repository.add_tag("tag#{i}")
end
repository.push_tags_and_branches(branches)
end
expect(project).to have_branches(branches)
expect(project).to have_tags(tags)
end
end
end
end
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
describe 'SSH key support' do
# Note: If you run this test against GDK make sure you've enabled sshd
# See: https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/run_qa_against_gdk.md
let(:key_title) { "key for ssh tests #{Time.now.to_f}" }
it 'user adds an ssh key and pushes code to the repository' do
Flow::Login.sign_in
key = Resource::SSHKey.fabricate_via_api! do |resource|
resource.title = key_title
end
Resource::Repository::ProjectPush.fabricate! do |push|
push.ssh_key = key
push.file_name = 'README.md'
push.file_content = '# Test Use SSH Key'
push.commit_message = 'Add README.md'
end.project.visit!
expect(page).to have_content('README.md')
expect(page).to have_content('Test Use SSH Key')
Page::Main::Menu.perform(&:click_settings_link)
Page::Profile::Menu.perform(&:click_ssh_keys)
Page::Profile::SSHKeys.perform do |ssh_keys|
ssh_keys.remove_key(key_title)
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment