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

Simplify Jira dev integration license check

parent 4b9543bd
...@@ -12,11 +12,6 @@ module EE ...@@ -12,11 +12,6 @@ module EE
with_scope :subject with_scope :subject
condition(:deploy_board_disabled) { !@subject.feature_available?(:deploy_board) } 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 with_scope :global
condition(:is_development) { Rails.env.development? } condition(:is_development) { Rails.env.development? }
...@@ -39,17 +34,12 @@ module EE ...@@ -39,17 +34,12 @@ module EE
prevent :admin_issue_link prevent :admin_issue_link
end 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?(:read_issue) }.enable :read_issue_link
rule { can?(:reporter_access) }.policy do rule { can?(:reporter_access) }.policy do
enable :admin_board enable :admin_board
enable :read_deploy_board enable :read_deploy_board
enable :admin_issue_link enable :admin_issue_link
enable :integrate_to_jira_dev_panel
end end
rule { can?(:developer_access) }.enable :admin_board rule { can?(:developer_access) }.enable :admin_board
......
...@@ -9,9 +9,9 @@ module API ...@@ -9,9 +9,9 @@ module API
requires :project, type: String requires :project, type: String
end 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) project = find_project!(full_path)
authorize! access_level, project not_found! unless project.feature_available?(:jira_dev_panel_integration)
project project
end end
end end
...@@ -30,7 +30,7 @@ module API ...@@ -30,7 +30,7 @@ module API
resource :users do resource :users do
get ':namespace/repos' 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) projects = ::Kaminari.paginate_array(projects)
present paginate(projects), with: ::API::Entities::Github::Repository present paginate(projects), with: ::API::Entities::Github::Repository
end end
......
...@@ -100,9 +100,6 @@ describe API::V3::GithubRepos do ...@@ -100,9 +100,6 @@ describe API::V3::GithubRepos do
end end
context 'unauthenticated' do context 'unauthenticated' do
before do
end
it 'returns 401' do it 'returns 401' do
stub_licensed_features(jira_dev_panel_integration: true) stub_licensed_features(jira_dev_panel_integration: true)
...@@ -113,23 +110,14 @@ describe API::V3::GithubRepos do ...@@ -113,23 +110,14 @@ describe API::V3::GithubRepos do
end end
context 'unauthorized' do context 'unauthorized' do
it 'returns 403 when lower access level' do it 'returns 404 when not licensed' 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
stub_licensed_features(jira_dev_panel_integration: false) stub_licensed_features(jira_dev_panel_integration: false)
unauthorized_user = create(:user) unauthorized_user = create(:user)
project.add_reporter(unauthorized_user) project.add_reporter(unauthorized_user)
get v3_api("/repos/#{project.namespace.path}/#{project.path}/branches", 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 end
end end
...@@ -178,17 +166,17 @@ describe API::V3::GithubRepos do ...@@ -178,17 +166,17 @@ describe API::V3::GithubRepos do
end end
context 'unauthorized' do context 'unauthorized' do
it 'returns 403 when lower access level' do it 'returns 404 when lower access level' do
unauthorized_user = create(:user) unauthorized_user = create(:user)
project.add_guest(unauthorized_user) project.add_guest(unauthorized_user)
get v3_api("/repos/#{project.namespace.path}/#{project.path}/commits/#{commit_id}", get v3_api("/repos/#{project.namespace.path}/#{project.path}/commits/#{commit_id}",
unauthorized_user) unauthorized_user)
expect(response).to have_http_status(403) expect(response).to have_http_status(404)
end end
it 'returns 403 when not licensed' do it 'returns 404 when not licensed' do
stub_licensed_features(jira_dev_panel_integration: false) stub_licensed_features(jira_dev_panel_integration: false)
unauthorized_user = create(:user) unauthorized_user = create(:user)
project.add_reporter(unauthorized_user) project.add_reporter(unauthorized_user)
...@@ -196,7 +184,7 @@ describe API::V3::GithubRepos do ...@@ -196,7 +184,7 @@ describe API::V3::GithubRepos do
get v3_api("/repos/#{project.namespace.path}/#{project.path}/commits/#{commit_id}", get v3_api("/repos/#{project.namespace.path}/#{project.path}/commits/#{commit_id}",
unauthorized_user) unauthorized_user)
expect(response).to have_http_status(403) expect(response).to have_http_status(404)
end end
end 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