summaryrefslogtreecommitdiff
path: root/qa/qa/factory
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/factory')
-rw-r--r--qa/qa/factory/repository/project_push.rb18
-rw-r--r--qa/qa/factory/repository/push.rb18
-rw-r--r--qa/qa/factory/repository/wiki_push.rb4
-rw-r--r--qa/qa/factory/resource/branch.rb2
-rw-r--r--qa/qa/factory/resource/fork.rb37
-rw-r--r--qa/qa/factory/resource/project.rb7
-rw-r--r--qa/qa/factory/resource/ssh_key.rb40
-rw-r--r--qa/qa/factory/resource/user.rb5
8 files changed, 118 insertions, 13 deletions
diff --git a/qa/qa/factory/repository/project_push.rb b/qa/qa/factory/repository/project_push.rb
index 4f78098d348..167f47c9141 100644
--- a/qa/qa/factory/repository/project_push.rb
+++ b/qa/qa/factory/repository/project_push.rb
@@ -11,7 +11,9 @@ module QA
factory.output
end
- product(:project) { |factory| factory.project }
+ product :project do |factory|
+ factory.project
+ end
def initialize
@file_name = 'file.txt'
@@ -21,8 +23,8 @@ module QA
@new_branch = true
end
- def repository_uri
- @repository_uri ||= begin
+ def repository_http_uri
+ @repository_http_uri ||= begin
project.visit!
Page::Project::Show.act do
choose_repository_clone_http
@@ -30,6 +32,16 @@ module QA
end
end
end
+
+ def repository_ssh_uri
+ @repository_ssh_uri ||= begin
+ project.visit!
+ Page::Project::Show.act do
+ choose_repository_clone_ssh
+ repository_location.uri
+ end
+ end
+ end
end
end
end
diff --git a/qa/qa/factory/repository/push.rb b/qa/qa/factory/repository/push.rb
index 5b7ebf6c41f..6c5088f1da5 100644
--- a/qa/qa/factory/repository/push.rb
+++ b/qa/qa/factory/repository/push.rb
@@ -5,8 +5,8 @@ module QA
module Repository
class Push < Factory::Base
attr_accessor :file_name, :file_content, :commit_message,
- :branch_name, :new_branch, :output, :repository_uri,
- :user
+ :branch_name, :new_branch, :output, :repository_http_uri,
+ :repository_ssh_uri, :ssh_key, :user
attr_writer :remote_branch
@@ -16,7 +16,8 @@ module QA
@commit_message = "This is a test commit"
@branch_name = 'master'
@new_branch = true
- @repository_uri = ""
+ @repository_http_uri = ""
+ @ssh_key = nil
end
def remote_branch
@@ -31,9 +32,14 @@ module QA
def fabricate!
Git::Repository.perform do |repository|
- repository.uri = repository_uri
+ if ssh_key
+ repository.uri = repository_ssh_uri
+ repository.use_ssh_key(ssh_key)
+ else
+ repository.uri = repository_http_uri
+ repository.use_default_credentials
+ end
- repository.use_default_credentials
username = 'GitLab QA'
email = 'root@gitlab.com'
@@ -63,6 +69,8 @@ module QA
repository.commit(commit_message)
@output = repository.push_changes("#{branch_name}:#{remote_branch}")
+
+ repository.delete_ssh_key
end
end
end
diff --git a/qa/qa/factory/repository/wiki_push.rb b/qa/qa/factory/repository/wiki_push.rb
index fb7c2bb660d..ecc6cc18c88 100644
--- a/qa/qa/factory/repository/wiki_push.rb
+++ b/qa/qa/factory/repository/wiki_push.rb
@@ -16,8 +16,8 @@ module QA
@new_branch = false
end
- def repository_uri
- @repository_uri ||= begin
+ def repository_http_uri
+ @repository_http_uri ||= begin
wiki.visit!
Page::Project::Wiki::Show.act do
go_to_clone_repository
diff --git a/qa/qa/factory/resource/branch.rb b/qa/qa/factory/resource/branch.rb
index bc252bf3148..60539992073 100644
--- a/qa/qa/factory/resource/branch.rb
+++ b/qa/qa/factory/resource/branch.rb
@@ -64,7 +64,7 @@ module QA
end
page.wait(reload: false) do
- !page.first('.btn-create').disabled?
+ !page.first('.btn-success').disabled?
end
page.protect_branch
diff --git a/qa/qa/factory/resource/fork.rb b/qa/qa/factory/resource/fork.rb
index 01969c31438..92050eaba2a 100644
--- a/qa/qa/factory/resource/fork.rb
+++ b/qa/qa/factory/resource/fork.rb
@@ -13,8 +13,43 @@ module QA
product(:user) { |factory| factory.user }
+ def visit_project_with_retry
+ # The user intermittently fails to stay signed in after visiting the
+ # project page. The new user is registered and then signs in and a
+ # screenshot shows that signing in was successful. Then the project
+ # page is visited but a screenshot shows the user is no longer signed
+ # in. It's difficult to reproduce locally but GDK logs don't seem to
+ # show anything unexpected. This method attempts to work around the
+ # problem and capture data to help troubleshoot.
+
+ Capybara::Screenshot.screenshot_and_save_page
+
+ start = Time.now
+
+ while Time.now - start < 20
+ push.project.visit!
+
+ puts "Visited project page"
+ Capybara::Screenshot.screenshot_and_save_page
+
+ return if Page::Menu::Main.act { has_personal_area?(wait: 0) }
+
+ puts "Not signed in. Attempting to sign in again."
+ Capybara::Screenshot.screenshot_and_save_page
+
+ Page::Menu::Main.act { sign_out }
+
+ Page::Main::Login.perform do |login|
+ login.sign_in_using_credentials(user)
+ end
+ end
+
+ raise "Failed to load project page and stay logged in"
+ end
+
def fabricate!
- push.project.visit!
+ visit_project_with_retry
+
Page::Project::Show.act { fork_project }
Page::Project::Fork::New.perform do |fork_new|
diff --git a/qa/qa/factory/resource/project.rb b/qa/qa/factory/resource/project.rb
index 7fff22b5468..90db26ab3ab 100644
--- a/qa/qa/factory/resource/project.rb
+++ b/qa/qa/factory/resource/project.rb
@@ -20,6 +20,13 @@ module QA
end
end
+ product :repository_http_location do
+ Page::Project::Show.act do
+ choose_repository_clone_http
+ repository_location
+ end
+ end
+
def initialize
@description = 'My awesome project'
end
diff --git a/qa/qa/factory/resource/ssh_key.rb b/qa/qa/factory/resource/ssh_key.rb
new file mode 100644
index 00000000000..6c872f32d16
--- /dev/null
+++ b/qa/qa/factory/resource/ssh_key.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+module QA
+ module Factory
+ module Resource
+ class SSHKey < Factory::Base
+ extend Forwardable
+
+ attr_accessor :title
+ attr_reader :private_key, :public_key, :fingerprint
+ def_delegators :key, :private_key, :public_key, :fingerprint
+
+ product :private_key do |factory|
+ factory.private_key
+ end
+
+ product :title do |factory|
+ factory.title
+ end
+
+ product :fingerprint do |factory|
+ factory.fingerprint
+ end
+
+ def key
+ @key ||= Runtime::Key::RSA.new
+ end
+
+ def fabricate!
+ Page::Menu::Main.act { go_to_profile_settings }
+ Page::Menu::Profile.act { click_ssh_keys }
+
+ Page::Profile::SSHKeys.perform do |page|
+ page.add_key(public_key, title)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/factory/resource/user.rb b/qa/qa/factory/resource/user.rb
index eac2a873bd5..34b52223b2d 100644
--- a/qa/qa/factory/resource/user.rb
+++ b/qa/qa/factory/resource/user.rb
@@ -37,7 +37,10 @@ module QA
product(:password) { |factory| factory.password }
def fabricate!
- Page::Menu::Main.perform { |main| main.sign_out }
+ # Don't try to log-out if we're not logged-in
+ if Page::Menu::Main.act { has_personal_area?(wait: 0) }
+ Page::Menu::Main.perform { |main| main.sign_out }
+ end
if credentials_given?
Page::Main::Login.perform do |login|