Commit 44dc8051 authored by Sanad Liaquat's avatar Sanad Liaquat

Remove GitHub OAuth e2e spec

Also remove the related scenario and supporting code
parent 550d687c
......@@ -30,8 +30,7 @@ module AuthHelper
def qa_class_for_provider(provider)
{
saml: 'qa-saml-login-button',
github: 'qa-github-login-button'
saml: 'qa-saml-login-button'
}[provider.to_sym]
end
......
......@@ -134,7 +134,6 @@ module QA
autoload :LDAPNoServer, 'qa/scenario/test/integration/ldap_no_server'
autoload :LDAPTLS, 'qa/scenario/test/integration/ldap_tls'
autoload :InstanceSAML, 'qa/scenario/test/integration/instance_saml'
autoload :OAuth, 'qa/scenario/test/integration/oauth'
autoload :Kubernetes, 'qa/scenario/test/integration/kubernetes'
autoload :Mattermost, 'qa/scenario/test/integration/mattermost'
autoload :ObjectStorage, 'qa/scenario/test/integration/object_storage'
......@@ -483,17 +482,6 @@ module QA
autoload :ConfigureJob, 'qa/vendor/jenkins/page/configure_job'
end
end
module Github
module Page
autoload :Base, 'qa/vendor/github/page/base'
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.
......
......@@ -35,7 +35,6 @@ module QA
view 'app/helpers/auth_helper.rb' do
element :saml_login_button
element :github_login_button
end
view 'app/views/layouts/devise.html.haml' do
......@@ -139,11 +138,6 @@ module QA
click_element :standard_tab
end
def sign_in_with_github
set_initial_password_if_present
click_element :github_login_button
end
def sign_in_with_saml
set_initial_password_if_present
click_element :saml_login_button
......
# frozen_string_literal: true
module QA
module Scenario
module Test
module Integration
class OAuth < Test::Instance::All
tags :oauth
end
end
end
end
end
# frozen_string_literal: true
module QA
# This test is skipped instead of quarantine because continuously running
# this test may cause the user to hit GitHub's rate limits thus blocking the user.
# Related issue: https://gitlab.com/gitlab-org/gitlab/issues/196517
context 'Manage', :orchestrated, :oauth, :skip do
describe 'OAuth login' do
it 'User logs in to GitLab with GitHub OAuth' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_with_github)
Vendor::Github::Page::Login.perform(&:login)
expect(page).to have_content('Welcome to GitLab')
end
end
end
end
# frozen_string_literal: true
module QA
module Vendor
module Github
module Page
class Base
include Capybara::DSL
include Scenario::Actable
end
end
end
end
end
# frozen_string_literal: true
require 'capybara/dsl'
require 'benchmark'
module QA
module Vendor
module Github
module Page
class Login < Page::Base
def login
fill_in 'login', with: QA::Runtime::Env.github_username
fill_in 'password', with: QA::Runtime::Env.github_password
click_on 'Sign in'
Support::Retrier.retry_until(raise_on_failure: true, sleep_interval: 35) do
fresh_otp = nil
time = Benchmark.realtime do
fresh_otp = OnePassword::CLI.instance.fresh_otp
end
QA::Runtime::Logger.info("Returned fresh_otp: #{fresh_otp} in #{time} seconds")
fill_in 'otp', with: fresh_otp
click_on 'Verify'
!has_text?('Two-factor authentication failed', wait: 1.0)
end
click_on 'Authorize gitlab-qa' if has_button?('Authorize gitlab-qa')
end
end
end
end
end
end
# frozen_string_literal: true
require 'benchmark'
module QA
module Vendor
module OnePassword
class CLI
include Singleton
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 fresh_otp
otps = []
# Fetches a fresh OTP and returns it only after op provides the same OTP twice
# An OTP is valid for 30 seconds so 70 attempts with 0.5 interval would ensure we complete 1 cycle
Support::Retrier.retry_until(max_attempts: 70, sleep_interval: 0.5) do
otps << fetch_otp
otps.size >= 3 && otps[-1] == otps[-2] && otps[-1] != otps[-3]
end
otps.last
end
private
def fetch_otp
result = nil
time = Benchmark.realtime do
result = `#{op_path} get totp #{@github_uuid} --session=#{session_token}`.to_i
end
QA::Runtime::Logger.info("Fetched OTP: #{result} in: #{time} seconds")
result
end
# OP session tokens are valid for 30 minutes. We are caching the session token here and this is fine currently
# as we just have one test that is not expected to go over 30 minutes.
# But note that if we add more tests that use this class, we might need to add a mechanism to invalidate
# the cache after 30 minutes or if the session_token is rejected by op CLI.
def session_token
@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
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::OAuth do
describe '#perform' do
it_behaves_like 'a QA scenario class' do
let(:tags) { [:oauth] }
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