Skip to content

Commit

Permalink
Block web search indexing on backend; add tests (#574)
Browse files Browse the repository at this point in the history
* Block web search indexing on backend; add tests

* Fix test URLs
  • Loading branch information
mpolidori authored Oct 27, 2024
1 parent 620a5cb commit fd46641
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% ckan_extends %}

{% block meta %}
{{ super() }}
<meta name="robots" content="noindex,nofollow">
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
User-agent: *
{% block all_user_agents -%}
Disallow: /
{%- endblock %}

{% block additional_user_agents -%}
{%- endblock %}
12 changes: 12 additions & 0 deletions e2e-tests/cypress/e2e/robots_txt.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe('robots.txt Test', () => {
it('should only contain custom rule', () => {
cy.request('http://ckan-dev:5000/private-admin/robots.txt').then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.contain('User-agent: *');
expect(response.body).to.contain('Disallow: /');
expect(response.body).not.to.contain('Disallow: /dataset/rate/');
expect(response.body).not.to.contain('Disallow: /revision/');
expect(response.body).not.to.contain('Crawl-Delay: 10');
});
});
});
6 changes: 6 additions & 0 deletions e2e-tests/cypress/e2e/web_search_indexing.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe('Meta Robots Tag Test', () => {
it('should contain a "noindex, nofollow" robots meta tag on the homepage', () => {
cy.visit('http://ckan-dev:5000/private-admin/');
cy.get('head meta[name="robots"]').should('have.attr', 'content', 'noindex,nofollow');
});
});

0 comments on commit fd46641

Please sign in to comment.