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

Updates for Fedora 6.5 #20

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions FedoraSearchTool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/bin/env python

import TestConstants as TC
import requests


class FedoraSearchTool(object):

max_results = None
offset = None
order_by = None
order = None
baseUri = None
fields = list()
conditions = list()
authz = None

def __init__(self, base, authz):
self.authz = authz
self.baseUri = base

@staticmethod
def create(base_uri, calling_class):
"""
Create a FedoraSearchTool instance
:param base_uri: The base uri of the fedora instance.
:param calling_class: The test class this is used in to get the authorization
:return: FedoraSearchTool
"""
return FedoraSearchTool(base_uri, calling_class.get_auth(True))

def clear(self):
"""
Clear all search parameters.
:return: void
"""
self.fields = list()
self.conditions = list()
self.max_results = None
self.offset = None
self.order_by = None
self.order = None

def add_field(self, field):
"""
Add a field to return in the search results.
:param field: The field
:return: void
"""
if field not in self.fields:
self.fields.append(field)

def add_condition(self, field, operator, value):
"""
Add a condition to the search
:param field: The field to search against.
:param operator: The operator to use in the search.
:param value: The value to compare (operator) against the field
:return: void
"""
new_condition = field + operator + value
if new_condition not in self.conditions:
self.conditions.append(new_condition)

def set_max_results(self, count):
"""
Set the max results.
:param count: Max results.
:return: void
"""
self.max_results = count

def set_order_by(self, field):
"""
Set the field to order by.
:param field: The field.
:return: void
"""
self.order_by = field

def set_order(self, order):
"""
Set the order to use with the order_by field.
:param order: Order
:return: void
TODO: Should use an enum of some sort.
"""
self.order = order

def set_offset(self, offset):
"""
Set the offset.
:param offset: The offset.
:return: void
"""
self.offset = offset

def do_query(self):
"""
Perform the search.
:return: Response object.
"""
parameters = {}
for condition in self.conditions:
if 'condition' in parameters:
try:
parameters['condition'].append(condition)
except AttributeError:
tmp = parameters['condition']
parameters['condition'] = [tmp]
parameters['condition'].append(condition)
else:
parameters['condition'] = condition

if len(self.fields) > 0:
parameters['fields'] = ",".join(self.fields)
if self.max_results is not None:
parameters['max_results'] = self.max_results
if self.offset is not None:
parameters['offset'] = self.offset
if self.order_by is not None:
parameters['order_by'] = self.order_by
if self.order is not None:
parameters['order'] = self.order

return requests.get(self.baseUri + "/" + TC.FCR_SEARCH, auth=self.authz, params=parameters)
115 changes: 96 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
# Fedora 4 Tests
# Fedora Tests

These python tests are meant to be run against a standalone Fedora 4 instance.
These python tests are meant to be run against a standalone Fedora instance.

This will create, update and delete resources in the repository. So you may **not** want to use it on a production instance.

Also, this is doing a cursory test. It does some verification of RDF, and patches are always welcome.

Note: in order to test authorization, please first verify that your Fedora repository in configured to use authorization.
Check the `repository.json` in use, and verify that the `security` block contains a `providers` list such as:

