diff --git a/doc/development/cloud_connector/index.md b/doc/development/cloud_connector/index.md index d5f073ed8d67559cf1ea49b5883d3606bdf59406..650250be4e55085d1fe6eca43cae5a642e6bbd9a 100644 --- a/doc/development/cloud_connector/index.md +++ b/doc/development/cloud_connector/index.md @@ -233,8 +233,8 @@ As an example, the feature is delivered as a stand-alone service called `new_fea - `X-Gitlab-Duo-Seat-Count`: The number of either duo pro or duo enterprise seats the customer purchased. When both add-ons are present, it will take the highest number of seats. - Some of these headers can be injected by merging the result of the `Gitlab::CloudConnector#headers` method to your payload. - For AI uses cases and requests targeting the AI gateway, use `Gitlab::CloudConnector#ai_headers` instead. + Some of these headers can be injected by merging the result of the `::CloudConnector#headers` method to your payload. + For AI uses cases and requests targeting the AI gateway, use `::CloudConnector#ai_headers` instead. ###### Permission checks diff --git a/ee/app/workers/observability/alert_query_worker.rb b/ee/app/workers/observability/alert_query_worker.rb index 74d1a210c492a15720db42df69df2117a1e66876..f6f93d1921e8de4edb7492a45d4a484b4021dd6e 100644 --- a/ee/app/workers/observability/alert_query_worker.rb +++ b/ee/app/workers/observability/alert_query_worker.rb @@ -43,7 +43,7 @@ def fetch_alerts result = Gitlab::HTTP.get( ::Gitlab::Observability.alerts_url, - headers: Gitlab::CloudConnector.headers(nil).merge({ + headers: ::CloudConnector.headers(nil).merge({ "Authorization" => "Bearer #{access_token}" }), verify: ::Gitlab::CurrentSettings.observability_backend_ssl_verification_enabled diff --git a/ee/lib/ai/duo_workflow/duo_workflow_service/client.rb b/ee/lib/ai/duo_workflow/duo_workflow_service/client.rb index aad03b8543d2c900442b0c563a80f523b202f1cc..463c654ef0c8c1dd32cebb27f3225f6590b076c3 100644 --- a/ee/lib/ai/duo_workflow/duo_workflow_service/client.rb +++ b/ee/lib/ai/duo_workflow/duo_workflow_service/client.rb @@ -42,7 +42,7 @@ def metadata "authorization" => "Bearer #{token}", "x-gitlab-authentication-type" => "oidc", 'x-gitlab-instance-id' => ::Gitlab::GlobalAnonymousId.instance_id, - 'x-gitlab-realm' => ::Gitlab::CloudConnector.gitlab_realm, + 'x-gitlab-realm' => ::CloudConnector.gitlab_realm, 'x-gitlab-global-user-id' => ::Gitlab::GlobalAnonymousId.user_id(current_user) } end diff --git a/ee/lib/api/internal/observability.rb b/ee/lib/api/internal/observability.rb index 099f4cc19ac125fb9b494fc5f71874f9e3bef009..717e0ecbd2bfdccbd95ebb0014afb7b738da210d 100644 --- a/ee/lib/api/internal/observability.rb +++ b/ee/lib/api/internal/observability.rb @@ -35,7 +35,7 @@ def respond_success { 'gob' => { 'backend' => observability_url, - 'headers' => Gitlab::CloudConnector.headers(current_user).merge({ + 'headers' => ::CloudConnector.headers(current_user).merge({ 'X-GitLab-Namespace-id' => project.root_ancestor.id.to_s, 'X-GitLab-Project-id' => project.id.to_s, 'Authorization' => "Bearer #{cc_access_token}", diff --git a/ee/lib/api/security_scans.rb b/ee/lib/api/security_scans.rb index bf8fee7dad16d8d163a521d797bffa6b13bf2fe0..bdc06e25f9d79ef5d4a662d338dcb611fd53b067 100644 --- a/ee/lib/api/security_scans.rb +++ b/ee/lib/api/security_scans.rb @@ -20,7 +20,7 @@ def construct_scan_url(endpoint) end def request_headers(token) - Gitlab::CloudConnector.headers(current_user).merge({ + ::CloudConnector.headers(current_user).merge({ 'Authorization' => "Bearer #{token}", 'Content-Type' => 'application/json', 'User-Agent' => headers['User-Agent'] diff --git a/ee/lib/cloud_connector.rb b/ee/lib/cloud_connector.rb new file mode 100644 index 0000000000000000000000000000000000000000..1adbec7f88c22e4fa839b28a4cc7930b76481e94 --- /dev/null +++ b/ee/lib/cloud_connector.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module CloudConnector + extend self + + GITLAB_REALM_SAAS = 'saas' + GITLAB_REALM_SELF_MANAGED = 'self-managed' + + def gitlab_realm + gitlab_realm_saas? ? GITLAB_REALM_SAAS : GITLAB_REALM_SELF_MANAGED + end + + def headers(user) + { + 'X-Gitlab-Host-Name' => Gitlab.config.gitlab.host, + 'X-Gitlab-Instance-Id' => Gitlab::GlobalAnonymousId.instance_id, + 'X-Gitlab-Realm' => ::CloudConnector.gitlab_realm, + 'X-Gitlab-Version' => Gitlab.version_info.to_s + }.tap do |result| + result['X-Gitlab-Global-User-Id'] = Gitlab::GlobalAnonymousId.user_id(user) if user + end + end + + ### + # Returns required HTTP header fields when making AI requests through Cloud Connector. + # + # user - User making the request, may be null. + # namespace_ids - Namespaces for which to return the maximum allowed Duo seat count. + # This should only be set when the request is made on gitlab.com. + def ai_headers(user, namespace_ids: []) + effective_seat_count = GitlabSubscriptions::AddOnPurchase.maximum_duo_seat_count( + namespace_ids: namespace_ids + ) + headers(user).merge( + 'X-Gitlab-Duo-Seat-Count' => effective_seat_count.to_s, + 'X-Gitlab-Feature-Enabled-By-Namespace-Ids' => namespace_ids.join(',') + ) + end + + def gitlab_realm_saas? + Gitlab.org_or_com? # rubocop:disable Gitlab/AvoidGitlabInstanceChecks -- Will be addressed in https://gitlab.com/gitlab-org/gitlab/-/issues/437725 + end + + def self_managed_cloud_connected? + !gitlab_realm_saas? && !::Gitlab::AiGateway.self_hosted_url.present? + end +end diff --git a/ee/lib/cloud_connector/self_signed/available_service_data.rb b/ee/lib/cloud_connector/self_signed/available_service_data.rb index a43776f8b336818151338c052698bed0f50f3b12..25b4e731ef9bd30b0338c1c11784a1629578a2d6 100644 --- a/ee/lib/cloud_connector/self_signed/available_service_data.rb +++ b/ee/lib/cloud_connector/self_signed/available_service_data.rb @@ -22,7 +22,7 @@ def access_token(resource = nil, extra_claims: {}) issuer: Doorkeeper::OpenidConnect.configuration.issuer, audience: backend, subject: Gitlab::CurrentSettings.uuid, - realm: Gitlab::CloudConnector.gitlab_realm, + realm: ::CloudConnector.gitlab_realm, scopes: scopes_for(resource), ttl: 1.hour, extra_claims: extra_claims diff --git a/ee/lib/ee/gitlab/tracking/standard_context.rb b/ee/lib/ee/gitlab/tracking/standard_context.rb index 8561f65ec4f00cfb80407ecac3ba415d42b8e09c..82173262ad0ed5e23b66aa7f04d2698c3a796dc4 100644 --- a/ee/lib/ee/gitlab/tracking/standard_context.rb +++ b/ee/lib/ee/gitlab/tracking/standard_context.rb @@ -16,7 +16,7 @@ def gitlab_team_member?(user_id) override :realm def realm - ::Gitlab::CloudConnector.gitlab_realm + ::CloudConnector.gitlab_realm end override :instance_id diff --git a/ee/lib/gitlab/ai_gateway.rb b/ee/lib/gitlab/ai_gateway.rb index ec4d41fc4046ff68848ed77477b8a0184b3055a6..dc42d0a0cc98fa93a3a54bf92b867597ff4c9a6d 100644 --- a/ee/lib/gitlab/ai_gateway.rb +++ b/ee/lib/gitlab/ai_gateway.rb @@ -58,7 +58,7 @@ def self.headers(user:, service:, agent: nil, lsp_version: nil) # Forward the request time to the model gateway to calculate latency 'X-Gitlab-Rails-Send-Start' => Time.now.to_f.to_s, 'x-gitlab-enabled-feature-flags' => enabled_feature_flags.uniq.join(',') - }.merge(Gitlab::CloudConnector.ai_headers(user, namespace_ids: allowed_by_namespace_ids)) + }.merge(::CloudConnector.ai_headers(user, namespace_ids: allowed_by_namespace_ids)) .tap do |result| result['User-Agent'] = agent if agent # Forward the User-Agent on to the model gateway @@ -77,7 +77,7 @@ def self.public_headers(user:, service:) { 'x-gitlab-enabled-feature-flags' => enabled_feature_flags.uniq.join(',') - }.merge(Gitlab::CloudConnector.ai_headers(user, namespace_ids: namespace_ids)) + }.merge(::CloudConnector.ai_headers(user, namespace_ids: namespace_ids)) end end end diff --git a/ee/lib/gitlab/cloud_connector.rb b/ee/lib/gitlab/cloud_connector.rb deleted file mode 100644 index 79bf389302cecd21123d86ca00fd7bb61a91de1a..0000000000000000000000000000000000000000 --- a/ee/lib/gitlab/cloud_connector.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module CloudConnector - extend self - - GITLAB_REALM_SAAS = 'saas' - GITLAB_REALM_SELF_MANAGED = 'self-managed' - - def gitlab_realm - gitlab_realm_saas? ? GITLAB_REALM_SAAS : GITLAB_REALM_SELF_MANAGED - end - - def headers(user) - { - 'X-Gitlab-Host-Name' => Gitlab.config.gitlab.host, - 'X-Gitlab-Instance-Id' => Gitlab::GlobalAnonymousId.instance_id, - 'X-Gitlab-Realm' => Gitlab::CloudConnector.gitlab_realm, - 'X-Gitlab-Version' => Gitlab.version_info.to_s - }.tap do |result| - result['X-Gitlab-Global-User-Id'] = Gitlab::GlobalAnonymousId.user_id(user) if user - end - end - - ### - # Returns required HTTP header fields when making AI requests through Cloud Connector. - # - # user - User making the request, may be null. - # namespace_ids - Namespaces for which to return the maximum allowed Duo seat count. - # This should only be set when the request is made on gitlab.com. - def ai_headers(user, namespace_ids: []) - effective_seat_count = GitlabSubscriptions::AddOnPurchase.maximum_duo_seat_count( - namespace_ids: namespace_ids - ) - headers(user).merge( - 'X-Gitlab-Duo-Seat-Count' => effective_seat_count.to_s, - 'X-Gitlab-Feature-Enabled-By-Namespace-Ids' => namespace_ids.join(',') - ) - end - - def gitlab_realm_saas? - Gitlab.org_or_com? # rubocop:disable Gitlab/AvoidGitlabInstanceChecks -- Will be addressed in https://gitlab.com/gitlab-org/gitlab/-/issues/437725 - end - - def self_managed_cloud_connected? - !gitlab_realm_saas? && !::Gitlab::AiGateway.self_hosted_url.present? - end - end -end diff --git a/ee/lib/gitlab/cloud_connector/self_issued_token.rb b/ee/lib/gitlab/cloud_connector/self_issued_token.rb index b8d648afa05a84baee367f659e3e8c90ff31a778..6f8cf69d700122822738525cff85251e57399096 100644 --- a/ee/lib/gitlab/cloud_connector/self_issued_token.rb +++ b/ee/lib/gitlab/cloud_connector/self_issued_token.rb @@ -44,7 +44,7 @@ def payload def custom_claims { - gitlab_realm: Gitlab::CloudConnector.gitlab_realm, + gitlab_realm: ::CloudConnector.gitlab_realm, scopes: @scopes }.merge(@extra_claims) end diff --git a/ee/lib/gitlab/duo_workflow/client.rb b/ee/lib/gitlab/duo_workflow/client.rb index d7df90b619bc926beccfd3a6894d681a7dc6f644..0d1111227eec37be22ea433788e333c27ce504bc 100644 --- a/ee/lib/gitlab/duo_workflow/client.rb +++ b/ee/lib/gitlab/duo_workflow/client.rb @@ -8,7 +8,7 @@ def self.url end def self.headers(user:) - Gitlab::CloudConnector.ai_headers(user) + ::CloudConnector.ai_headers(user) end def self.secure? diff --git a/ee/lib/gitlab/llm/completions/chat.rb b/ee/lib/gitlab/llm/completions/chat.rb index 46378c9493606150f992c61bbba9728b95b81c1e..93a9bfb1fb0dacefc27ab5e80e60549dc94d8153 100644 --- a/ee/lib/gitlab/llm/completions/chat.rb +++ b/ee/lib/gitlab/llm/completions/chat.rb @@ -159,7 +159,7 @@ def slash_command def push_feature_flags Gitlab::AiGateway.push_feature_flag(:ai_commit_reader_for_chat, user) - return if ::Gitlab::CloudConnector.self_managed_cloud_connected? + return if ::CloudConnector.self_managed_cloud_connected? Gitlab::AiGateway.push_feature_flag(:expanded_ai_logging, user) end diff --git a/ee/spec/lib/ai/duo_workflow/duo_workflow_service/client_spec.rb b/ee/spec/lib/ai/duo_workflow/duo_workflow_service/client_spec.rb index b1182119b9f98ed0340306bc452ad4eeb7a27471..ea51e0dbdecc6d75601fda9d61c9e4cc055c204b 100644 --- a/ee/spec/lib/ai/duo_workflow/duo_workflow_service/client_spec.rb +++ b/ee/spec/lib/ai/duo_workflow/duo_workflow_service/client_spec.rb @@ -40,7 +40,7 @@ "authorization" => "Bearer instance jwt", "x-gitlab-authentication-type" => "oidc", 'x-gitlab-instance-id' => ::Gitlab::GlobalAnonymousId.instance_id, - 'x-gitlab-realm' => ::Gitlab::CloudConnector.gitlab_realm, + 'x-gitlab-realm' => ::CloudConnector.gitlab_realm, 'x-gitlab-global-user-id' => ::Gitlab::GlobalAnonymousId.user_id(current_user) } ) diff --git a/ee/spec/lib/cloud_connector/self_signed/available_service_data_spec.rb b/ee/spec/lib/cloud_connector/self_signed/available_service_data_spec.rb index ac0e2c8821b5a1b58c9911a55edfa65593a0db9c..0472a54e981f3fb00b58c61797d35d6b6a87682d 100644 --- a/ee/spec/lib/cloud_connector/self_signed/available_service_data_spec.rb +++ b/ee/spec/lib/cloud_connector/self_signed/available_service_data_spec.rb @@ -32,7 +32,7 @@ before do allow(Doorkeeper::OpenidConnect.configuration).to receive(:issuer).and_return(issuer) allow(Gitlab::CurrentSettings).to receive(:uuid).and_return(instance_id) - allow(Gitlab::CloudConnector).to receive(:gitlab_realm).and_return(gitlab_realm) + allow(::CloudConnector).to receive(:gitlab_realm).and_return(gitlab_realm) end it 'returns the constructed token' do diff --git a/ee/spec/lib/gitlab/cloud_connector_spec.rb b/ee/spec/lib/cloud_connector_spec.rb similarity index 87% rename from ee/spec/lib/gitlab/cloud_connector_spec.rb rename to ee/spec/lib/cloud_connector_spec.rb index 2017505b48f0da7d852768c36e6c22a527127205..990d7bef9caa8bb38d5cb9f59f0a881f9dedc8d1 100644 --- a/ee/spec/lib/gitlab/cloud_connector_spec.rb +++ b/ee/spec/lib/cloud_connector_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Gitlab::CloudConnector, feature_category: :cloud_connector do +RSpec.describe ::CloudConnector, feature_category: :cloud_connector do describe '.gitlab_realm' do subject { described_class.gitlab_realm } @@ -20,7 +20,7 @@ { 'X-Gitlab-Host-Name' => Gitlab.config.gitlab.host, 'X-Gitlab-Instance-Id' => an_instance_of(String), - 'X-Gitlab-Realm' => Gitlab::CloudConnector::GITLAB_REALM_SELF_MANAGED, + 'X-Gitlab-Realm' => ::CloudConnector::GITLAB_REALM_SELF_MANAGED, 'X-Gitlab-Version' => Gitlab.version_info.to_s } end @@ -80,7 +80,7 @@ context 'when on saas' do it 'returns false' do - allow(::Gitlab::CloudConnector).to receive(:gitlab_realm_saas?).and_return(true) + allow(::Gitlab).to receive(:org_or_com?).and_return(true) allow(::Gitlab::AiGateway).to receive(:self_hosted_url).and_return('http::test.com') expect(self_managed_cloud_connected?).to be(false) @@ -89,7 +89,7 @@ context 'when self-hosted and cloud connected' do it 'returns true' do - allow(::Gitlab::CloudConnector).to receive(:gitlab_realm_saas?).and_return(false) + allow(::Gitlab).to receive(:org_or_com?).and_return(false) allow(::Gitlab::AiGateway).to receive(:self_hosted_url).and_return(nil) expect(self_managed_cloud_connected?).to be(true) @@ -98,7 +98,7 @@ context 'when self-hosted and not cloud connected' do it 'returns false' do - allow(::Gitlab::CloudConnector).to receive(:gitlab_realm_saas?).and_return(false) + allow(::Gitlab).to receive(:org_or_com?).and_return(false) allow(::Gitlab::AiGateway).to receive(:self_hosted_url).and_return('http::test.com') expect(self_managed_cloud_connected?).to be(false) diff --git a/ee/spec/lib/gitlab/ai_gateway_spec.rb b/ee/spec/lib/gitlab/ai_gateway_spec.rb index aa0baae6197a48a6dbeba7752c5f3b17020f9bea..2eacede70727080c91e5d14e4c07cf64e27b4ecf 100644 --- a/ee/spec/lib/gitlab/ai_gateway_spec.rb +++ b/ee/spec/lib/gitlab/ai_gateway_spec.rb @@ -126,7 +126,7 @@ before do allow(service).to receive(:access_token).with(user).and_return(token) allow(user).to receive(:allowed_by_namespace_ids).with(service_name).and_return(enabled_by_namespace_ids) - allow(Gitlab::CloudConnector).to( + allow(::CloudConnector).to( receive(:ai_headers).with(user, namespace_ids: enabled_by_namespace_ids).and_return(cloud_connector_headers) ) end @@ -191,7 +191,7 @@ allow(described_class).to receive(:enabled_feature_flags) .and_return(enabled_feature_flags) - allow(Gitlab::CloudConnector).to receive(:ai_headers) + allow(::CloudConnector).to receive(:ai_headers) .with(user, namespace_ids: namespace_ids) .and_return(ai_headers) end diff --git a/ee/spec/lib/gitlab/duo_workflow/client_spec.rb b/ee/spec/lib/gitlab/duo_workflow/client_spec.rb index 750caf09e25f99b7c0862171d61d70493da133b7..c86430fbd4d0133c5ce0910b25f3e2c68e7a6d49 100644 --- a/ee/spec/lib/gitlab/duo_workflow/client_spec.rb +++ b/ee/spec/lib/gitlab/duo_workflow/client_spec.rb @@ -18,7 +18,7 @@ describe '.headers' do it 'returns cloud connector headers' do - expect(Gitlab::CloudConnector).to receive(:ai_headers).with(user).and_return({ header_key: 'header_value' }) + expect(::CloudConnector).to receive(:ai_headers).with(user).and_return({ header_key: 'header_value' }) expect(described_class.headers(user: user)).to eq({ header_key: 'header_value' }) end diff --git a/ee/spec/lib/gitlab/llm/ai_gateway/client_spec.rb b/ee/spec/lib/gitlab/llm/ai_gateway/client_spec.rb index bd58e3eded978fad193c9b94b53bad4e842a9d55..8d4cebf7a10b627b8cba63b38e4610b6b2857d2d 100644 --- a/ee/spec/lib/gitlab/llm/ai_gateway/client_spec.rb +++ b/ee/spec/lib/gitlab/llm/ai_gateway/client_spec.rb @@ -13,7 +13,7 @@ let(:service) { instance_double(CloudConnector::BaseAvailableServiceData, name: :test) } let(:enabled_by_namespace_ids) { [1, 2] } let(:expected_access_token) { active_token.token } - let(:expected_gitlab_realm) { Gitlab::CloudConnector::GITLAB_REALM_SELF_MANAGED } + let(:expected_gitlab_realm) { ::CloudConnector::GITLAB_REALM_SELF_MANAGED } let(:expected_gitlab_host_name) { Gitlab.config.gitlab.host } let(:expected_instance_id) { Gitlab::GlobalAnonymousId.instance_id } let(:expected_user_id) { Gitlab::GlobalAnonymousId.user_id(user) } diff --git a/ee/spec/lib/gitlab/llm/ai_gateway/code_suggestions_client_spec.rb b/ee/spec/lib/gitlab/llm/ai_gateway/code_suggestions_client_spec.rb index b93aec171e32b333afee97fa293faabd5dbb0a35..fef60fc107c8b107747f2cb0b1474c4aa67d4b6b 100644 --- a/ee/spec/lib/gitlab/llm/ai_gateway/code_suggestions_client_spec.rb +++ b/ee/spec/lib/gitlab/llm/ai_gateway/code_suggestions_client_spec.rb @@ -83,7 +83,7 @@ 'X-Gitlab-Instance-Id' => Gitlab::GlobalAnonymousId.instance_id, 'X-Gitlab-Global-User-Id' => Gitlab::GlobalAnonymousId.user_id(user), 'X-Gitlab-Host-Name' => Gitlab.config.gitlab.host, - 'X-Gitlab-Realm' => Gitlab::CloudConnector::GITLAB_REALM_SELF_MANAGED, + 'X-Gitlab-Realm' => ::CloudConnector::GITLAB_REALM_SELF_MANAGED, 'X-Gitlab-Authentication-Type' => 'oidc', 'Authorization' => "Bearer #{instance_token.token}", "X-Gitlab-Feature-Enabled-By-Namespace-Ids" => [enabled_by_namespace_ids.join(',')], diff --git a/ee/spec/lib/gitlab/llm/ai_gateway/docs_client_spec.rb b/ee/spec/lib/gitlab/llm/ai_gateway/docs_client_spec.rb index 321c6d03a23b1d887723e348569b68ad1f3ebc49..b39cb6e0d34bfa5dbed9fc0643675090d25e064c 100644 --- a/ee/spec/lib/gitlab/llm/ai_gateway/docs_client_spec.rb +++ b/ee/spec/lib/gitlab/llm/ai_gateway/docs_client_spec.rb @@ -13,7 +13,7 @@ let(:enabled_by_namespace_ids) { [1, 2] } let(:expected_feature_name) { :duo_chat } let(:expected_access_token) { '123' } - let(:expected_gitlab_realm) { Gitlab::CloudConnector::GITLAB_REALM_SELF_MANAGED } + let(:expected_gitlab_realm) { ::CloudConnector::GITLAB_REALM_SELF_MANAGED } let(:expected_gitlab_host_name) { Gitlab.config.gitlab.host } let(:expected_instance_id) { Gitlab::GlobalAnonymousId.instance_id } let(:expected_user_id) { Gitlab::GlobalAnonymousId.user_id(user) } diff --git a/ee/spec/lib/gitlab/llm/completions/chat_spec.rb b/ee/spec/lib/gitlab/llm/completions/chat_spec.rb index 8a6594a45cd3f84874ec807a9150611274884f95..f34b87db3789588722c7e236254215e981c0b4a6 100644 --- a/ee/spec/lib/gitlab/llm/completions/chat_spec.rb +++ b/ee/spec/lib/gitlab/llm/completions/chat_spec.rb @@ -269,7 +269,7 @@ context 'when on self-managed cloud-connected instance' do before do - allow(::Gitlab::CloudConnector).to receive(:self_managed_cloud_connected?).and_return(true) + allow(::CloudConnector).to receive(:self_managed_cloud_connected?).and_return(true) end it 'does not push expanded ai logging feature flag to AI Gateway' do @@ -288,7 +288,7 @@ stub_feature_flags(ai_commit_reader_for_chat: true) allow(ai_request).to receive(:request) allow(::Gitlab::AiGateway).to receive(:push_feature_flag) - allow(::Gitlab::CloudConnector).to receive(:self_managed_cloud_connected?).and_return(false) + allow(::CloudConnector).to receive(:self_managed_cloud_connected?).and_return(false) end let(:tools) do diff --git a/ee/spec/requests/api/ai/duo_workflows/workflows_spec.rb b/ee/spec/requests/api/ai/duo_workflows/workflows_spec.rb index a2b2276a832a5f7c90d0e0c6b516ad25a48a9a4b..a9e612e9090b6828395b8644f738aca4813e13c5 100644 --- a/ee/spec/requests/api/ai/duo_workflows/workflows_spec.rb +++ b/ee/spec/requests/api/ai/duo_workflows/workflows_spec.rb @@ -166,7 +166,7 @@ context 'when success' do before do - allow(Gitlab::CloudConnector).to receive(:ai_headers).with(user).and_return({ header_key: 'header_value' }) + allow(::CloudConnector).to receive(:ai_headers).with(user).and_return({ header_key: 'header_value' }) allow_next_instance_of(::Ai::DuoWorkflows::CreateOauthAccessTokenService) do |service| allow(service).to receive(:execute).and_return({ status: :success, oauth_access_token: instance_double('Doorkeeper::AccessToken', plaintext_token: 'oauth_token') }) diff --git a/ee/spec/workers/observability/alert_query_worker_spec.rb b/ee/spec/workers/observability/alert_query_worker_spec.rb index 1ff87575f3dc48ae016b71370bcb328c44bc15de..9b4e77cac9c4468e2d83520c96ac2c03dd9453d6 100644 --- a/ee/spec/workers/observability/alert_query_worker_spec.rb +++ b/ee/spec/workers/observability/alert_query_worker_spec.rb @@ -9,7 +9,7 @@ let_it_be(:another_project) { create(:project, group: group) } let(:expected_instance_id) { Gitlab::GlobalAnonymousId.instance_id } - let(:expected_gitlab_realm) { Gitlab::CloudConnector::GITLAB_REALM_SELF_MANAGED } + let(:expected_gitlab_realm) { ::CloudConnector::GITLAB_REALM_SELF_MANAGED } let(:expected_access_token) { active_token.token } let(:expected_response) do