-
Notifications
You must be signed in to change notification settings - Fork 1
Embargo script updates #8
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
base: master
Are you sure you want to change the base?
Changes from all commits
c7833f8
1df4d8a
2361cc8
d8d717d
9710669
6fd44ed
0e21180
dedbafd
5d64636
cbfe3f1
e92c2e1
0a30090
c3375a3
147328c
5f9945a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| Title,Method,URI,Headers,Form,Payload,Expected,Store,Test,NS | ||
| Load Configuration File,FILE,config.xml,,,,,"BASE_URL=/config/base_url | ||
| DEFAULT_ADMIN_SET=/config/default_admin_set | ||
| COLLECTION_ID=/config/rw_collection_id | ||
| RO_COLLECTION_ID=/config/ro_collection_id | ||
| DENY_COLLECTION_ID=/config/deny_collection_id | ||
| API_KEY=/config/api_key",, | ||
| Post a SimpleZip with embargo,POST,$BASE_URL/sword/v2/collections/$DEFAULT_ADMIN_SET/works,Api-key: $API_KEY,payload=files/EtdEmbargo.zip,,201,"temp/post.body.out=* | ||
| WORKID=//*[local-name() = ""id""]/text() | ||
| WORKEDIT=//*[local-name() = ""link"" and @rel=""edit""]/@href",,atom=http://www.w3.org/2005/Atom | ||
| Extract Filesets created under this work,XSLT,embargo/get-first-fileset.xsl,,,temp/post.body.out,,FILESET_URL=//resultroot/*[1]/text(),, | ||
| Extract ATOM response to metadata format,XSLT,embargo/h4cmeta.xsl,,,temp/post.body.out,,temp/post.metadata.xml=*,"embargo=//metadata/visibility/text() | ||
| *=//metadata/visibility_after_embargo | ||
| *=//metadata/visibility_during_embargo | ||
| *=//metadata/embargo_release_date", | ||
| Fileset should inherit same embargo...GET Fileset,GET,$FILESET_URL,Api-key: $API_KEY,,,200,temp/fileset.body.out=*,"embargo=//metadata/visibility/text() | ||
| *=//metadata/visibility_after_embargo | ||
| *=//metadata/visibility_during_embargo | ||
| *=//metadata/embargo_release_date", | ||
| Extract ATOM response to metadata and check embargo for Fileset,XSLT,embargo/h4cmeta.xsl,,,temp/fileset.body.out,,temp/fileset.metadata.xml=*,"embargo=//metadata/visibility/text() | ||
| *=//metadata/visibility_after_embargo | ||
| *=//metadata/visibility_during_embargo | ||
| *=//metadata/embargo_release_date", |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| { | ||
| "Headers": ["Title","Method","URI","Headers", | ||
| "Form","Payload","Expected","Store","Test","NS"], | ||
| "steps": [ { | ||
| "Title": "Load Configuration File", | ||
| "Method": "FILE", | ||
| "URI": "config.xml" , | ||
| "Store": ["BASE_URL=/config/base_url", | ||
| "DEFAULT_ADMIN_SET=/config/default_admin_set", | ||
| "COLLECTION_ID=/config/rw_collection_id", | ||
| "RO_COLLECTION_ID=/config/ro_collection_id", | ||
| "DENY_COLLECTION_ID=/config/deny_collection_id", | ||
| "API_KEY=/config/api_key"] | ||
| }, | ||
| { | ||
| "Title": "Post a SimpleZip with embargo", | ||
| "Method": "POST", | ||
| "URI": "$BASE_URL/sword/v2/collections/$DEFAULT_ADMIN_SET/works", | ||
| "Headers":["Api-key: $API_KEY"], | ||
| "Form": ["payload=files/EtdEmbargo.zip"], | ||
| "Expected":201, | ||
| "Store":["temp/post.body.out=*", | ||
| "WORKID=//atom:id/text()", | ||
| "WORKEDIT=//atom:link[@rel=\"edit\"]/@href"], | ||
| "NS":"atom=http://www.w3.org/2005/Atom" | ||
| }, | ||
| { | ||
| "Title": "Extract Filesets created under this work", | ||
| "Method": "XSLT", | ||
| "URI": "embargo/get-first-fileset.xsl", | ||
| "Payload": "temp/post.body.out", | ||
| "Store":["FILESET_URL=//resultroot/*[1]/text()"] | ||
| }, | ||
| { | ||
| "Title": "Extract ATOM response to metadata format", | ||
| "Method": "XSLT", | ||
| "URI": "embargo/h4cmeta.xsl", | ||
| "Payload": "temp/post.body.out", | ||
| "Store":["temp/post.metadata.xml=*"], | ||
| "Test": ["embargo=//metadata/visibility/text()", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Each of these would be better with a root match ( |
||
| "*=//metadata/visibility_after_embargo", | ||
| "*=//metadata/visibility_during_embargo", | ||
| "*=//metadata/embargo_release_date" | ||
| ] | ||
| }, | ||
| { | ||
| "Title": "Fileset should inherit same embargo...GET Fileset", | ||
| "Method": "GET", | ||
| "Headers": ["Api-key: $API_KEY"], | ||
| "URI": "$FILESET_URL", | ||
| "Expected": 200, | ||
| "Store":["temp/fileset.body.out=*"], | ||
| "Test": ["embargo=//metadata/visibility/text()", | ||
| "*=//metadata/visibility_after_embargo", | ||
| "*=//metadata/visibility_during_embargo", | ||
| "*=//metadata/embargo_release_date" | ||
| ] | ||
| }, | ||
| { | ||
| "Title": "Extract ATOM response to metadata and check embargo for Fileset", | ||
| "Method": "XSLT", | ||
| "URI": "embargo/h4cmeta.xsl", | ||
| "Payload": "temp/fileset.body.out", | ||
| "Store":["temp/fileset.metadata.xml=*"], | ||
| "Test": ["embargo=//metadata/visibility/text()", | ||
| "*=//metadata/visibility_after_embargo", | ||
| "*=//metadata/visibility_during_embargo", | ||
| "*=//metadata/embargo_release_date" | ||
| ] | ||
| } | ||
| ]} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:h4cmeta="https://hykucommons.org/schema/metadata" xmlns:atom="http://www.w3.org/2005/Atom" exclude-result-prefixes="h4cmeta atom"> | ||
| <xsl:output method="xml" omit-xml-declaration="yes" indent="no"/> | ||
|
|
||
| <xsl:template match="/atom:entry"> | ||
| <resultroot> | ||
| <xsl:for-each select="atom:link[@rel='edit-media']"> | ||
| <result> | ||
| <xsl:value-of select="@href" /> | ||
| </result> | ||
| </xsl:for-each> | ||
| </resultroot> | ||
| </xsl:template> | ||
|
|
||
| </xsl:stylesheet> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| """ | ||
| Read json file (provided in argv), and convert it into a csv that can be fed into | ||
| runtests.py. CSV is written to stdout. | ||
| """ | ||
|
|
||
| import json | ||
| import csv | ||
| import sys | ||
|
|
||
| csv_headers = ("Title","Method","URI","Headers", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are the CSV headers named here, but also in the YAMLs as a |
||
| "Form","Payload","Expected","Store","Test","NS") | ||
|
|
||
|
|
||
| def usage(): | ||
| print(f"Usage: python3 {__file__} <input.json>", file=sys.stderr) | ||
| print("Read json file, and convert it into a csv that can be fed into" | ||
| "runtests.py. CSV is written to stdout.", file=sys.stderr) | ||
|
|
||
| def main(): | ||
| """ | ||
| JSON assumed to have a base object, with a field "steps" which is an | ||
| array of json objects. Each of the json objects corresponds to a row of the | ||
| csv. If a field of a json object is not specified, it is assumed to be empty. | ||
| Strings and ints are treated in trivial ways. JSON arrays are translated into | ||
| multiline sequences within CSV. | ||
|
|
||
| See ../README.md for details about CSV | ||
| """ | ||
| if len(sys.argv) != 2: | ||
| print("Invalid Number of arguments") | ||
| usage() | ||
| return | ||
| json_file = sys.argv[1] | ||
| with open(json_file) as f: | ||
| input_file = json.load(f) | ||
| output = csv.DictWriter(sys.stdout, csv_headers) | ||
| output.writeheader() | ||
| for step in input_file['steps']: | ||
| for k, v in step.items(): | ||
| if type(v) == list: | ||
| step[k] = '\n'.join(v) | ||
| output.writerow(step) | ||
|
|
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| Title,Method,URI,Headers,Form,Payload,Expected,Store,Test,NS | ||
| Load Configuration File,FILE,config.xml,,,,,"BASE_URL=/config/base_url | ||
| DEFAULT_ADMIN_SET=/config/default_admin_set | ||
| COLLECTION_ID=/config/rw_collection_id | ||
| RO_COLLECTION_ID=/config/ro_collection_id | ||
| DENY_COLLECTION_ID=/config/deny_collection_id | ||
| API_KEY=/config/api_key | ||
| AUTH_KEY=/config/basic_auth",, | ||
| Get service document and check type in correct namespace,GET,$BASE_URL/sword/v2/service_document,"Api-key: $API_KEY | ||
| Content-type: application/xml",,,200,temp/service_document=*,True=count(//h:type)>0 and count(//a:type)=0,"h=https://hykucommons.org/schema/system | ||
| a=http://www.w3.org/2005/Atom" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
|
|
||
| { | ||
| "Headers": ["Title","Method","URI","Headers", | ||
| "Form","Payload","Expected","Store","Test","NS"], | ||
| "steps": [ { | ||
| "Title": "Load Configuration File", | ||
| "Method": "FILE", | ||
| "URI": "config.xml" , | ||
| "Store": ["BASE_URL=/config/base_url", | ||
| "DEFAULT_ADMIN_SET=/config/default_admin_set", | ||
| "COLLECTION_ID=/config/rw_collection_id", | ||
| "RO_COLLECTION_ID=/config/ro_collection_id", | ||
| "DENY_COLLECTION_ID=/config/deny_collection_id", | ||
| "API_KEY=/config/api_key", | ||
| "AUTH_KEY=/config/basic_auth"] | ||
| }, | ||
| { | ||
| "Title": "Get service document and check type in correct namespace", | ||
| "Method": "GET", | ||
| "URI": "$BASE_URL/sword/v2/service_document", | ||
| "Headers": ["Api-key: $API_KEY", "Content-type: application/xml"], | ||
| "Store": ["temp/service_document=*"], | ||
| "Test":["True=count(//h:type)>0 and count(//a:type)=0"], | ||
| "Expected": 200, | ||
| "NS": ["h=https://hykucommons.org/schema/system", "a=http://www.w3.org/2005/Atom"] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| Title,Method,URI,Headers,Form,Payload,Expected,Store,Test,NS | ||
| Load Configuration File,FILE,config.xml,,,,,"BASE_URL=/config/base_url | ||
| DEFAULT_ADMIN_SET=/config/default_admin_set | ||
| COLLECTION_ID=/config/rw_collection_id | ||
| RO_COLLECTION_ID=/config/ro_collection_id | ||
| DENY_COLLECTION_ID=/config/deny_collection_id | ||
| API_KEY=/config/api_key | ||
| AUTH_KEY=/config/basic_auth",, | ||
| Check default admin set for id in feed and check if content url public,GET,$BASE_URL/sword/v2/collections/$DEFAULT_ADMIN_SET,"Api-key: $API_KEY | ||
| Content-type: application/xml",,,200,"temp/admin_get=* | ||
| CONTENT_URL_FIRST=(//r:content)[1]/@src | ||
| CONTENT_URL_LAST=(//r:content)[last()]/@src","*=//r:feed/r:id | ||
| True=contains((//r:content)[1]/@src, ""concern"")",r=http://www.w3.org/2005/Atom | ||
| Check entries describe themselves correctly i.e. content points to self id,FILE,temp/admin_get,,,,,,"True=count(//r:entry)=count((//r:entry)[contains(./r:content/@src, ./r:id)]) | ||
| True=count(//r:entry)=count(//r:entry[contains(./r:link[@rel=""edit""]/@href, ./r:id)])",r=http://www.w3.org/2005/Atom | ||
| Check feed describes itself correctly,FILE,temp/admin_get,,,,,,"True=contains(//r:feed/r:link[@rel=""edit""]/@href, /r:feed/r:id)",r=http://www.w3.org/2005/Atom | ||
| Check all entries that have child file sets have file set links,FILE,temp/admin_get,,,,,,"True=count(//r:entry/r:link[@rel=""edit-media""])=count(//r:entry/r:link[@rel=""edit-media""][contains(./@href, ""file_sets"")])",r=http://www.w3.org/2005/Atom |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| { | ||
| "Headers": ["Title","Method","URI","Headers", | ||
| "Form","Payload","Expected","Store","Test","NS"], | ||
| "steps": [ { | ||
| "Title": "Load Configuration File", | ||
| "Method": "FILE", | ||
| "URI": "config.xml" , | ||
| "Store": ["BASE_URL=/config/base_url", | ||
| "DEFAULT_ADMIN_SET=/config/default_admin_set", | ||
| "COLLECTION_ID=/config/rw_collection_id", | ||
| "RO_COLLECTION_ID=/config/ro_collection_id", | ||
| "DENY_COLLECTION_ID=/config/deny_collection_id", | ||
| "API_KEY=/config/api_key", | ||
| "AUTH_KEY=/config/basic_auth"] | ||
| }, | ||
| { | ||
| "Title": "Check default admin set for id in feed and check if content url public", | ||
| "Method": "GET", | ||
| "URI": "$BASE_URL/sword/v2/collections/$DEFAULT_ADMIN_SET", | ||
| "Headers": ["Api-key: $API_KEY", "Content-type: application/xml"], | ||
| "Expected": 200, | ||
| "Store": ["temp/admin_get=*", "CONTENT_URL_FIRST=(//r:content)[1]/@src", | ||
| "CONTENT_URL_LAST=(//r:content)[last()]/@src"], | ||
| "Test": ["*=//r:feed/r:id", "True=contains((//r:content)[1]/@src, \"concern\")"], | ||
| "NS": "r=http://www.w3.org/2005/Atom" | ||
| }, | ||
| { | ||
| "Title": "Check entries describe themselves correctly i.e. content points to self id", | ||
| "Method": "FILE", | ||
| "URI": "temp/admin_get", | ||
| "Test": ["True=count(//r:entry)=count((//r:entry)[contains(./r:content/@src, ./r:id)])", | ||
| "True=count(//r:entry)=count(//r:entry[contains(./r:link[@rel=\"edit\"]/@href, ./r:id)])"], | ||
| "NS": "r=http://www.w3.org/2005/Atom" | ||
| }, | ||
| { | ||
| "Title": "Check feed describes itself correctly", | ||
| "Method": "FILE", | ||
| "URI": "temp/admin_get", | ||
| "Test": ["True=contains(//r:feed/r:link[@rel=\"edit\"]/@href, /r:feed/r:id)"], | ||
| "NS": "r=http://www.w3.org/2005/Atom" | ||
| }, | ||
| { | ||
| "Title": "Check all entries that have child file sets have file set links", | ||
| "Method": "FILE", | ||
| "URI":"temp/admin_get", | ||
| "Test": ["True=count(//r:entry/r:link[@rel=\"edit-media\"])=count(//r:entry/r:link[@rel=\"edit-media\"][contains(./@href, \"file_sets\")])"], | ||
| "NS": "r=http://www.w3.org/2005/Atom" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| Title,Method,URI,Headers,Form,Payload,Expected,Store,Test,NS | ||
| Load Configuration File,FILE,config.xml,,,,,"BASE_URL=/config/base_url | ||
| DEFAULT_ADMIN_SET=/config/default_admin_set | ||
| COLLECTION_ID=/config/rw_collection_id | ||
| RO_COLLECTION_ID=/config/ro_collection_id | ||
| DENY_COLLECTION_ID=/config/deny_collection_id | ||
| API_KEY=/config/api_key",, | ||
| Check default admin set for id in feed,GET,$BASE_URL/sword/v2/collections/$DEFAULT_ADMIN_SET,"Api-key: $API_KEY | ||
| Content-type: application/xml",,,200,"temp/admin_get=* | ||
| WORK=(//r:link[contains(@href, ""works"")])[1]/@href | ||
| FILESET=(//r:link[contains(@href, ""file_sets"")])[1]/@href | ||
| FILEID=substring-after((//r:link[contains(@href, ""file_sets"")])[1]/@href, ""file_sets/"")",*=//r:feed/r:id,r=http://www.w3.org/2005/Atom | ||
| Check file root node for fileset is entry: GET,GET,$FILESET,"Api-key: $API_KEY | ||
| Content-type: application/xml",,,200,temp/example_fileset=*,entry=local-name(/*),r=http://www.w3.org/2005/Atom | ||
| Check file root node for work is entry: GET,GET,$WORK,"Api-key: $API_KEY | ||
| Content-type: application/xml",,,200,temp/example_work=*,entry=local-name(/*),r=http://www.w3.org/2005/Atom | ||
| Modify file metadata check file root node is entry: PUT,PUT,$FILESET,"Api-key: $API_KEY | ||
| Content-type: application/xml | ||
| Packaging: application/atom+xml;type=entry",,files/generic.full.xml,200,temp/example_work=*,entry=local-name(/*),r=http://www.w3.org/2005/Atom | ||
| Modify work metadata check work root node is entry: PUT,PUT,$WORK,"Api-key: $API_KEY | ||
| Content-type: application/xml | ||
| Packaging: application/atom+xml;type=entry",,files/generic.full.xml,200,temp/example_work=*,entry=local-name(/*),r=http://www.w3.org/2005/Atom | ||
| Post file metadata check work root node (POST),POST,$BASE_URL/sword/v2/collections/$DEFAULT_ADMIN_SET/works/,"Api-key: $API_KEY | ||
| Content-type: application/xml | ||
| Packaging: application/atom+xml;type=entry",,files/generic.minimal.xml,201,temp/work_submit=*,entry=local-name(/*),atom=http://www.w3.org/2005/Atom | ||
| Modify file metadata check file root node (POST),POST,$FILESET/$FILEID,"Api-key: $API_KEY | ||
| Content-type: application/xml | ||
| Packaging: application/atom+xml;type=entry",,files/generic.minimal.xml,201,temp/work_submit=*,entry=local-name(/*),atom=http://www.w3.org/2005/Atom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a simpler xpath would be
/resultroot/result.