Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop to master - remove unwanted error message on PURL redirects and clean up tests #143

Merged
merged 9 commits into from
Sep 23, 2024
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ckan-version: ["2.10", 2.9, 2.9-py2]
ckan-version: ["2.10"]
ckan-type: ['vanilla', 'custom']

name: CKAN ${{ matrix.ckan-version }} ${{ matrix.ckan-type }}
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:

- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: CKAN ${{ matrix.ckan-version }} screenshots
path: /tmp/artifacts/behave/screenshots
Expand Down
4 changes: 3 additions & 1 deletion bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ CKAN_GIT_ORG=ckan

if [ "$CKAN_VERSION" = "2.10" ]; then
if [ "$CKAN_TYPE" = "custom" ]; then
CKAN_GIT_VERSION=ckan-2.10.3-qgov.3
CKAN_GIT_VERSION=ckan-2.10.5-qgov.1
CKAN_GIT_ORG=qld-gov-au
else
CKAN_GIT_VERSION=ckan-2.10.5
fi

PYTHON_VERSION=py3
Expand Down
4 changes: 3 additions & 1 deletion ckanext/qgov/common/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ def make_middleware(self, app, config):
if hasattr(app, 'errorhandler'):
@app.errorhandler(404)
def handle_not_found(e):
from flask import redirect, request
from flask import redirect, request, get_flashed_messages
redirect_url = urlm.get_purl_response(request.base_url)
if redirect_url:
# eat the 'page not found' message as it's obsolete
get_flashed_messages()
return redirect(redirect_url, 301)
else:
# copy default error handling
Expand Down
19 changes: 19 additions & 0 deletions test/features/datasets.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@dataset
Feature: Dataset APIs

Scenario: Creative Commons BY-NC-SA 4.0 licence is an option for datasets
Expand All @@ -6,3 +7,21 @@ Feature: Dataset APIs
And I edit the "test-dataset" dataset
Then I should see an element with xpath "//option[@value='cc-by-nc-sa-4']"

Scenario: As a publisher, I can view the change history of a dataset
Given "TestOrgEditor" as the persona
When I log in
And I create a dataset and resource with key-value parameters "notes=Testing activity stream" and "name=Test"
And I press the element with xpath "//a[contains(@href, '/dataset/activity/') and contains(string(), 'Activity Stream')]"
Then I should see "created the dataset"
When I press "View this version"
Then I should see "You're currently viewing an old version of this dataset."

When I go back
And I press "Changes"
Then I should see "View changes from"
And I should see an element with xpath "//select[@name='old_id']"
And I should see an element with xpath "//select[@name='new_id']"

When I go back
And I press the element with xpath "//li[contains(@class, 'new-package')]/preceding-sibling::li[1]//a[contains(string(), 'Changes')]"
Then I should see "Added resource"
5 changes: 4 additions & 1 deletion test/features/organisations.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@users
@organisations
Feature: Organization APIs

Scenario Outline: Organisation membership is accessible to admins of the organisation
Expand Down Expand Up @@ -37,6 +37,9 @@ Feature: Organization APIs
Then I should see "Test Organisation"
And I should not see an element with xpath "//a[contains(@href, '?action=read')]"
And I should see an element with xpath "//a[contains(@href, '/organization/test-organisation')]"
When I press "Test Organisation"
And I press "Activity Stream"
Then I should see "created the org"

When I view the "test-organisation" organisation API "not including" users
Then I should see an element with xpath "//*[contains(string(), '"success": true') and contains(string(), '"name": "test-organisation"')]"
18 changes: 18 additions & 0 deletions test/features/users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,21 @@ Feature: User APIs
And I fill in "password2" with "password1234"
And I press "Create Account"
Then I should see "Password: Must contain at least one number, lowercase letter, capital letter, and symbol"

Scenario: As a sysadmin, when I go to the sysadmin list, I can promote and demote other sysadmins
Given "SysAdmin" as the persona
When I log in
And I click the link to a url that contains "/ckan-admin/"
And I take a debugging screenshot
Then I should see an element with xpath "//table//a[string() = 'Administrator' and @href = '/user/admin']"
And I should not see "Test Admin"

When I fill in "promote-username" with "test_org_admin"
And I press "Promote"
And I take a debugging screenshot
Then I should see "Promoted Test Admin to sysadmin"
And I should see an element with xpath "//table//a[string() = 'Test Admin' and @href = '/user/test_org_admin']"

When I press the element with xpath "//tr/td/a[@href = '/user/test_org_admin']/../following-sibling::td//button[contains(@title, 'Revoke')]"
Then I should see "Revoked sysadmin permission from Test Admin"
And I should not see an element with xpath "//table//a[@href = '/user/test_org_admin']"
Loading