Commit 05db0a6a authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'qa-shl-nightly-121-fix-login-via-oauth-spec' into 'master'

Use 1Password CLI to pull OTP for GitHub OAuth

Closes gitlab-org/quality/nightly#121

See merge request gitlab-org/gitlab!17691
parents 45811f91 2b49fca7
...@@ -435,6 +435,10 @@ module QA ...@@ -435,6 +435,10 @@ module QA
autoload :Login, 'qa/vendor/github/page/login' autoload :Login, 'qa/vendor/github/page/login'
end end
end end
module OnePassword
autoload :CLI, 'qa/vendor/one_password/cli'
end
end end
# Classes that provide support to other parts of the framework. # Classes that provide support to other parts of the framework.
......
...@@ -177,6 +177,22 @@ module QA ...@@ -177,6 +177,22 @@ module QA
ENV['GITLAB_QA_PASSWORD_6'] ENV['GITLAB_QA_PASSWORD_6']
end end
def gitlab_qa_1p_email
ENV['GITLAB_QA_1P_EMAIL']
end
def gitlab_qa_1p_password
ENV['GITLAB_QA_1P_PASSWORD']
end
def gitlab_qa_1p_secret
ENV['GITLAB_QA_1P_SECRET']
end
def gitlab_qa_1p_github_uuid
ENV['GITLAB_QA_1P_GITHUB_UUID']
end
def knapsack? def knapsack?
!!(ENV['KNAPSACK_GENERATE_REPORT'] || ENV['KNAPSACK_REPORT_PATH'] || ENV['KNAPSACK_TEST_FILE_PATTERN']) !!(ENV['KNAPSACK_GENERATE_REPORT'] || ENV['KNAPSACK_REPORT_PATH'] || ENV['KNAPSACK_TEST_FILE_PATTERN'])
end end
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
# Failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/121 context 'Manage', :orchestrated, :oauth do
context 'Manage', :orchestrated, :oauth, :quarantine do
describe 'OAuth login' do describe 'OAuth login' do
it 'User logs in to GitLab with GitHub OAuth' do it 'User logs in to GitLab with GitHub OAuth' do
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
......
...@@ -12,6 +12,12 @@ module QA ...@@ -12,6 +12,12 @@ module QA
fill_in 'password', with: QA::Runtime::Env.github_password fill_in 'password', with: QA::Runtime::Env.github_password
click_on 'Sign in' click_on 'Sign in'
otp = OnePassword::CLI.new.otp
fill_in 'otp', with: otp
click_on 'Verify'
click_on 'Authorize gitlab-qa' if has_button?('Authorize gitlab-qa') click_on 'Authorize gitlab-qa' if has_button?('Authorize gitlab-qa')
end end
end end
......
# frozen_string_literal: true
module QA
module Vendor
module OnePassword
class CLI
def initialize
@email = QA::Runtime::Env.gitlab_qa_1p_email
@password = QA::Runtime::Env.gitlab_qa_1p_password
@secret = QA::Runtime::Env.gitlab_qa_1p_secret
@github_uuid = QA::Runtime::Env.gitlab_qa_1p_github_uuid
end
def otp
`#{op_path} get totp #{@github_uuid} --session=#{session_token}`.to_i
end
private
def session_token
`echo '#{@password}' | #{op_path} signin gitlab.1password.com #{@email} #{@secret} --output=raw --shorthand=gitlab_qa`
end
def op_path
File.expand_path(File.join(%W[qa vendor one_password #{os} op]))
end
def os
RUBY_PLATFORM.include?("darwin") ? "darwin" : "linux"
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