-
Notifications
You must be signed in to change notification settings - Fork 20
/
README
176 lines (117 loc) · 6.4 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
==============
IIIF Validator
==============
.. image:: https://travis-ci.org/IIIF/image-validator.svg?branch=master
:target: https://travis-ci.org/IIIF/image-validator
.. image:: https://coveralls.io/repos/github/IIIF/image-validator/badge.svg?branch=master
:target: https://coveralls.io/github/IIIF/image-validator?branch=master
This validator supports the same validations that are available on the
`IIIF
<http://iiif.io/>`_ website at
`<http://iiif.io/api/image/validator/>`_.
Installation
------------
Installation from pypi
~~~~~~~~~~~~~~~~~~~~~~
The following should install scripts, library, and the necessary dependencies::
pip install iiif-validator
Manual installation
~~~~~~~~~~~~~~~~~~~
Installation from `source code
<https://github.com/IIIF/image-validator>` can de done with::
python setup.py install
which should install scripts, library, and the necessary dependencies. Note that ``setup.py`` includes directives to pin certain libraries to particular versions for compatibility.
The ``python-magic`` module requires ``libmagic`` which, on a mac, one can install with::
brew install libmagic
Command line validator, ``iiif-validate.py``
--------------------------------------------
Then for an image served at ``http://localhost:8000/prefix/image_id``
the validator can be run with::
iiif-validate.py -s localhost:8000 -p prefix -i image_id --version=2.0 -v
or similar to validate server with the test image. Use
``iiif-validate -h`` for parameter details.
Use with Travis CI
~~~~~~~~~~~~~~~~~~
To install dependencies for this code the following lines must
be present in the ``install:`` section of ``.travis.yml``::
install:
- sudo apt-get update
- sudo apt-get install libmagic-dev
- pip install iiif_validator
...
and then a single validation can be added to the commands under
the ``script:`` section of ``.travis.yml``. For example, to test a
server running with base URI ``http://localhost:8000/prefix`` with
image ``image_id1`` at version 1.1, level 1, one might use::
script:
...
- iiif-validate.py -s localhost:8000 -p prefix -i image_id1 --version=1.1 --level 1 --quiet
The ``iiif-validate.py`` script returns 0 exit code on success, non-zero
on failure, in order to work easily with Travis CI.
Running the validator server, ``iiif-validator.py``
---------------------------------------------------
The primary installation of the validator server is on the `IIIF
<http://iiif.io/>`_ website at
`<http://iiif.io/api/image/validator/>`_.
Stand-alone server
~~~~~~~~~~~~~~~~~~
The validator server runs at `<http://localhost:8080/>`_ by
default, the URI path is the test name and then the query
parameters give the details of the server and image to
be tested. The URI pattern is::
http://localhost:8080/{test_name}?server={server}&prefix={prefix}&identifer={id}&version={api_version}
As an example, if the test server <https://pypi.python.org/pypi/iiif> is installed and run locally::
easy_install iiif
iiif_testserver.py
which will set up a server at `<http://localhost:8000/>`_ and write the log of accesses to STDOUT. The one can run validation tests against this with requests like `<http://localhost:8080/info_json?server=localhost:8000&prefix=/2.0_pil_none&identifier=67352ccc-d1b0-11e1-89ae-279075081939.png&version=2.0>`_ which tests the `info.json` response and gives JSON output (pretty formatted here)::
{
"test": "info_json",
"status": "success",
"tests": ["required-field: width", "required-field: height", "type-is-int: height", "type-is-int: width", "required-field: @id", "type-is-uri: @id", "@id is correct URI", "required-field: @context", "correct-context", "required-field: protocol", "correct-protocol", "required-field: profile", "is-list", "profile-compliance", "is-list", "is-object", "required-field: scaleFactors", "required-field: width", "type-is-int: width"],
"url": ["http://localhost:8000/2.0_pil_none/67352ccc-d1b0-11e1-89ae-279075081939.png/info.json"],
"label": "Check Image Information"
}
and `<http://localhost:8080/rot_mirror?server=localhost:8000&prefix=/2.0_pil_none&identifier=67352ccc-d1b0-11e1-89ae-279075081939.png&version=2.0>`_ which tests mirroring and will give JSON output (again pretty formatted)::
{
"test": "rot_mirror",
"status": "success",
"tests": ["9,0:True", "0,9:True"],
"url": ["http://localhost:8000/2.0_pil_none/67352ccc-d1b0-11e1-89ae-279075081939.png/full/full/!0/default.jpg"],
"label": "Mirroring"
}
Validator server under WSGI
~~~~~~~~~~~~~~~~~~~~~~~~~~~
*need docs here*
Running with Vagrant
--------------------
For ease of development and local testing, you can provision a virtual machine using Vagrant. To start Vagrant, ssh in, and run the validator on a site::
vagrant up
vagrant ssh
cd /vagrant
./iiif-validate.py -h
./iiif-validate.py --scheme=https -s iiif.lib.ncsu.edu -p iiif --level=2 -i 67352ccc-d1b0-11e1-89ae-279075081939
In addition, the Vagrant configuration runs the validator as a WSGI application using ``mod_wsgi`` and Apache ``httpd``, accessible both from with the VM as well as the host machine at `<http://localhost:8080/>`_.
Running with Docker
--------------------
```
docker build -t image-validator . && docker run --rm --name image-validator -p 9001:80 image-validator:latest
```
Then navigate to:
http://localhost:9001/api/image/validator/service/id_basic?version=2.0&server=server&prefix=prefix&identifier=identifier
Editing this README
-------------------
This README is in reStructuredText and not gfm because that is what pypi will render. An editor like `<http://rst.ninjs.org/>`_ is useful for editing/checking interactively.
License
-------
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
See ``LICENSE.txt``.
Data included with this software, such as the test image files in the ``html`` directory, may be freely reused under `CC0
<https://creativecommons.org/publicdomain/zero/1.0/>`_