diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-05 12:09:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-05 12:09:49 +0300 |
commit | 1e02d1c756e1b5e79453fcc805c9737bb6520fca (patch) | |
tree | d0a3b167272dfe32cbaa4c552082a4a3f831bfed /spec | |
parent | 130b909c4fab338c54e3292ed0c4f548e26e46b9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/concerns/sensitive_serializable_hash_spec.rb | 33 | ||||
-rw-r--r-- | spec/models/hooks/web_hook_spec.rb | 8 | ||||
-rw-r--r-- | spec/services/clusters/applications/install_service_spec.rb | 80 |
3 files changed, 0 insertions, 121 deletions
diff --git a/spec/models/concerns/sensitive_serializable_hash_spec.rb b/spec/models/concerns/sensitive_serializable_hash_spec.rb index 3c9199ce18f..591a4383a03 100644 --- a/spec/models/concerns/sensitive_serializable_hash_spec.rb +++ b/spec/models/concerns/sensitive_serializable_hash_spec.rb @@ -35,12 +35,6 @@ RSpec.describe SensitiveSerializableHash do expect(model.serializable_hash).not_to include('super_secret') end - context 'unsafe_serialization_hash option' do - it 'includes the field in serializable_hash' do - expect(model.serializable_hash(unsafe_serialization_hash: true)).to include('super_secret') - end - end - it 'does not change parent class attributes_exempt_from_serializable_hash' do expect(test_class.attributes_exempt_from_serializable_hash).to contain_exactly(:super_secret) expect(another_class.attributes_exempt_from_serializable_hash).to contain_exactly(:sub_secret) @@ -65,21 +59,6 @@ RSpec.describe SensitiveSerializableHash do expect(model.as_json).not_to include(attribute) end end - - context 'unsafe_serialization_hash option' do - it 'includes the field in serializable_hash' do - attributes.each do |attribute| - expect(model.attributes).to include(attribute) # double-check the attribute does exist - - # Do not expect binary columns to appear in JSON - next if klass.columns_hash[attribute]&.type == :binary - - expect(model.serializable_hash(unsafe_serialization_hash: true)).to include(attribute) - expect(model.to_json(unsafe_serialization_hash: true)).to include(attribute) - expect(model.as_json(unsafe_serialization_hash: true)).to include(attribute) - end - end - end end end @@ -120,18 +99,6 @@ RSpec.describe SensitiveSerializableHash do expect(model.as_json).not_to include(attribute) end end - - context 'unsafe_serialization_hash option' do - it 'includes the field in serializable_hash' do - attributes.each do |attribute| - expect(model.attributes).to include(attribute) # double-check the attribute does exist - - expect(model.serializable_hash(unsafe_serialization_hash: true)).to include(attribute) - expect(model.to_json(unsafe_serialization_hash: true)).to include(attribute) - expect(model.as_json(unsafe_serialization_hash: true)).to include(attribute) - end - end - end end end diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb index 988be46f8e6..2ffc9846e92 100644 --- a/spec/models/hooks/web_hook_spec.rb +++ b/spec/models/hooks/web_hook_spec.rb @@ -678,17 +678,9 @@ RSpec.describe WebHook do expect { hook.to_json }.not_to raise_error end - it 'does not error, when serializing unsafe attributes' do - expect { hook.to_json(unsafe_serialization_hash: true) }.not_to raise_error - end - it 'does not contain binary attributes' do expect(hook.to_json).not_to include('encrypted_url_variables') end - - it 'does not contain binary attributes, even when serializing unsafe attributes' do - expect(hook.to_json(unsafe_serialization_hash: true)).not_to include('encrypted_url_variables') - end end describe '#interpolated_url' do diff --git a/spec/services/clusters/applications/install_service_spec.rb b/spec/services/clusters/applications/install_service_spec.rb deleted file mode 100644 index d34b4dd943c..00000000000 --- a/spec/services/clusters/applications/install_service_spec.rb +++ /dev/null @@ -1,80 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Clusters::Applications::InstallService do - describe '#execute' 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) } - - before do - allow(service).to receive(:install_command).and_return(install_command) - allow(service).to receive(:helm_api).and_return(helm_client) - end - - context 'when there are no errors' do - before do - expect(helm_client).to receive(:install).with(install_command) - allow(ClusterWaitForAppInstallationWorker).to receive(:perform_in).and_return(nil) - end - - it 'make the application installing' do - expect(application.cluster).not_to be_nil - service.execute - - expect(application).to be_installing - end - - it 'schedule async installation status check' do - expect(ClusterWaitForAppInstallationWorker).to receive(:perform_in).once - - service.execute - end - end - - context 'when k8s cluster communication fails' do - let(:error) { Kubeclient::HttpError.new(500, 'system failure', nil) } - - before do - expect(helm_client).to receive(:install).with(install_command).and_raise(error) - end - - include_examples 'logs kubernetes errors' do - let(:error_name) { 'Kubeclient::HttpError' } - let(:error_message) { 'system failure' } - let(:error_code) { 500 } - end - - it 'make the application errored' do - service.execute - - expect(application).to be_errored - expect(application.status_reason).to match('Kubernetes error: 500') - end - end - - context 'a non kubernetes error happens' do - let(:application) { create(:clusters_applications_helm, :scheduled) } - let(:error) { StandardError.new('something bad happened') } - - before do - expect(helm_client).to receive(:install).with(install_command).and_raise(error) - end - - include_examples 'logs kubernetes errors' do - let(:error_name) { 'StandardError' } - let(:error_message) { 'something bad happened' } - let(:error_code) { nil } - end - - it 'make the application errored' do - service.execute - - expect(application).to be_errored - expect(application.status_reason).to eq('Failed to install.') - end - end - end -end |