summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-09 18:07:59 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-09 18:07:59 +0000
commit7ebcead8cfd2edb810dd0cbda816b6cfbd170fe3 (patch)
tree11880c4059c89149cf997e9b958fb6d32c7dbdad /spec
parentf1a40d0db939dfe8ff95d385e652ff72566be765 (diff)
downloadgitlab-ce-7ebcead8cfd2edb810dd0cbda816b6cfbd170fe3.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js34
-rw-r--r--spec/frontend/diffs/components/tree_list_spec.js138
-rw-r--r--spec/javascripts/diffs/components/tree_list_spec.js126
-rw-r--r--spec/lib/gitlab/kubernetes/helm/api_spec.rb2
-rw-r--r--spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb33
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb32
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing_spec.rb34
-rw-r--r--spec/lib/gitlab/url_blocker_spec.rb66
-rw-r--r--spec/lib/gitlab/url_blockers/url_whitelist_spec.rb46
-rw-r--r--spec/services/clusters/applications/check_installation_progress_service_spec.rb2
-rw-r--r--spec/services/clusters/applications/check_uninstall_progress_service_spec.rb2
-rw-r--r--spec/services/clusters/applications/install_service_spec.rb2
-rw-r--r--spec/services/clusters/applications/patch_service_spec.rb2
-rw-r--r--spec/services/clusters/applications/uninstall_service_spec.rb2
-rw-r--r--spec/services/clusters/applications/upgrade_service_spec.rb2
15 files changed, 329 insertions, 194 deletions
diff --git a/spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js b/spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js
index 0170ef927cf..2c7891e4b1a 100644
--- a/spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js
+++ b/spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js
@@ -1,18 +1,25 @@
import { shallowMount } from '@vue/test-utils';
import Popover from '~/blob/suggest_gitlab_ci_yml/components/popover.vue';
import Cookies from 'js-cookie';
+import * as utils from '~/lib/utils/common_utils';
-const popoverTarget = 'gitlab-ci-yml-selector';
+jest.mock('~/lib/utils/common_utils', () => ({
+ ...jest.requireActual('~/lib/utils/common_utils'),
+ scrollToElement: jest.fn(),
+}));
+
+const target = 'gitlab-ci-yml-selector';
const dismissKey = 'suggest_gitlab_ci_yml_99';
+const defaultTrackLabel = 'suggest_gitlab_ci_yml';
describe('Suggest gitlab-ci.yml Popover', () => {
let wrapper;
- function createWrapper() {
+ function createWrapper(trackLabel) {
wrapper = shallowMount(Popover, {
propsData: {
- target: popoverTarget,
- cssClass: 'js-class',
+ target,
+ trackLabel,
dismissKey,
},
});
@@ -25,7 +32,7 @@ describe('Suggest gitlab-ci.yml Popover', () => {
describe('when no dismiss cookie is set', () => {
beforeEach(() => {
- createWrapper();
+ createWrapper(defaultTrackLabel);
});
it('sets popoverDismissed to false', () => {
@@ -36,11 +43,26 @@ describe('Suggest gitlab-ci.yml Popover', () => {
describe('when the dismiss cookie is set', () => {
beforeEach(() => {
Cookies.set(dismissKey, true);
- createWrapper();
+ createWrapper(defaultTrackLabel);
});
it('sets popoverDismissed to true', () => {
expect(wrapper.vm.popoverDismissed).toEqual(true);
});
+
+ beforeEach(() => {
+ Cookies.remove(dismissKey);
+ });
+ });
+
+ describe('when the popover is mounted with the trackLabel of the Confirm button popover at the bottom of the page', () => {
+ it('calls scrollToElement so that the Confirm button and popover will be in sight', () => {
+ const scrollToElementSpy = jest.spyOn(utils, 'scrollToElement');
+ const commitTrackLabel = 'suggest_commit_first_project_gitlab_ci_yml';
+
+ createWrapper(commitTrackLabel);
+
+ expect(scrollToElementSpy).toHaveBeenCalled();
+ });
});
});
diff --git a/spec/frontend/diffs/components/tree_list_spec.js b/spec/frontend/diffs/components/tree_list_spec.js
new file mode 100644
index 00000000000..f78c5f25ee7
--- /dev/null
+++ b/spec/frontend/diffs/components/tree_list_spec.js
@@ -0,0 +1,138 @@
+import Vuex from 'vuex';
+import { mount, createLocalVue } from '@vue/test-utils';
+import TreeList from '~/diffs/components/tree_list.vue';
+import createStore from '~/diffs/store/modules';
+
+describe('Diffs tree list component', () => {
+ let wrapper;
+ const getFileRows = () => wrapper.findAll('.file-row');
+ const localVue = createLocalVue();
+ localVue.use(Vuex);
+
+ const createComponent = state => {
+ const store = new Vuex.Store({
+ modules: {
+ diffs: createStore(),
+ },
+ });
+
+ // Setup initial state
+ store.state.diffs.diffFiles.push('test');
+ store.state.diffs = {
+ addedLines: 10,
+ removedLines: 20,
+ ...store.state.diffs,
+ ...state,
+ };
+
+ wrapper = mount(TreeList, {
+ store,
+ localVue,
+ propsData: { hideFileStats: false },
+ });
+ };
+
+ beforeEach(() => {
+ localStorage.removeItem('mr_diff_tree_list');
+
+ createComponent();
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('renders empty text', () => {
+ expect(wrapper.text()).toContain('No files found');
+ });
+
+ describe('with files', () => {
+ beforeEach(() => {
+ const treeEntries = {
+ 'index.js': {
+ addedLines: 0,
+ changed: true,
+ deleted: false,
+ fileHash: 'test',
+ key: 'index.js',
+ name: 'index.js',
+ path: 'app/index.js',
+ removedLines: 0,
+ tempFile: true,
+ type: 'blob',
+ parentPath: 'app',
+ },
+ app: {
+ key: 'app',
+ path: 'app',
+ name: 'app',
+ type: 'tree',
+ tree: [],
+ },
+ };
+
+ createComponent({
+ treeEntries,
+ tree: [treeEntries['index.js'], treeEntries.app],
+ });
+
+ return wrapper.vm.$nextTick();
+ });
+
+ it('renders tree', () => {
+ expect(getFileRows()).toHaveLength(2);
+ expect(
+ getFileRows()
+ .at(0)
+ .text(),
+ ).toContain('index.js');
+ expect(
+ getFileRows()
+ .at(1)
+ .text(),
+ ).toContain('app');
+ });
+
+ it('hides file stats', () => {
+ wrapper.setProps({ hideFileStats: true });
+
+ return wrapper.vm.$nextTick().then(() => {
+ expect(wrapper.find('.file-row-stats').exists()).toBe(false);
+ });
+ });
+
+ it('calls toggleTreeOpen when clicking folder', () => {
+ jest.spyOn(wrapper.vm.$store, 'dispatch').mockReturnValue(undefined);
+
+ getFileRows()
+ .at(1)
+ .trigger('click');
+
+ expect(wrapper.vm.$store.dispatch).toHaveBeenCalledWith('diffs/toggleTreeOpen', 'app');
+ });
+
+ it('calls scrollToFile when clicking blob', () => {
+ jest.spyOn(wrapper.vm.$store, 'dispatch').mockReturnValue(undefined);
+
+ wrapper.find('.file-row').trigger('click');
+
+ expect(wrapper.vm.$store.dispatch).toHaveBeenCalledWith('diffs/scrollToFile', 'app/index.js');
+ });
+
+ it('renders as file list when renderTreeList is false', () => {
+ wrapper.vm.$store.state.diffs.renderTreeList = false;
+
+ return wrapper.vm.$nextTick().then(() => {
+ expect(getFileRows()).toHaveLength(1);
+ });
+ });
+
+ it('renders file paths when renderTreeList is false', () => {
+ wrapper.vm.$store.state.diffs.renderTreeList = false;
+
+ return wrapper.vm.$nextTick().then(() => {
+ expect(wrapper.find('.file-row').text()).toContain('index.js');
+ });
+ });
+ });
+});
diff --git a/spec/javascripts/diffs/components/tree_list_spec.js b/spec/javascripts/diffs/components/tree_list_spec.js
deleted file mode 100644
index 0a6e433551c..00000000000
--- a/spec/javascripts/diffs/components/tree_list_spec.js
+++ /dev/null
@@ -1,126 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
-import TreeList from '~/diffs/components/tree_list.vue';
-import createStore from '~/diffs/store/modules';
-
-describe('Diffs tree list component', () => {
- let Component;
- let vm;
-
- beforeAll(() => {
- Component = Vue.extend(TreeList);
- });
-
- beforeEach(() => {
- Vue.use(Vuex);
-
- const store = new Vuex.Store({
- modules: {
- diffs: createStore(),
- },
- });
-
- // Setup initial state
- store.state.diffs.addedLines = 10;
- store.state.diffs.removedLines = 20;
- store.state.diffs.diffFiles.push('test');
-
- localStorage.removeItem('mr_diff_tree_list');
-
- vm = mountComponentWithStore(Component, { store, props: { hideFileStats: false } });
- });
-
- afterEach(() => {
- vm.$destroy();
- });
-
- it('renders empty text', () => {
- expect(vm.$el.textContent).toContain('No files found');
- });
-
- describe('with files', () => {
- beforeEach(done => {
- Object.assign(vm.$store.state.diffs.treeEntries, {
- 'index.js': {
- addedLines: 0,
- changed: true,
- deleted: false,
- fileHash: 'test',
- key: 'index.js',
- name: 'index.js',
- path: 'app/index.js',
- removedLines: 0,
- tempFile: true,
- type: 'blob',
- parentPath: 'app',
- },
- app: {
- key: 'app',
- path: 'app',
- name: 'app',
- type: 'tree',
- tree: [],
- },
- });
- vm.$store.state.diffs.tree = [
- vm.$store.state.diffs.treeEntries['index.js'],
- vm.$store.state.diffs.treeEntries.app,
- ];
-
- vm.$nextTick(done);
- });
-
- it('renders tree', () => {
- expect(vm.$el.querySelectorAll('.file-row').length).toBe(2);
- expect(vm.$el.querySelectorAll('.file-row')[0].textContent).toContain('index.js');
- expect(vm.$el.querySelectorAll('.file-row')[1].textContent).toContain('app');
- });
-
- it('hides file stats', done => {
- vm.hideFileStats = true;
-
- vm.$nextTick(() => {
- expect(vm.$el.querySelector('.file-row-stats')).toBe(null);
-
- done();
- });
- });
-
- it('calls toggleTreeOpen when clicking folder', () => {
- spyOn(vm.$store, 'dispatch').and.stub();
-
- vm.$el.querySelectorAll('.file-row')[1].click();
-
- expect(vm.$store.dispatch).toHaveBeenCalledWith('diffs/toggleTreeOpen', 'app');
- });
-
- it('calls scrollToFile when clicking blob', () => {
- spyOn(vm.$store, 'dispatch').and.stub();
-
- vm.$el.querySelector('.file-row').click();
-
- expect(vm.$store.dispatch).toHaveBeenCalledWith('diffs/scrollToFile', 'app/index.js');
- });
-
- it('renders as file list when renderTreeList is false', done => {
- vm.$store.state.diffs.renderTreeList = false;
-
- vm.$nextTick(() => {
- expect(vm.$el.querySelectorAll('.file-row').length).toBe(1);
-
- done();
- });
- });
-
- it('renders file paths when renderTreeList is false', done => {
- vm.$store.state.diffs.renderTreeList = false;
-
- vm.$nextTick(() => {
- expect(vm.$el.querySelector('.file-row').textContent).toContain('index.js');
-
- done();
- });
- });
- });
-});
diff --git a/spec/lib/gitlab/kubernetes/helm/api_spec.rb b/spec/lib/gitlab/kubernetes/helm/api_spec.rb
index e493acd7bad..8147990ecc3 100644
--- a/spec/lib/gitlab/kubernetes/helm/api_spec.rb
+++ b/spec/lib/gitlab/kubernetes/helm/api_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::Kubernetes::Helm::Api do
+describe Gitlab::Kubernetes::Helm::API do
let(:client) { double('kubernetes client') }
let(:helm) { described_class.new(client) }
let(:gitlab_namespace) { Gitlab::Kubernetes::Helm::NAMESPACE }
diff --git a/spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb
new file mode 100644
index 00000000000..3cc5c0bed1b
--- /dev/null
+++ b/spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::SidekiqLogging::DeduplicationLogger do
+ describe '#log_deduplication' do
+ let(:job) do
+ {
+ 'class' => 'TestWorker',
+ 'args' => [1234, 'hello', { 'key' => 'value' }],
+ 'jid' => 'da883554ee4fe414012f5f42',
+ 'correlation_id' => 'cid',
+ 'duplicate-of' => 'other_jid'
+ }
+ end
+
+ it 'logs a deduplication message to the sidekiq logger' do
+ expected_payload = {
+ 'job_status' => 'deduplicated',
+ 'message' => "#{job['class']} JID-#{job['jid']}: deduplicated: a fancy strategy",
+ 'deduplication_type' => 'a fancy strategy'
+ }
+ expect(Sidekiq.logger).to receive(:info).with(a_hash_including(expected_payload)).and_call_original
+
+ described_class.instance.log(job, "a fancy strategy")
+ end
+
+ it "does not modify the job" do
+ expect { described_class.instance.log(job, "a fancy strategy") }
+ .not_to change { job }
+ end
+ end
+end
diff --git a/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb
index 2334439461e..058e0737a25 100644
--- a/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gitlab_redis_queues do
+ using RSpec::Parameterized::TableSyntax
+
subject(:duplicate_job) do
described_class.new(job, queue)
end
@@ -110,6 +112,36 @@ describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gitlab_r
end
end
+ describe 'droppable?' do
+ where(:idempotent, :duplicate, :feature_enabled) do
+ # [true, false].repeated_permutation(3)
+ [[true, true, true],
+ [true, true, false],
+ [true, false, true],
+ [true, false, false],
+ [false, true, true],
+ [false, true, false],
+ [false, false, true],
+ [false, false, false]]
+ end
+
+ with_them do
+ before do
+ allow(AuthorizedProjectsWorker).to receive(:idempotent?).and_return(idempotent)
+ allow(duplicate_job).to receive(:duplicate?).and_return(duplicate)
+ stub_feature_flags(drop_duplicate_sidekiq_jobs: feature_enabled)
+ end
+
+ it 'is droppable when all conditions are met' do
+ if idempotent && duplicate && feature_enabled
+ expect(duplicate_job).to be_droppable
+ else
+ expect(duplicate_job).not_to be_droppable
+ end
+ end
+ end
+ end
+
def set_idempotency_key(key, value = '1')
Sidekiq.redis { |r| r.set(key, value) }
end
diff --git a/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing_spec.rb b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing_spec.rb
index f40e829f9a5..31b51260ebd 100644
--- a/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing_spec.rb
@@ -10,14 +10,21 @@ describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecuting do
subject(:strategy) { described_class.new(fake_duplicate_job) }
describe '#schedule' do
+ before do
+ allow(Gitlab::SidekiqLogging::DeduplicationLogger.instance).to receive(:log)
+ end
+
it 'checks for duplicates before yielding' do
expect(fake_duplicate_job).to receive(:check!).ordered.and_return('a jid')
expect(fake_duplicate_job).to receive(:duplicate?).ordered.and_return(false)
+ expect(fake_duplicate_job).to receive(:droppable?).ordered.and_return(false)
+
expect { |b| strategy.schedule({}, &b) }.to yield_control
end
it 'adds the jid of the existing job to the job hash' do
allow(fake_duplicate_job).to receive(:check!).and_return('the jid')
+ allow(fake_duplicate_job).to receive(:droppable?).and_return(true)
job_hash = {}
expect(fake_duplicate_job).to receive(:duplicate?).and_return(true)
@@ -27,6 +34,33 @@ describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecuting do
expect(job_hash).to include('duplicate-of' => 'the jid')
end
+
+ context "when the job is droppable" do
+ before do
+ allow(fake_duplicate_job).to receive(:check!).and_return('the jid')
+ allow(fake_duplicate_job).to receive(:duplicate?).and_return(true)
+ allow(fake_duplicate_job).to receive(:existing_jid).and_return('the jid')
+ allow(fake_duplicate_job).to receive(:droppable?).and_return(true)
+ end
+
+ it 'drops the job' do
+ schedule_result = nil
+
+ expect(fake_duplicate_job).to receive(:droppable?).and_return(true)
+
+ expect { |b| schedule_result = strategy.schedule({}, &b) }.not_to yield_control
+ expect(schedule_result).to be(false)
+ end
+
+ it 'logs that the job wass dropped' do
+ fake_logger = instance_double(Gitlab::SidekiqLogging::DeduplicationLogger)
+
+ expect(Gitlab::SidekiqLogging::DeduplicationLogger).to receive(:instance).and_return(fake_logger)
+ expect(fake_logger).to receive(:log).with(a_hash_including({ 'jid' => 'new jid' }), 'dropped until executing')
+
+ strategy.schedule({ 'jid' => 'new jid' }) {}
+ end
+ end
end
describe '#perform' do
diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb
index 97859c82e9e..f8bfcc6c99a 100644
--- a/spec/lib/gitlab/url_blocker_spec.rb
+++ b/spec/lib/gitlab/url_blocker_spec.rb
@@ -501,64 +501,20 @@ describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
it_behaves_like 'dns rebinding checks'
end
end
-
- context 'with ip ranges in whitelist' do
- let(:ipv4_range) { '127.0.0.0/28' }
- let(:ipv6_range) { 'fd84:6d02:f6d8:c89e::/124' }
-
- let(:whitelist) do
- [
- ipv4_range,
- ipv6_range
- ]
- end
-
- it 'blocks ipv4 range when not in whitelist' do
- stub_application_setting(outbound_local_requests_whitelist: [])
-
- IPAddr.new(ipv4_range).to_range.to_a.each do |ip|
- expect(described_class).to be_blocked_url("http://#{ip}",
- url_blocker_attributes)
- end
- end
-
- it 'allows all ipv4s in the range when in whitelist' do
- IPAddr.new(ipv4_range).to_range.to_a.each do |ip|
- expect(described_class).not_to be_blocked_url("http://#{ip}",
- url_blocker_attributes)
- end
- end
-
- it 'blocks ipv6 range when not in whitelist' do
- stub_application_setting(outbound_local_requests_whitelist: [])
-
- IPAddr.new(ipv6_range).to_range.to_a.each do |ip|
- expect(described_class).to be_blocked_url("http://[#{ip}]",
- url_blocker_attributes)
- end
- end
-
- it 'allows all ipv6s in the range when in whitelist' do
- IPAddr.new(ipv6_range).to_range.to_a.each do |ip|
- expect(described_class).not_to be_blocked_url("http://[#{ip}]",
- url_blocker_attributes)
- end
- end
-
- it 'blocks IPs outside the range' do
- expect(described_class).to be_blocked_url("http://[fd84:6d02:f6d8:c89e:0:0:1:f]",
- url_blocker_attributes)
-
- expect(described_class).to be_blocked_url("http://127.0.1.15",
- url_blocker_attributes)
- end
- end
end
end
- def stub_domain_resolv(domain, ip, &block)
- address = double(ip_address: ip, ipv4_private?: true, ipv6_link_local?: false, ipv4_loopback?: false, ipv6_loopback?: false, ipv4?: false)
- allow(Addrinfo).to receive(:getaddrinfo).with(domain, any_args).and_return([address])
+ def stub_domain_resolv(domain, ip, port = 80, &block)
+ address = instance_double(Addrinfo,
+ ip_address: ip,
+ ipv4_private?: true,
+ ipv6_linklocal?: false,
+ ipv4_loopback?: false,
+ ipv6_loopback?: false,
+ ipv4?: false,
+ ip_port: port
+ )
+ allow(Addrinfo).to receive(:getaddrinfo).with(domain, port, any_args).and_return([address])
allow(address).to receive(:ipv6_v4mapped?).and_return(false)
yield
diff --git a/spec/lib/gitlab/url_blockers/url_whitelist_spec.rb b/spec/lib/gitlab/url_blockers/url_whitelist_spec.rb
index 906e0f0ba3d..64d804e8541 100644
--- a/spec/lib/gitlab/url_blockers/url_whitelist_spec.rb
+++ b/spec/lib/gitlab/url_blockers/url_whitelist_spec.rb
@@ -68,5 +68,51 @@ describe Gitlab::UrlBlockers::UrlWhitelist do
it 'returns false when ip is blank' do
expect(described_class).not_to be_ip_whitelisted(nil)
end
+
+ context 'with ip ranges in whitelist' do
+ let(:ipv4_range) { '127.0.0.0/28' }
+ let(:ipv6_range) { 'fd84:6d02:f6d8:c89e::/124' }
+
+ let(:whitelist) do
+ [
+ ipv4_range,
+ ipv6_range
+ ]
+ end
+
+ it 'does not whitelist ipv4 range when not in whitelist' do
+ stub_application_setting(outbound_local_requests_whitelist: [])
+
+ IPAddr.new(ipv4_range).to_range.to_a.each do |ip|
+ expect(described_class).not_to be_ip_whitelisted(ip.to_s)
+ end
+ end
+
+ it 'whitelists all ipv4s in the range when in whitelist' do
+ IPAddr.new(ipv4_range).to_range.to_a.each do |ip|
+ expect(described_class).to be_ip_whitelisted(ip.to_s)
+ end
+ end
+
+ it 'does not whitelist ipv6 range when not in whitelist' do
+ stub_application_setting(outbound_local_requests_whitelist: [])
+
+ IPAddr.new(ipv6_range).to_range.to_a.each do |ip|
+ expect(described_class).not_to be_ip_whitelisted(ip.to_s)
+ end
+ end
+
+ it 'whitelists all ipv6s in the range when in whitelist' do
+ IPAddr.new(ipv6_range).to_range.to_a.each do |ip|
+ expect(described_class).to be_ip_whitelisted(ip.to_s)
+ end
+ end
+
+ it 'does not whitelist IPs outside the range' do
+ expect(described_class).not_to be_ip_whitelisted("fd84:6d02:f6d8:c89e:0:0:1:f")
+
+ expect(described_class).not_to be_ip_whitelisted("127.0.1.15")
+ end
+ end
end
end
diff --git a/spec/services/clusters/applications/check_installation_progress_service_spec.rb b/spec/services/clusters/applications/check_installation_progress_service_spec.rb
index 2f224d40920..4b8db405101 100644
--- a/spec/services/clusters/applications/check_installation_progress_service_spec.rb
+++ b/spec/services/clusters/applications/check_installation_progress_service_spec.rb
@@ -144,7 +144,7 @@ describe Clusters::Applications::CheckInstallationProgressService, '#execute' do
end
it 'removes the installation POD' do
- expect_next_instance_of(Gitlab::Kubernetes::Helm::Api) do |instance|
+ expect_next_instance_of(Gitlab::Kubernetes::Helm::API) do |instance|
expect(instance).to receive(:delete_pod!).with(kind_of(String)).once
end
expect(service).to receive(:remove_installation_pod).and_call_original
diff --git a/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb b/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb
index 93557c6b229..ffb658330d3 100644
--- a/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb
+++ b/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb
@@ -48,7 +48,7 @@ describe Clusters::Applications::CheckUninstallProgressService do
let(:phase) { Gitlab::Kubernetes::Pod::SUCCEEDED }
before do
- expect_next_instance_of(Gitlab::Kubernetes::Helm::Api) do |instance|
+ expect_next_instance_of(Gitlab::Kubernetes::Helm::API) do |instance|
expect(instance).to receive(:delete_pod!).with(kind_of(String)).once
end
expect(service).to receive(:pod_phase).once.and_return(phase)
diff --git a/spec/services/clusters/applications/install_service_spec.rb b/spec/services/clusters/applications/install_service_spec.rb
index 9e1ae5e8742..2441cc595a3 100644
--- a/spec/services/clusters/applications/install_service_spec.rb
+++ b/spec/services/clusters/applications/install_service_spec.rb
@@ -7,7 +7,7 @@ describe Clusters::Applications::InstallService do
let(:application) { create(:clusters_applications_helm, :scheduled) }
let!(:install_command) { application.install_command }
let(:service) { described_class.new(application) }
- let(:helm_client) { instance_double(Gitlab::Kubernetes::Helm::Api) }
+ let(:helm_client) { instance_double(Gitlab::Kubernetes::Helm::API) }
before do
allow(service).to receive(:install_command).and_return(install_command)
diff --git a/spec/services/clusters/applications/patch_service_spec.rb b/spec/services/clusters/applications/patch_service_spec.rb
index c6d0fee43c4..dc9843a5116 100644
--- a/spec/services/clusters/applications/patch_service_spec.rb
+++ b/spec/services/clusters/applications/patch_service_spec.rb
@@ -7,7 +7,7 @@ describe Clusters::Applications::PatchService do
let(:application) { create(:clusters_applications_knative, :scheduled) }
let!(:update_command) { application.update_command }
let(:service) { described_class.new(application) }
- let(:helm_client) { instance_double(Gitlab::Kubernetes::Helm::Api) }
+ let(:helm_client) { instance_double(Gitlab::Kubernetes::Helm::API) }
before do
allow(service).to receive(:update_command).and_return(update_command)
diff --git a/spec/services/clusters/applications/uninstall_service_spec.rb b/spec/services/clusters/applications/uninstall_service_spec.rb
index 16497d752b2..6d7f0478b20 100644
--- a/spec/services/clusters/applications/uninstall_service_spec.rb
+++ b/spec/services/clusters/applications/uninstall_service_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
describe Clusters::Applications::UninstallService, '#execute' do
let(:application) { create(:clusters_applications_prometheus, :scheduled) }
let(:service) { described_class.new(application) }
- let(:helm_client) { instance_double(Gitlab::Kubernetes::Helm::Api) }
+ let(:helm_client) { instance_double(Gitlab::Kubernetes::Helm::API) }
let(:worker_class) { Clusters::Applications::WaitForUninstallAppWorker }
before do
diff --git a/spec/services/clusters/applications/upgrade_service_spec.rb b/spec/services/clusters/applications/upgrade_service_spec.rb
index 48fa79eeb97..86fb06375f1 100644
--- a/spec/services/clusters/applications/upgrade_service_spec.rb
+++ b/spec/services/clusters/applications/upgrade_service_spec.rb
@@ -7,7 +7,7 @@ describe Clusters::Applications::UpgradeService do
let(:application) { create(:clusters_applications_helm, :scheduled) }
let!(:install_command) { application.install_command }
let(:service) { described_class.new(application) }
- let(:helm_client) { instance_double(Gitlab::Kubernetes::Helm::Api) }
+ let(:helm_client) { instance_double(Gitlab::Kubernetes::Helm::API) }
before do
allow(service).to receive(:install_command).and_return(install_command)