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
|
# unit tests
|
||||||
bundle exec rubocop
|
bundle exec rubocop
|
||||||
bundle exec rake zammad:db:init
|
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 zammad:db:reset
|
||||||
bundle exec rake test:units
|
bundle exec rake test:units
|
||||||
ruby -I test/ test/integration/object_manager_test.rb
|
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.
|
# 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
|
before do
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
RSpec.describe GitHub, type: :integration do # rubocop:disable RSpec/FilePath
|
RSpec.describe GitHub, type: :integration, required_envs: %w[GITHUB_ENDPOINT GITHUB_APITOKEN] 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
|
|
||||||
|
|
||||||
let(:instance) { described_class.new(ENV['GITHUB_ENDPOINT'], ENV['GITHUB_APITOKEN']) }
|
let(:instance) { described_class.new(ENV['GITHUB_ENDPOINT'], ENV['GITHUB_APITOKEN']) }
|
||||||
let(:issue_data) do
|
let(:issue_data) do
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
RSpec.describe GitLab, type: :integration do # rubocop:disable RSpec/FilePath
|
RSpec.describe GitLab, type: :integration, required_envs: %w[GITLAB_ENDPOINT GITLAB_APITOKEN] 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
|
|
||||||
|
|
||||||
let(:instance) { described_class.new(ENV['GITLAB_ENDPOINT'], ENV['GITLAB_APITOKEN']) }
|
let(:instance) { described_class.new(ENV['GITLAB_ENDPOINT'], ENV['GITLAB_APITOKEN']) }
|
||||||
let(:issue_data) do
|
let(:issue_data) do
|
||||||
|
|
|
@ -1,18 +1,11 @@
|
||||||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'rails_helper'
|
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
|
let(:channel) do
|
||||||
create(:google_channel).tap(&:refresh_xoauth2!)
|
create(:google_channel).tap(&:refresh_xoauth2!)
|
||||||
end
|
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
|
context 'when probing inbound' do
|
||||||
it 'succeeds' do
|
it 'succeeds' do
|
||||||
result = EmailHelper::Probe.inbound(channel.options[:inbound])
|
result = EmailHelper::Probe.inbound(channel.options[:inbound])
|
||||||
|
|
|
@ -1,18 +1,11 @@
|
||||||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'rails_helper'
|
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
|
let(:channel) do
|
||||||
create(:microsoft365_channel).tap(&:refresh_xoauth2!)
|
create(:microsoft365_channel).tap(&:refresh_xoauth2!)
|
||||||
end
|
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
|
context 'when probing inbound' do
|
||||||
it 'succeeds' do
|
it 'succeeds' do
|
||||||
result = EmailHelper::Probe.inbound(channel.options[:inbound])
|
result = EmailHelper::Probe.inbound(channel.options[:inbound])
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
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
|
before do
|
||||||
VCR.configure do |c|
|
VCR.configure do |c|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
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
|
before do
|
||||||
VCR.configure do |c|
|
VCR.configure do |c|
|
||||||
|
|
|
@ -2,18 +2,11 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
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
|
# https://github.com/zammad/zammad/issues/2964
|
||||||
context 'when connecting with a ASCII 8-Bit password' do
|
context 'when connecting with a ASCII 8-Bit password' do
|
||||||
it 'succeeds' 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 = {
|
params = {
|
||||||
host: ENV['IMAP_ASCII_8BIT_HOST'],
|
host: ENV['IMAP_ASCII_8BIT_HOST'],
|
||||||
user: ENV['IMAP_ASCII_8BIT_USER'],
|
user: ENV['IMAP_ASCII_8BIT_USER'],
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
# rubocop:disable RSpec/StubbedMock,RSpec/MessageSpies
|
# 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(:token) { 't0k3N' }
|
||||||
let(:endpoint) { 'https://api.github.com/graphql' }
|
let(:endpoint) { 'https://api.github.com/graphql' }
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
# rubocop:disable RSpec/StubbedMock,RSpec/MessageSpies
|
# 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(:token) { 't0k3N' }
|
||||||
let(:endpoint) { 'https://git.example.com/api/graphql' }
|
let(:endpoint) { 'https://git.example.com/api/graphql' }
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
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(:group) { create(:group) }
|
||||||
let!(:admin) do
|
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'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Import Freshdesk', type: :system, set_up: false, authenticated_as: false do
|
RSpec.describe 'Import Freshdesk', type: :system, set_up: false, authenticated_as: false, required_envs: %w[IMPORT_FRESHDESK_ENDPOINT_SUBDOMAIN IMPORT_FRESHDESK_ENDPOINT_KEY] 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
|
|
||||||
|
|
||||||
describe 'fields validation', :use_vcr do
|
describe 'fields validation', :use_vcr do
|
||||||
before do
|
before do
|
||||||
visit '#import'
|
visit '#import'
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
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
|
def fqdn
|
||||||
match_data = %r{://(.+?)(:.+?|/.+?|)$}.match(app_host)
|
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
|
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_user = ENV['MAILBOX_INIT'].split(':')[0]
|
||||||
mailbox_password = ENV['MAILBOX_INIT'].split(':')[1]
|
mailbox_password = ENV['MAILBOX_INIT'].split(':')[1]
|
||||||
|
|
||||||
|
|
|
@ -340,18 +340,11 @@ RSpec.describe 'Ticket Create', type: :system do
|
||||||
end
|
end
|
||||||
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(:customer) { create(:customer) }
|
||||||
let(:agent) { create(:agent, groups: [Group.find_by(name: 'Users')]) }
|
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) }
|
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
|
def authenticate
|
||||||
Setting.set('gitlab_integration', true)
|
Setting.set('gitlab_integration', true)
|
||||||
Setting.set('gitlab_config', {
|
Setting.set('gitlab_config', {
|
||||||
|
@ -392,18 +385,11 @@ RSpec.describe 'Ticket Create', type: :system do
|
||||||
end
|
end
|
||||||
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(:customer) { create(:customer) }
|
||||||
let(:agent) { create(:agent, groups: [Group.find_by(name: 'Users')]) }
|
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) }
|
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
|
def authenticate
|
||||||
Setting.set('github_integration', true)
|
Setting.set('github_integration', true)
|
||||||
Setting.set('github_config', {
|
Setting.set('github_config', {
|
||||||
|
|
|
@ -1535,16 +1535,9 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
end
|
end
|
||||||
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')) }
|
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
|
def authenticate
|
||||||
Setting.set('gitlab_integration', true)
|
Setting.set('gitlab_integration', true)
|
||||||
Setting.set('gitlab_config', {
|
Setting.set('gitlab_config', {
|
||||||
|
@ -1593,16 +1586,9 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
end
|
end
|
||||||
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')) }
|
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
|
def authenticate
|
||||||
Setting.set('github_integration', true)
|
Setting.set('github_integration', true)
|
||||||
Setting.set('github_config', {
|
Setting.set('github_config', {
|
||||||
|
|
Loading…
Reference in a new issue