diff options
Diffstat (limited to 'spec/requests/api/internal')
-rw-r--r-- | spec/requests/api/internal/base_spec.rb | 115 | ||||
-rw-r--r-- | spec/requests/api/internal/container_registry/migration_spec.rb | 19 |
2 files changed, 105 insertions, 29 deletions
diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index 2b7963eadab..acfe476a864 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -612,30 +612,6 @@ RSpec.describe API::Internal::Base do expect(json_response["gitaly"]["features"]).to eq('gitaly-feature-mep-mep' => 'false') end end - - context "with a sidechannels enabled for a project" do - before do - stub_feature_flags(gitlab_shell_upload_pack_sidechannel: project) - end - - it "has the use_sidechannel field set to true for that project" do - pull(key, project) - - expect(response).to have_gitlab_http_status(:ok) - expect(json_response["gl_repository"]).to eq("project-#{project.id}") - expect(json_response["gitaly"]["use_sidechannel"]).to eq(true) - end - - it "has the use_sidechannel field set to false for other projects" do - other_project = create(:project, :public, :repository) - - pull(key, other_project) - - expect(response).to have_gitlab_http_status(:ok) - expect(json_response["gl_repository"]).to eq("project-#{other_project.id}") - expect(json_response["gitaly"]["use_sidechannel"]).to eq(false) - end - end end context "git push" do @@ -826,13 +802,13 @@ RSpec.describe API::Internal::Base do context 'git pull' do context 'with a key that has expired' do - let(:key) { create(:key, user: user, expires_at: 2.days.ago) } + let(:key) { create(:key, :expired, user: user) } - it 'includes the `key expired` message in the response' do + it 'includes the `key expired` message in the response and fails' do pull(key, project) - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['gl_console_messages']).to eq(['INFO: Your SSH key has expired. Please generate a new key.']) + expect(response).to have_gitlab_http_status(:unauthorized) + expect(json_response['message']).to eq('Your SSH key has expired.') end end @@ -1490,6 +1466,89 @@ RSpec.describe API::Internal::Base do subject expect(json_response['success']).to be_falsey + expect(json_response['message']).to eq 'Feature is not available' + end + end + + describe 'POST /internal/two_factor_manual_otp_check' do + let(:key_id) { key.id } + let(:otp) { '123456'} + + subject do + post api('/internal/two_factor_manual_otp_check'), + params: { + secret_token: secret_token, + key_id: key_id, + otp_attempt: otp + } + end + + it 'is not available' do + subject + + expect(json_response['success']).to be_falsey + expect(json_response['message']).to eq 'Feature is not available' + end + end + + describe 'POST /internal/two_factor_push_otp_check' do + let(:key_id) { key.id } + let(:otp) { '123456'} + + subject do + post api('/internal/two_factor_push_otp_check'), + params: { + secret_token: secret_token, + key_id: key_id, + otp_attempt: otp + } + end + + it 'is not available' do + subject + + expect(json_response['success']).to be_falsey + expect(json_response['message']).to eq 'Feature is not available' + end + end + + describe 'POST /internal/two_factor_manual_otp_check' do + let(:key_id) { key.id } + let(:otp) { '123456'} + + subject do + post api('/internal/two_factor_manual_otp_check'), + params: { + secret_token: secret_token, + key_id: key_id, + otp_attempt: otp + } + end + + it 'is not available' do + subject + + expect(json_response['success']).to be_falsey + end + end + + describe 'POST /internal/two_factor_push_otp_check' do + let(:key_id) { key.id } + let(:otp) { '123456'} + + subject do + post api('/internal/two_factor_push_otp_check'), + params: { + secret_token: secret_token, + key_id: key_id, + otp_attempt: otp + } + end + + it 'is not available' do + subject + + expect(json_response['success']).to be_falsey end end diff --git a/spec/requests/api/internal/container_registry/migration_spec.rb b/spec/requests/api/internal/container_registry/migration_spec.rb index 35113c66f11..db2918e65f1 100644 --- a/spec/requests/api/internal/container_registry/migration_spec.rb +++ b/spec/requests/api/internal/container_registry/migration_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Internal::ContainerRegistry::Migration do +RSpec.describe API::Internal::ContainerRegistry::Migration, :aggregate_failures do let_it_be_with_reload(:repository) { create(:container_repository) } let(:secret_token) { 'secret_token' } @@ -127,6 +127,12 @@ RSpec.describe API::Internal::ContainerRegistry::Migration do it_behaves_like 'updating the repository migration status', from: 'pre_importing', to: 'import_aborted' end + + context 'with repository in unabortable migration state' do + let(:repository) { create(:container_repository, :import_skipped) } + + it_behaves_like 'returning an error', with_message: 'Wrong migration state (import_skipped)' + end end end @@ -147,6 +153,17 @@ RSpec.describe API::Internal::ContainerRegistry::Migration do it_behaves_like 'returning an error', returning_status: :not_found end + + context 'query read location' do + it 'reads from the primary' do + expect(ContainerRepository).to receive(:find_by_path!).and_wrap_original do |m, *args| + expect(::Gitlab::Database::LoadBalancing::Session.current.use_primary?).to eq(true) + m.call(*args) + end + + subject + end + end end context 'with an invalid sent token' do |