"providers" : [
{ "classname" : "org.fcrepo.auth.common.ServletContainerAuthenticationProvider" }
]
Note: in order to test authorization, please see [this note](#authz-tests)

## Installation

Expand Down Expand Up @@ -68,6 +63,8 @@ second_site:
password1: password1
user2: user2
password2: password2
solrurl: http://someserver:8080/solr
triplestoreurl: http://someserver:8080/fuseki/test/sparql
```

To use the `second_site` configuration, simply start the testrunner with
Expand All @@ -80,13 +77,16 @@ If a configuration cannot be found or the `-n|--site_name` argument is not prese
### Isolate tests
You can also choose to run only a subset of all tests using the `-t|--tests` argument. It accepts a comma separated list
of the following values which indicate which tests to run.
* `authz` - Authorization tests
* `archivalgroup` - Archival Group tests
* `authz` - Authorization tests (see [note](#authz-tests))
* `basic` - Basic interaction tests
* `sparql` - Sparql operation tests
* `camel` - Camel toolbox tests (see [note](#camel-tests))
* `fixity` - Binary fixity tests
* `indirect` - Direct/Indirect container tests
* `rdf` - RDF serialization tests
* `version` - Versioning tests
* `sparql` - Sparql operation tests
* `transaction` - Transcation tests
* `fixity` - Binary fixity tests
* `version` - Versioning tests

Without this parameter all the above tests will be run.

Expand All @@ -95,8 +95,35 @@ To run only the `authz` and `sparql` tests you would execute:
./testrunner.py -c config.yml -t authz,sparql
```

##### Camel Tests
`camel` tests are **NOT** executed by default, due to timing issues they should be run separately.

They also require the configuration to have a `solrurl` parameter pointing to a Solr endpoint and a
`triplestoreurl` parameter pointing to the SPARQL endpoint of a triplestore.

Both of these systems must be fed by the fcrepo-camel-toolbox for this testing.

##### AuthZ tests
`authz` tests will require authz to be enabled on your Fedora, as well you will need to set the
following properties for your Fedora or the test `testGroupAuth` will fail.
```commandline
fcrepo.auth.webac.userAgent.baseUri=http://example.com/
fcrepo.auth.webac.groupAgent.baseUri=http://example.com/
```


## Tests implemented

**Note**: this list is out of date, you are better to view the tests in the various test classes.

### archivalgroup
1. Create an archivalgroup container
1. Create an archivalgroup member, delete it and it's tombstone
1. Create an archivalgroup member, delete it and PUT over the tombstone
1. Try to PUT over an archivalgroup member tombstone with a different interaction model
1. Create and delete an archivalgroup, delete it's tombstone.
1. Create and delete an archivalgroup, and PUT over the tombstone

### authz
1. Create a container called **cover**
1. Patch it to a pcdm:Object
Expand All @@ -108,6 +135,34 @@ To run only the `authz` and `sparql` tests you would execute:
1. Verify regular user 1 can access **cover**
1. Verify regular user 2 can't access **cover**


1. Create a container that is readonly for regular user 1
1. Create a container that regular user 1 has read/write access to.
1. Verify that regular user 1 can create/edit/append the container
1. Verify that regular user 1 cannot create a direct or indirect container
that targets the read-only container as the membership resource.


1. Create a container
1. Add an acl with multiple authorizations for user 1
1. Verify that user 1 receives the most permissive set of permissions
from the authorizations


1. Verify that the `rel="acl"` link header is the same for:
* a binary
* its description
* the binary timemap
* the description timemap
* a binary memento
* a description memento


1. Verify that both a binary and its description share the permissions give
to the binary.



### basic
1. Create a container
1. Create a container inside the container from step 1
Expand All @@ -121,11 +176,39 @@ To run only the `authz` and `sparql` tests you would execute:
1. Create a LDP Indirect container
1. Validate the correct Link header type


1. Create a basic container
1. Create an indirect container
1. Create a direct container
1. Create a NonRDFSource
1. Try to create a ldp:Resource (not allowed)
1. Try to create a ldp:Container (not allowed)


1. Try to change each of the following (basic, direct, indirect container
and binary) to all other types.

### camel - see [note](#camel-tests)
1. Create a container
1. Check the container is indexed to Solr
1. Check the container is indexed to the triplestore

### fixity
1. Create a binary resource
1. Get a fixity result for that resource
1. Compare that the SHA-1 hash matches the expected value

### indirect
1. Create a pcdm:Object
2. Create a pcdm:Collection
3. Create an indirect container "members" inside the pcdm:Collection
4. Create a proxy object for the pcdm:Object inside the **members** indirectContainer
5. Verify that the pcdm:Collection has the memberRelation property added pointing to the pcdm:Object

### rdf
1. Create a RDFSource object.
1. Retrieve that object in all possible RDF serializations.

### sparql
1. Create a container
1. Set the dc:title of the container with a Patch request
Expand All @@ -137,7 +220,7 @@ To run only the `authz` and `sparql` tests you would execute:
1. Verify the title
1. Create a container
1. Update the title to text with Unicode characters
1. Verify the title
1. Verify the title

### transaction
1. Create a transaction
Expand Down Expand Up @@ -170,9 +253,3 @@ To run only the `authz` and `sparql` tests you would execute:
1. Create Memento at deleted memento's datetime
1. Verify Memento exists

### indirect
1. Create a pcdm:Object
2. Create a pcdm:Collection
3. Create an indirect container "members" inside the pcdm:Collection
4. Create a proxy object for the pcdm:Object inside the **members** indirectContainer
5. Verify that the pcdm:Collection has the memberRelation property added pointing to the pcdm:Object
Loading