1# frozen_string_literal: true 2 3module QA 4 RSpec.describe 'Create' do 5 describe 'SSH key support' do 6 # Note: If you run these tests against GDK make sure you've enabled sshd 7 # See: https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/run_qa_against_gdk.md 8 9 let(:project) do 10 Resource::Project.fabricate! do |project| 11 project.name = 'ssh-tests' 12 end 13 end 14 15 before(:context) do 16 @key = Resource::SSHKey.fabricate_via_api! do |resource| 17 resource.title = "key for ssh tests #{Time.now.to_f}" 18 end 19 end 20 21 after(:context) do 22 @key.remove_via_api! 23 end 24 25 before do 26 Flow::Login.sign_in 27 end 28 29 it 'pushes code to the repository via SSH', :smoke, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347825' do 30 Resource::Repository::ProjectPush.fabricate! do |push| 31 push.project = project 32 push.ssh_key = @key 33 push.file_name = 'README.md' 34 push.file_content = '# Test Use SSH Key' 35 push.commit_message = 'Add README.md' 36 end.project.visit! 37 38 Page::Project::Show.perform do |project| 39 expect(project).to have_file('README.md') 40 expect(project).to have_readme_content('Test Use SSH Key') 41 end 42 end 43 44 it 'pushes multiple branches and tags together', :smoke, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347826' do 45 branches = [] 46 tags = [] 47 Git::Repository.perform do |repository| 48 repository.uri = project.repository_ssh_location.uri 49 repository.use_ssh_key(@key) 50 repository.clone 51 repository.configure_identity('GitLab QA', 'root@gitlab.com') 52 1.upto(3) do |i| 53 branches << "branch#{i}" 54 tags << "tag#{i}" 55 repository.checkout("branch#{i}", new_branch: true) 56 repository.commit_file("file#{i}", SecureRandom.random_bytes(10000), "Add file#{i}") 57 repository.add_tag("tag#{i}") 58 end 59 repository.push_tags_and_branches(branches) 60 end 61 62 expect(project).to have_branches(branches) 63 expect(project).to have_tags(tags) 64 end 65 end 66 end 67end 68