blob: f2c38d70508cab49f9b0eace14e6bb07d89e705a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# frozen_string_literal: true
RSpec.shared_examples 'MLflow|Not Found - Resource Does Not Exist' do
it "is Resource Does Not Exist", :aggregate_failures do
is_expected.to have_gitlab_http_status(:not_found)
expect(json_response).to include({ "error_code" => 'RESOURCE_DOES_NOT_EXIST' })
end
end
RSpec.shared_examples 'MLflow|Requires api scope' do
context 'when user has access but token has wrong scope' do
let(:access_token) { tokens[:read] }
it { is_expected.to have_gitlab_http_status(:forbidden) }
end
end
RSpec.shared_examples 'MLflow|Requires read_api scope' do
context 'when user has access but token has wrong scope' do
let(:access_token) { tokens[:no_access] }
it { is_expected.to have_gitlab_http_status(:forbidden) }
end
end
RSpec.shared_examples 'MLflow|Bad Request' do
it "is Bad Request" do
is_expected.to have_gitlab_http_status(:bad_request)
end
end
RSpec.shared_examples 'MLflow|shared 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 experiments is unavailable' do
before do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?)
.with(current_user, :read_model_experiments, 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
let(:params) { default_params.tap { |p| p.delete(key) } }
it "is Bad Request" do
is_expected.to have_gitlab_http_status(:bad_request)
end
end
end
end
|