diff --git a/qa/qa.rb b/qa/qa.rb index e084ef17985df4ef510668e98eb346a9cb314639..dfe549de7086f9a87025f415904b67fe7b4d1041 100644 --- a/qa/qa.rb +++ b/qa/qa.rb @@ -435,6 +435,10 @@ module Page autoload :Login, 'qa/vendor/github/page/login' end end + + module OnePassword + autoload :CLI, 'qa/vendor/one_password/cli' + end end # Classes that provide support to other parts of the framework. diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index a437c83100a873620484c23e417fb131bd718895..b4047ef508867d911ae5da234a519a3689e29033 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -177,6 +177,22 @@ def gitlab_qa_password_6 ENV['GITLAB_QA_PASSWORD_6'] 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? !!(ENV['KNAPSACK_GENERATE_REPORT'] || ENV['KNAPSACK_REPORT_PATH'] || ENV['KNAPSACK_TEST_FILE_PATTERN']) end diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb index db99488160b71080c46dcafd055365e6c4e37aef..a118176eb8ae1fb006d4e8f6f483e7ba00feeb45 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true module QA - # Failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/121 - context 'Manage', :orchestrated, :oauth, :quarantine do + context 'Manage', :orchestrated, :oauth do describe 'OAuth login' do it 'User logs in to GitLab with GitHub OAuth' do Runtime::Browser.visit(:gitlab, Page::Main::Login) diff --git a/qa/qa/vendor/github/page/login.rb b/qa/qa/vendor/github/page/login.rb index 120ba6e6c0687f5c99717cc0ee3cbf16abf2e850..f6e72bb01f98d6c7f7621d04a3ecb8116a4f380d 100644 --- a/qa/qa/vendor/github/page/login.rb +++ b/qa/qa/vendor/github/page/login.rb @@ -12,6 +12,12 @@ def login fill_in 'password', with: QA::Runtime::Env.github_password 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') end end diff --git a/qa/qa/vendor/one_password/cli.rb b/qa/qa/vendor/one_password/cli.rb new file mode 100644 index 0000000000000000000000000000000000000000..3cb69391783559768eebaa28a72d13e995d56a85 --- /dev/null +++ b/qa/qa/vendor/one_password/cli.rb @@ -0,0 +1,34 @@ +# 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 diff --git a/qa/qa/vendor/one_password/darwin/op b/qa/qa/vendor/one_password/darwin/op new file mode 100755 index 0000000000000000000000000000000000000000..0f646522834582ed63b7b2794aa8ec982823b1a9 Binary files /dev/null and b/qa/qa/vendor/one_password/darwin/op differ diff --git a/qa/qa/vendor/one_password/linux/op b/qa/qa/vendor/one_password/linux/op new file mode 100755 index 0000000000000000000000000000000000000000..47ce87731be20e118990344e0c720db248cb7d78 Binary files /dev/null and b/qa/qa/vendor/one_password/linux/op differ