2020-10-27 12:08:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Robots.txt Requests', :aggregate_failures do
|
|
|
|
before do
|
|
|
|
Gitlab::Testing::RobotsBlockerMiddleware.block_requests!
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
Gitlab::Testing::RobotsBlockerMiddleware.allow_requests!
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows the requests' do
|
|
|
|
requests = [
|
2020-10-27 15:08:39 +00:00
|
|
|
'/users/sign_in',
|
2020-10-28 18:08:52 +00:00
|
|
|
'/namespace/subnamespace/design.gitlab.com',
|
|
|
|
'/users/foo/snippets',
|
|
|
|
'/users/foo/snippets/1'
|
2020-10-27 12:08:33 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
requests.each do |request|
|
|
|
|
get request
|
|
|
|
|
|
|
|
expect(response).not_to have_gitlab_http_status(:service_unavailable), "#{request} must be allowed"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'blocks the requests' do
|
|
|
|
requests = [
|
|
|
|
'/autocomplete/users',
|
2020-10-28 09:08:37 +00:00
|
|
|
'/autocomplete/projects',
|
2020-10-27 12:08:33 +00:00
|
|
|
'/search',
|
|
|
|
'/admin',
|
|
|
|
'/profile',
|
|
|
|
'/dashboard',
|
|
|
|
'/users',
|
|
|
|
'/users/foo',
|
|
|
|
'/help',
|
|
|
|
'/s/',
|
|
|
|
'/-/profile',
|
2020-10-28 15:08:49 +00:00
|
|
|
'/-/ide/project',
|
2020-10-27 12:08:33 +00:00
|
|
|
'/foo/bar/new',
|
|
|
|
'/foo/bar/edit',
|
|
|
|
'/foo/bar/raw',
|
|
|
|
'/groups/foo/analytics',
|
|
|
|
'/groups/foo/contribution_analytics',
|
|
|
|
'/groups/foo/group_members',
|
|
|
|
'/foo/bar/project.git',
|
|
|
|
'/foo/bar/archive/foo',
|
|
|
|
'/foo/bar/repository/archive',
|
|
|
|
'/foo/bar/activity',
|
|
|
|
'/foo/bar/blame',
|
|
|
|
'/foo/bar/commits',
|
|
|
|
'/foo/bar/commit',
|
|
|
|
'/foo/bar/compare',
|
|
|
|
'/foo/bar/network',
|
|
|
|
'/foo/bar/graphs',
|
|
|
|
'/foo/bar/merge_requests/1.patch',
|
|
|
|
'/foo/bar/merge_requests/1.diff',
|
|
|
|
'/foo/bar/merge_requests/1/diffs',
|
|
|
|
'/foo/bar/deploy_keys',
|
|
|
|
'/foo/bar/hooks',
|
|
|
|
'/foo/bar/services',
|
|
|
|
'/foo/bar/protected_branches',
|
|
|
|
'/foo/bar/uploads/foo',
|
|
|
|
'/foo/bar/project_members',
|
2020-10-27 15:08:39 +00:00
|
|
|
'/foo/bar/settings',
|
2020-10-29 00:08:36 +00:00
|
|
|
'/namespace/subnamespace/design.gitlab.com/settings',
|
|
|
|
'/foo/bar/-/import',
|
|
|
|
'/foo/bar/-/environments',
|
|
|
|
'/foo/bar/-/jobs',
|
|
|
|
'/foo/bar/-/requirements_management',
|
|
|
|
'/foo/bar/-/pipelines',
|
|
|
|
'/foo/bar/-/pipeline_schedules',
|
|
|
|
'/foo/bar/-/dependencies',
|
|
|
|
'/foo/bar/-/licenses',
|
|
|
|
'/foo/bar/-/metrics',
|
|
|
|
'/foo/bar/-/incidents',
|
|
|
|
'/foo/bar/-/value_stream_analytics',
|
|
|
|
'/foo/bar/-/analytics',
|
2020-10-29 18:09:11 +00:00
|
|
|
'/foo/bar/insights',
|
|
|
|
'/foo/bar/-/issues/123/realtime_changes',
|
|
|
|
'/groups/group/-/epics/123/realtime_changes'
|
2020-10-27 12:08:33 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
requests.each do |request|
|
|
|
|
get request
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(:service_unavailable), "#{request} must be disallowed"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|