Maintenance: Closes #3626 - Fix handling of test that require secrets to not run them for Github PRs.
This commit is contained in:
parent
52a8ad7db0
commit
f7a17b6be8
17 changed files with 31 additions and 91 deletions
2
.github/ci.sh
vendored
2
.github/ci.sh
vendored
|
@ -36,7 +36,7 @@ bundle install --without "${INSTALL_OPTION}"
|
|||
# unit tests
|
||||
bundle exec rubocop
|
||||
bundle exec rake zammad:db:init
|
||||
bundle exec rspec -t ~type:system -t ~searchindex
|
||||
bundle exec rspec -t ~type:system -t ~searchindex -t ~required_envs
|
||||
bundle exec rake zammad:db:reset
|
||||
bundle exec rake test:units
|
||||
ruby -I test/ test/integration/object_manager_test.rb
|
||||
|
|
|
@ -7,7 +7,7 @@ require 'rails_helper'
|
|||
# Individual import steps are tested in spec/lib/sequencer.
|
||||
#
|
||||
|
||||
RSpec.describe 'Freshdesk import', type: :integration, use_vcr: true, db_strategy: :reset do # rubocop:disable RSpec/DescribeClass
|
||||
RSpec.describe 'Freshdesk import', type: :integration, use_vcr: true, db_strategy: :reset, required_envs: %w[IMPORT_FRESHDESK_ENDPOINT IMPORT_FRESHDESK_ENDPOINT_KEY] do # rubocop:disable RSpec/DescribeClass
|
||||
|
||||
before do
|
||||
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
require 'rails_helper'
|
||||
RSpec.describe GitHub, type: :integration do # rubocop:disable RSpec/FilePath
|
||||
|
||||
before(:all) do # rubocop:disable RSpec/BeforeAfterAll
|
||||
required_envs = %w[GITHUB_ENDPOINT GITHUB_APITOKEN]
|
||||
required_envs.each do |key|
|
||||
skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
|
||||
end
|
||||
end
|
||||
RSpec.describe GitHub, type: :integration, required_envs: %w[GITHUB_ENDPOINT GITHUB_APITOKEN] do # rubocop:disable RSpec/FilePath
|
||||
|
||||
let(:instance) { described_class.new(ENV['GITHUB_ENDPOINT'], ENV['GITHUB_APITOKEN']) }
|
||||
let(:issue_data) do
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
require 'rails_helper'
|
||||
RSpec.describe GitLab, type: :integration do # rubocop:disable RSpec/FilePath
|
||||
|
||||
before(:all) do # rubocop:disable RSpec/BeforeAfterAll
|
||||
required_envs = %w[GITLAB_ENDPOINT GITLAB_APITOKEN]
|
||||
required_envs.each do |key|
|
||||
skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
|
||||
end
|
||||
end
|
||||
RSpec.describe GitLab, type: :integration, required_envs: %w[GITLAB_ENDPOINT GITLAB_APITOKEN] do # rubocop:disable RSpec/FilePath
|
||||
|
||||
let(:instance) { described_class.new(ENV['GITLAB_ENDPOINT'], ENV['GITLAB_APITOKEN']) }
|
||||
let(:issue_data) do
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
require 'rails_helper'
|
||||
RSpec.describe 'Gmail XOAUTH2', type: :integration do # rubocop:disable RSpec/DescribeClass
|
||||
RSpec.describe 'Gmail XOAUTH2', type: :integration, required_envs: %w[GMAIL_REFRESH_TOKEN GMAIL_CLIENT_ID GMAIL_CLIENT_SECRET GMAIL_USER] do # rubocop:disable RSpec/DescribeClass
|
||||
let(:channel) do
|
||||
create(:google_channel).tap(&:refresh_xoauth2!)
|
||||
end
|
||||
|
||||
before do
|
||||
required_envs = %w[GMAIL_REFRESH_TOKEN GMAIL_CLIENT_ID GMAIL_CLIENT_SECRET GMAIL_USER]
|
||||
required_envs.each do |key|
|
||||
skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
|
||||
end
|
||||
end
|
||||
|
||||
context 'when probing inbound' do
|
||||
it 'succeeds' do
|
||||
result = EmailHelper::Probe.inbound(channel.options[:inbound])
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
require 'rails_helper'
|
||||
RSpec.describe 'Microsoft365 XOAUTH2', type: :integration do # rubocop:disable RSpec/DescribeClass
|
||||
RSpec.describe 'Microsoft365 XOAUTH2', type: :integration, required_envs: %w[MICROSOFT365_REFRESH_TOKEN MICROSOFT365_CLIENT_ID MICROSOFT365_CLIENT_SECRET MICROSOFT365_USER] do # rubocop:disable RSpec/DescribeClass
|
||||
let(:channel) do
|
||||
create(:microsoft365_channel).tap(&:refresh_xoauth2!)
|
||||
end
|
||||
|
||||
before do
|
||||
required_envs = %w[MICROSOFT365_REFRESH_TOKEN MICROSOFT365_CLIENT_ID MICROSOFT365_CLIENT_SECRET MICROSOFT365_USER]
|
||||
required_envs.each do |key|
|
||||
skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
|
||||
end
|
||||
end
|
||||
|
||||
context 'when probing inbound' do
|
||||
it 'succeeds' do
|
||||
result = EmailHelper::Probe.inbound(channel.options[:inbound])
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Facebook, use_vcr: true, current_user_id: 1 do
|
||||
RSpec.describe Facebook, use_vcr: true, current_user_id: 1, required_envs: %w[FACEBOOK_ADMIN_ACCESS_TOKEN] do
|
||||
|
||||
before do
|
||||
VCR.configure do |c|
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Channel::Driver::Facebook, use_vcr: true do
|
||||
RSpec.describe Channel::Driver::Facebook, use_vcr: true, required_envs: %w[FACEBOOK_ADMIN_ACCESS_TOKEN] do
|
||||
|
||||
before do
|
||||
VCR.configure do |c|
|
||||
|
|
|
@ -2,18 +2,11 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Channel::Driver::Imap do
|
||||
RSpec.describe Channel::Driver::Imap, required_envs: %w[IMAP_ASCII_8BIT_HOST IMAP_ASCII_8BIT_USER IMAP_ASCII_8BIT_PASSWORD] do
|
||||
# https://github.com/zammad/zammad/issues/2964
|
||||
context 'when connecting with a ASCII 8-Bit password' do
|
||||
it 'succeeds' do
|
||||
|
||||
required_envs = %w[IMAP_ASCII_8BIT_HOST IMAP_ASCII_8BIT_USER IMAP_ASCII_8BIT_PASSWORD]
|
||||
required_envs.each do |key|
|
||||
next if ENV[key].present?
|
||||
|
||||
skip("Need ENVs #{required_envs.join(', ')}.")
|
||||
end
|
||||
|
||||
params = {
|
||||
host: ENV['IMAP_ASCII_8BIT_HOST'],
|
||||
user: ENV['IMAP_ASCII_8BIT_USER'],
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
|||
|
||||
# rubocop:disable RSpec/StubbedMock,RSpec/MessageSpies
|
||||
|
||||
RSpec.describe 'GitHub', type: :request do
|
||||
RSpec.describe 'GitHub', type: :request, required_envs: %w[GITHUB_ENDPOINT GITHUB_APITOKEN] do
|
||||
|
||||
let(:token) { 't0k3N' }
|
||||
let(:endpoint) { 'https://api.github.com/graphql' }
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
|||
|
||||
# rubocop:disable RSpec/StubbedMock,RSpec/MessageSpies
|
||||
|
||||
RSpec.describe 'GitLab', type: :request do
|
||||
RSpec.describe 'GitLab', type: :request, required_envs: %w[GITLAB_ENDPOINT GITLAB_APITOKEN] do
|
||||
|
||||
let(:token) { 't0k3N' }
|
||||
let(:endpoint) { 'https://git.example.com/api/graphql' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Manage > Settings > System > Network', type: :request do
|
||||
RSpec.describe 'Manage > Settings > System > Network', type: :request, required_envs: %w[ZAMMAD_PROXY_USERNAME ZAMMAD_PROXY_PASSWORD] do
|
||||
|
||||
let(:group) { create(:group) }
|
||||
let!(:admin) do
|
||||
|
|
13
spec/support/required_envs.rb
Normal file
13
spec/support/required_envs.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
RSpec.configure do |config|
|
||||
|
||||
config.around(:each, :required_envs) do |example|
|
||||
example.metadata[:required_envs].each do |secret|
|
||||
if ENV[secret].blank?
|
||||
raise "This test requires the ENV variables [#{required_envs.join(', ')}], but #{secret} was not found."
|
||||
end
|
||||
end
|
||||
example.run
|
||||
end
|
||||
end
|
|
@ -2,14 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Import Freshdesk', type: :system, set_up: false, authenticated_as: false do
|
||||
before(:all) do # rubocop:disable RSpec/BeforeAfterAll
|
||||
required_envs = %w[IMPORT_FRESHDESK_ENDPOINT_SUBDOMAIN IMPORT_FRESHDESK_ENDPOINT_KEY]
|
||||
required_envs.each do |key|
|
||||
skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.describe 'Import Freshdesk', type: :system, set_up: false, authenticated_as: false, required_envs: %w[IMPORT_FRESHDESK_ENDPOINT_SUBDOMAIN IMPORT_FRESHDESK_ENDPOINT_KEY] do
|
||||
describe 'fields validation', :use_vcr do
|
||||
before do
|
||||
visit '#import'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'System setup process', type: :system, set_up: false, authenticated_as: false do
|
||||
RSpec.describe 'System setup process', type: :system, set_up: false, authenticated_as: false, required_envs: %w[MAILBOX_INIT] do
|
||||
|
||||
def fqdn
|
||||
match_data = %r{://(.+?)(:.+?|/.+?|)$}.match(app_host)
|
||||
|
@ -13,9 +13,6 @@ RSpec.describe 'System setup process', type: :system, set_up: false, authenticat
|
|||
|
||||
it 'Setting up a new system' do
|
||||
|
||||
if !ENV['MAILBOX_INIT']
|
||||
skip("NOTICE: Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'")
|
||||
end
|
||||
mailbox_user = ENV['MAILBOX_INIT'].split(':')[0]
|
||||
mailbox_password = ENV['MAILBOX_INIT'].split(':')[1]
|
||||
|
||||
|
|
|
@ -340,18 +340,11 @@ RSpec.describe 'Ticket Create', type: :system do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GitLab Integration', :integration, authenticated_as: :authenticate do
|
||||
describe 'GitLab Integration', :integration, authenticated_as: :authenticate, required_envs: %w[GITLAB_ENDPOINT GITLAB_APITOKEN] do
|
||||
let(:customer) { create(:customer) }
|
||||
let(:agent) { create(:agent, groups: [Group.find_by(name: 'Users')]) }
|
||||
let!(:template) { create(:template, :dummy_data, group: Group.find_by(name: 'Users'), owner: agent, customer: customer) }
|
||||
|
||||
before(:all) do # rubocop:disable RSpec/BeforeAfterAll
|
||||
required_envs = %w[GITLAB_ENDPOINT GITLAB_APITOKEN]
|
||||
required_envs.each do |key|
|
||||
skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
|
||||
end
|
||||
end
|
||||
|
||||
def authenticate
|
||||
Setting.set('gitlab_integration', true)
|
||||
Setting.set('gitlab_config', {
|
||||
|
@ -392,18 +385,11 @@ RSpec.describe 'Ticket Create', type: :system do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GitHub Integration', :integration, authenticated_as: :authenticate do
|
||||
describe 'GitHub Integration', :integration, authenticated_as: :authenticate, required_envs: %w[GITHUB_ENDPOINT GITHUB_APITOKEN] do
|
||||
let(:customer) { create(:customer) }
|
||||
let(:agent) { create(:agent, groups: [Group.find_by(name: 'Users')]) }
|
||||
let!(:template) { create(:template, :dummy_data, group: Group.find_by(name: 'Users'), owner: agent, customer: customer) }
|
||||
|
||||
before(:all) do # rubocop:disable RSpec/BeforeAfterAll
|
||||
required_envs = %w[GITHUB_ENDPOINT GITHUB_APITOKEN]
|
||||
required_envs.each do |key|
|
||||
skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
|
||||
end
|
||||
end
|
||||
|
||||
def authenticate
|
||||
Setting.set('github_integration', true)
|
||||
Setting.set('github_config', {
|
||||
|
|
|
@ -1535,16 +1535,9 @@ RSpec.describe 'Ticket zoom', type: :system do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GitLab Integration', :integration, authenticated_as: :authenticate do
|
||||
describe 'GitLab Integration', :integration, authenticated_as: :authenticate, required_envs: %w[GITLAB_ENDPOINT GITLAB_APITOKEN] do
|
||||
let!(:ticket) { create(:ticket, group: Group.find_by(name: 'Users')) }
|
||||
|
||||
before(:all) do # rubocop:disable RSpec/BeforeAfterAll
|
||||
required_envs = %w[GITLAB_ENDPOINT GITLAB_APITOKEN]
|
||||
required_envs.each do |key|
|
||||
skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
|
||||
end
|
||||
end
|
||||
|
||||
def authenticate
|
||||
Setting.set('gitlab_integration', true)
|
||||
Setting.set('gitlab_config', {
|
||||
|
@ -1593,16 +1586,9 @@ RSpec.describe 'Ticket zoom', type: :system do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GitHub Integration', :integration, authenticated_as: :authenticate do
|
||||
describe 'GitHub Integration', :integration, authenticated_as: :authenticate, required_envs: %w[GITHUB_ENDPOINT GITHUB_APITOKEN] do
|
||||
let!(:ticket) { create(:ticket, group: Group.find_by(name: 'Users')) }
|
||||
|
||||
before(:all) do # rubocop:disable RSpec/BeforeAfterAll
|
||||
required_envs = %w[GITHUB_ENDPOINT GITHUB_APITOKEN]
|
||||
required_envs.each do |key|
|
||||
skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
|
||||
end
|
||||
end
|
||||
|
||||
def authenticate
|
||||
Setting.set('github_integration', true)
|
||||
Setting.set('github_config', {
|
||||
|
|
Loading…
Reference in a new issue