summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-05 18:17:47 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-05 18:17:47 +0000
commitbc4cd6ffb93ae695f20ea54f4e4803d50c78a69e (patch)
tree2364d0f880af998b70356628f79cda64f13a11e7 /spec/models
parent6634288474d2a83cac7b4205f3ffc736cc6b36db (diff)
downloadgitlab-ce-bc4cd6ffb93ae695f20ea54f4e4803d50c78a69e.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/application_setting_spec.rb6
-rw-r--r--spec/models/integrations/prometheus_spec.rb48
-rw-r--r--spec/models/organization_spec.rb10
-rw-r--r--spec/models/project_spec.rb18
-rw-r--r--spec/models/user_spec.rb14
5 files changed, 24 insertions, 72 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 9f292b0a294..e0bfe41a3ae 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -27,12 +27,6 @@ RSpec.describe ApplicationSetting, feature_category: :shared, type: :model do
describe 'associations' do
it do
- is_expected.to belong_to(:self_monitoring_project).class_name('Project')
- .with_foreign_key(:instance_administration_project_id)
- .inverse_of(:application_setting)
- end
-
- it do
is_expected.to belong_to(:instance_group).class_name('Group')
.with_foreign_key(:instance_administrators_group_id)
.inverse_of(:application_setting)
diff --git a/spec/models/integrations/prometheus_spec.rb b/spec/models/integrations/prometheus_spec.rb
index aa248abd3bb..a533079f906 100644
--- a/spec/models/integrations/prometheus_spec.rb
+++ b/spec/models/integrations/prometheus_spec.rb
@@ -90,37 +90,6 @@ RSpec.describe Integrations::Prometheus, :use_clean_rails_memory_store_caching,
end
end
end
-
- context 'with self-monitoring project and internal Prometheus' do
- before do
- integration.api_url = 'http://localhost:9090'
-
- stub_application_setting(self_monitoring_project_id: project.id)
- stub_config(prometheus: { enable: true, server_address: 'localhost:9090' })
- end
-
- it 'allows self-monitoring project to connect to internal Prometheus' do
- aggregate_failures do
- ['127.0.0.1', '192.168.2.3'].each do |url|
- allow(Addrinfo).to receive(:getaddrinfo).with(domain, any_args).and_return([Addrinfo.tcp(url, 80)])
-
- expect(integration.can_query?).to be true
- end
- end
- end
-
- it 'does not allow self-monitoring project to connect to other local URLs' do
- integration.api_url = 'http://localhost:8000'
-
- aggregate_failures do
- ['127.0.0.1', '192.168.2.3'].each do |url|
- allow(Addrinfo).to receive(:getaddrinfo).with(domain, any_args).and_return([Addrinfo.tcp(url, 80)])
-
- expect(integration.can_query?).to be false
- end
- end
- end
- end
end
end
@@ -218,23 +187,6 @@ RSpec.describe Integrations::Prometheus, :use_clean_rails_memory_store_caching,
it 'blocks local requests' do
expect(integration.prometheus_client).to be_nil
end
-
- context 'with self-monitoring project and internal Prometheus URL' do
- before do
- stub_application_setting(allow_local_requests_from_web_hooks_and_services: false)
- stub_application_setting(self_monitoring_project_id: project.id)
-
- stub_config(prometheus: {
- enable: true,
- server_address: api_url
- })
- end
-
- it 'allows local requests' do
- expect(integration.prometheus_client).not_to be_nil
- expect { integration.prometheus_client.ping }.not_to raise_error
- end
- end
end
context 'behind IAP' do
diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb
new file mode 100644
index 00000000000..9966a7132ce
--- /dev/null
+++ b/spec/models/organization_spec.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+# rubocop: disable Lint/EmptyBlock
+# rubocop: disable RSpec/EmptyExampleGroup
+RSpec.describe Organization, type: :model, feature_category: :cell do
+end
+# rubocop: enable RSpec/EmptyExampleGroup
+# rubocop: enable Lint/EmptyBlock
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index f25ff0884b9..b5b7a283e39 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -7551,24 +7551,6 @@ RSpec.describe Project, factory_default: :keep, feature_category: :projects do
end
end
- describe '#self_monitoring?' do
- let_it_be(:project) { create(:project) }
-
- subject { project.self_monitoring? }
-
- context 'when the project is instance self-monitoring' do
- before do
- stub_application_setting(self_monitoring_project_id: project.id)
- end
-
- it { is_expected.to be true }
- end
-
- context 'when the project is not self-monitoring' do
- it { is_expected.to be false }
- end
- end
-
describe '#add_export_job' do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 60583bc351d..f1d3b17fd6f 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -2174,6 +2174,20 @@ RSpec.describe User, feature_category: :user_profile do
end
end
+ describe '#sign_in_with_codes_allowed?' do
+ let_it_be(:user) { create(:user, :two_factor_via_webauthn) }
+
+ context 'when `webauthn_without_totp` disabled' do
+ before do
+ stub_feature_flags(webauthn_without_totp: false)
+ end
+
+ it { expect(user.sign_in_with_codes_allowed?).to eq(false) }
+ end
+
+ it { expect(user.sign_in_with_codes_allowed?).to eq(true) }
+ end
+
describe '#two_factor_otp_enabled?' do
let_it_be(:user) { create(:user) }