diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-06 06:12:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-06 06:12:13 +0300 |
commit | ae4e6f370a477782f19008717449047b2d0fb254 (patch) | |
tree | a3dda41879e8a5c070592b52fc0a7250ec9b307b /spec/support | |
parent | 9cc2aa99c032c8b813ab1bfc439a56d39d83e679 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared_examples/requests/api/ml/mlflow/mlflow_shared_examples.rb | 31 | ||||
-rw-r--r-- | spec/support/shared_examples/requests/api/repository_storage_moves_shared_examples.rb | 100 |
2 files changed, 83 insertions, 48 deletions
diff --git a/spec/support/shared_examples/requests/api/ml/mlflow/mlflow_shared_examples.rb b/spec/support/shared_examples/requests/api/ml/mlflow/mlflow_shared_examples.rb index 00e50b07909..7978f43610d 100644 --- a/spec/support/shared_examples/requests/api/ml/mlflow/mlflow_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/ml/mlflow/mlflow_shared_examples.rb @@ -74,6 +74,37 @@ RSpec.shared_examples 'MLflow|shared error cases' do end end +RSpec.shared_examples 'MLflow|shared model registry error cases' do + context 'when not authenticated' do + let(:headers) { {} } + + it "is Unauthorized" do + is_expected.to have_gitlab_http_status(:unauthorized) + end + end + + context 'when user does not have access' do + let(:access_token) { tokens[:different_user] } + + it "is Not Found" do + is_expected.to have_gitlab_http_status(:not_found) + end + end + + context 'when model registry is unavailable' do + before do + allow(Ability).to receive(:allowed?).and_call_original + allow(Ability).to receive(:allowed?) + .with(current_user, :read_model_registry, project) + .and_return(false) + end + + it "is Not Found" do + is_expected.to have_gitlab_http_status(:not_found) + end + end +end + RSpec.shared_examples 'MLflow|Bad Request on missing required' do |keys| keys.each do |key| context "when \"#{key}\" is missing" do diff --git a/spec/support/shared_examples/requests/api/repository_storage_moves_shared_examples.rb b/spec/support/shared_examples/requests/api/repository_storage_moves_shared_examples.rb index 3913d29e086..181bab41e09 100644 --- a/spec/support/shared_examples/requests/api/repository_storage_moves_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/repository_storage_moves_shared_examples.rb @@ -80,56 +80,9 @@ RSpec.shared_examples 'repository_storage_moves API' do |container_type| end end - describe "GET /#{container_type}/:id/repository_storage_moves" do - let(:container_id) { container.id } + shared_examples 'post single container repository storage move' do let(:url) { "/#{container_type}/#{container_id}/repository_storage_moves" } - - it_behaves_like 'get container repository storage move list' - - context 'non-existent container' do - let(:container_id) { non_existing_record_id } - - it 'returns not found' do - get api(url, user, admin_mode: user.admin?) - - expect(response).to have_gitlab_http_status(:not_found) - end - end - end - - describe "GET /#{container_type}/:id/repository_storage_moves/:repository_storage_move_id" do let(:container_id) { container.id } - let(:url) { "/#{container_type}/#{container_id}/repository_storage_moves/#{repository_storage_move_id}" } - - it_behaves_like 'get single container repository storage move' - - context 'non-existent container' do - let(:container_id) { non_existing_record_id } - let(:repository_storage_move_id) { storage_move.id } - - it 'returns not found' do - get api(url, user, admin_mode: user.admin?) - - expect(response).to have_gitlab_http_status(:not_found) - end - end - end - - describe "GET /#{container_type.singularize}_repository_storage_moves" do - it_behaves_like 'get container repository storage move list' do - let(:url) { "/#{container_type.singularize}_repository_storage_moves" } - end - end - - describe "GET /#{container_type.singularize}_repository_storage_moves/:repository_storage_move_id" do - it_behaves_like 'get single container repository storage move' do - let(:url) { "/#{container_type.singularize}_repository_storage_moves/#{repository_storage_move_id}" } - end - end - - describe "POST /#{container_type}/:id/repository_storage_moves", :aggregate_failures do - let(:container_id) { container.id } - let(:url) { "/#{container_type}/#{container_id}/repository_storage_moves" } let(:destination_storage_name) { 'test_second_storage' } def create_container_repository_storage_move @@ -186,6 +139,57 @@ RSpec.shared_examples 'repository_storage_moves API' do |container_type| end end + describe "GET /#{container_type}/:id/repository_storage_moves" do + let(:container_id) { container.id } + let(:url) { "/#{container_type}/#{container_id}/repository_storage_moves" } + + it_behaves_like 'get container repository storage move list' + + context 'non-existent container' do + let(:container_id) { non_existing_record_id } + + it 'returns not found' do + get api(url, user, admin_mode: user.admin?) + + expect(response).to have_gitlab_http_status(:not_found) + end + end + end + + describe "GET /#{container_type}/:id/repository_storage_moves/:repository_storage_move_id" do + let(:container_id) { container.id } + let(:url) { "/#{container_type}/#{container_id}/repository_storage_moves/#{repository_storage_move_id}" } + + it_behaves_like 'get single container repository storage move' + + context 'non-existent container' do + let(:container_id) { non_existing_record_id } + let(:repository_storage_move_id) { storage_move.id } + + it 'returns not found' do + get api(url, user, admin_mode: user.admin?) + + expect(response).to have_gitlab_http_status(:not_found) + end + end + end + + describe "GET /#{container_type.singularize}_repository_storage_moves" do + it_behaves_like 'get container repository storage move list' do + let(:url) { "/#{container_type.singularize}_repository_storage_moves" } + end + end + + describe "GET /#{container_type.singularize}_repository_storage_moves/:repository_storage_move_id" do + it_behaves_like 'get single container repository storage move' do + let(:url) { "/#{container_type.singularize}_repository_storage_moves/#{repository_storage_move_id}" } + end + end + + describe "POST /#{container_type}/:id/repository_storage_moves", :aggregate_failures do + it_behaves_like 'post single container repository storage move' + end + describe "POST /#{container_type.singularize}_repository_storage_moves" do let(:url) { "/#{container_type.singularize}_repository_storage_moves" } let(:source_storage_name) { 'default' } |