Commit 24411b6f authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Simplify Jira dev integration license check

parent 4b9543bd
......@@ -12,11 +12,6 @@ module EE
with_scope :subject
condition(:deploy_board_disabled) { !@subject.feature_available?(:deploy_board) }
with_scope :subject
condition(:jira_dev_panel_integration_disabled) do
!@subject.feature_available?(:jira_dev_panel_integration)
end
with_scope :global
condition(:is_development) { Rails.env.development? }
......@@ -39,17 +34,12 @@ module EE
prevent :admin_issue_link
end
rule { jira_dev_panel_integration_disabled }.policy do
prevent :integrate_to_jira_dev_panel
end
rule { can?(:read_issue) }.enable :read_issue_link
rule { can?(:reporter_access) }.policy do
enable :admin_board
enable :read_deploy_board
enable :admin_issue_link
enable :integrate_to_jira_dev_panel
end
rule { can?(:developer_access) }.enable :admin_board
......
......@@ -9,9 +9,9 @@ module API
requires :project, type: String
end
def find_project_with_access(full_path, access_level = :integrate_to_jira_dev_panel)
def find_project_with_access(full_path)
project = find_project!(full_path)
authorize! access_level, project
not_found! unless project.feature_available?(:jira_dev_panel_integration)
project
end
end
......@@ -30,7 +30,7 @@ module API
resource :users do
get ':namespace/repos' do
projects = current_user.authorized_projects.select { |project| can?(current_user, :integrate_to_jira_dev_panel, project) }
projects = current_user.authorized_projects.select { |project| project.feature_available?(:jira_dev_panel_integration) }
projects = ::Kaminari.paginate_array(projects)
present paginate(projects), with: ::API::Entities::Github::Repository
end
......
......@@ -100,9 +100,6 @@ describe API::V3::GithubRepos do
end
context 'unauthenticated' do
before do
end
it 'returns 401' do
stub_licensed_features(jira_dev_panel_integration: true)
......@@ -113,23 +110,14 @@ describe API::V3::GithubRepos do
end
context 'unauthorized' do
it 'returns 403 when lower access level' do
unauthorized_user = create(:user)
project.add_guest(unauthorized_user)
get v3_api("/repos/#{project.namespace.path}/#{project.path}/branches", unauthorized_user)
expect(response).to have_http_status(403)
end
it 'returns 403 when not licensed' do
it 'returns 404 when not licensed' do
stub_licensed_features(jira_dev_panel_integration: false)
unauthorized_user = create(:user)
project.add_reporter(unauthorized_user)
get v3_api("/repos/#{project.namespace.path}/#{project.path}/branches", unauthorized_user)
expect(response).to have_http_status(403)
expect(response).to have_http_status(404)
end
end
end
......@@ -178,17 +166,17 @@ describe API::V3::GithubRepos do
end
context 'unauthorized' do
it 'returns 403 when lower access level' do
it 'returns 404 when lower access level' do
unauthorized_user = create(:user)
project.add_guest(unauthorized_user)
get v3_api("/repos/#{project.namespace.path}/#{project.path}/commits/#{commit_id}",
unauthorized_user)
expect(response).to have_http_status(403)
expect(response).to have_http_status(404)
end
it 'returns 403 when not licensed' do
it 'returns 404 when not licensed' do
stub_licensed_features(jira_dev_panel_integration: false)
unauthorized_user = create(:user)
project.add_reporter(unauthorized_user)
......@@ -196,7 +184,7 @@ describe API::V3::GithubRepos do
get v3_api("/repos/#{project.namespace.path}/#{project.path}/commits/#{commit_id}",
unauthorized_user)
expect(response).to have_http_status(403)
expect(response).to have_http_status(404)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment