Skip to content

Commit

Permalink
[QOLDEV-955] replace 'curl' with more universally available 'wget'
Browse files Browse the repository at this point in the history
  • Loading branch information
ThrawnCA committed Oct 25, 2024
1 parent da54836 commit 3538ddc
Showing 1 changed file with 20 additions and 39 deletions.
59 changes: 20 additions & 39 deletions bin/create-test-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,25 @@ add_user_if_needed test_org_member "Test Member" test_org_member@localhost

echo "Creating ${TEST_ORG_TITLE} organisation:"

api_call () {
wget -O - --header="Authorization: ${API_KEY}" --post-data "$1" ${CKAN_ACTION_URL}/$2
}

TEST_ORG=$( \
curl -LsH "Authorization: ${API_KEY}" \
--data '{"name": "'"${TEST_ORG_NAME}"'", "title": "'"${TEST_ORG_TITLE}"'",
"description": "Organisation for testing issues"}' \
${CKAN_ACTION_URL}/organization_create
api_call '{"name": "'"${TEST_ORG_NAME}"'", "title": "'"${TEST_ORG_TITLE}"'",
"description": "Organisation for testing issues"}' organization_create
)

TEST_ORG_ID=$(echo $TEST_ORG | $PYTHON ${APP_DIR}/bin/extract-id.py)

echo "Assigning test users to '${TEST_ORG_TITLE}' organisation (${TEST_ORG_ID}):"

curl -LsH "Authorization: ${API_KEY}" \
--data '{"id": "'"${TEST_ORG_ID}"'", "object": "test_org_admin", "object_type": "user", "capacity": "admin"}' \
${CKAN_ACTION_URL}/member_create
api_call '{"id": "'"${TEST_ORG_ID}"'", "object": "test_org_admin", "object_type": "user", "capacity": "admin"}' member_create

api_call '{"id": "'"${TEST_ORG_ID}"'", "object": "test_org_editor", "object_type": "user", "capacity": "editor"}' member_create

curl -LsH "Authorization: ${API_KEY}" \
--data '{"id": "'"${TEST_ORG_ID}"'", "object": "test_org_editor", "object_type": "user", "capacity": "editor"}' \
${CKAN_ACTION_URL}/member_create
api_call '{"id": "'"${TEST_ORG_ID}"'", "object": "test_org_member", "object_type": "user", "capacity": "member"}' member_create

curl -LsH "Authorization: ${API_KEY}" \
--data '{"id": "'"${TEST_ORG_ID}"'", "object": "test_org_member", "object_type": "user", "capacity": "member"}' \
${CKAN_ACTION_URL}/member_create
##
# END.
#
Expand All @@ -73,61 +70,45 @@ add_user_if_needed group_admin "Group Admin" group_admin@localhost
add_user_if_needed walker "Walker" walker@localhost

# Create private test dataset with our standard fields
curl -LsH "Authorization: ${API_KEY}" \
--data '{"name": "test-dataset", "owner_org": "'"${TEST_ORG_ID}"'", "private": true,
"author_email": "admin@localhost", "license_id": "other-open", "notes": "private test"}' \
${CKAN_ACTION_URL}/package_create
api_call '{"name": "test-dataset", "owner_org": "'"${TEST_ORG_ID}"'", "private": true,
"author_email": "admin@localhost", "license_id": "other-open", "notes": "private test"}' package_create

# Create public test dataset with our standard fields
curl -LsH "Authorization: ${API_KEY}" \
--data '{"name": "public-test-dataset", "owner_org": "'"${TEST_ORG_ID}"'",
"author_email": "admin@localhost", "license_id": "other-open", "notes": "public test"}' \
${CKAN_ACTION_URL}/package_create
api_call '{"name": "public-test-dataset", "owner_org": "'"${TEST_ORG_ID}"'",
"author_email": "admin@localhost", "license_id": "other-open", "notes": "public test"}' package_create

echo "Creating department-of-health organisation:"
organisation_create=$( \
curl -LsH "Authorization: ${API_KEY}" \
--data "name=department-of-health&title=Department%20of%20Health" \
${CKAN_ACTION_URL}/organization_create
api_call "name=department-of-health&title=Department%20of%20Health" organization_create
)
echo ${organisation_create}

echo "Creating food-standards-agency organisation:"
organisation_create=$( \
curl -LsH "Authorization: ${API_KEY}" \
--data "name=food-standards-agency&title=Food%20Standards%20Agency" \
${CKAN_ACTION_URL}/organization_create
api_call "name=food-standards-agency&title=Food%20Standards%20Agency" organization_create
)
echo ${organisation_create}

echo "Creating non-organisation group:"
group_create=$( \
curl -LsH "Authorization: ${API_KEY}" \
--data '{"name": "silly-walks", "title": "Silly walks", "description": "The Ministry of Silly Walks"}' \
${CKAN_ACTION_URL}/group_create
api_call '{"name": "silly-walks", "title": "Silly walks", "description": "The Ministry of Silly Walks"}' group_create
)
echo ${group_create}

echo "Updating group_admin to have admin privileges in the silly-walks group:"
group_admin_update=$( \
curl -LsH "Authorization: ${API_KEY}" \
--data '{"id": "silly-walks", "username": "group_admin", "role": "admin"}' \
${CKAN_ACTION_URL}/group_member_create
api_call '{"id": "silly-walks", "username": "group_admin", "role": "admin"}' group_member_create
)
echo ${group_admin_update}

echo "Updating walker to have editor privileges in the silly-walks group:"
walker_update=$( \
curl -LsH "Authorization: ${API_KEY}" \
--data '{"id": "silly-walks", "username": "walker", "role": "editor"}' \
${CKAN_ACTION_URL}/group_member_create
api_call '{"id": "silly-walks", "username": "walker", "role": "editor"}' group_member_create
)
echo ${walker_update}

echo "Creating config value for excluded display name words:"

curl -LsH "Authorization: ${API_KEY}" \
--data '{"ckanext.data_qld.excluded_display_name_words": "gov"}' \
${CKAN_ACTION_URL}/config_option_update
api_call '{"ckanext.data_qld.excluded_display_name_words": "gov"}' config_option_update

. ${APP_DIR}/bin/deactivate

0 comments on commit 3538ddc

Please sign in to comment.