Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
from .base_config_test import BaseConfigTest, CollsDirMixin, fmod
|
2016-11-11 10:30:48 -08:00
|
|
|
|
2015-03-13 19:53:50 -07:00
|
|
|
import os
|
|
|
|
import tempfile
|
|
|
|
import shutil
|
2015-03-15 21:20:00 -07:00
|
|
|
import sys
|
2015-03-13 19:53:50 -07:00
|
|
|
|
|
|
|
import webtest
|
|
|
|
|
2015-03-22 17:55:38 -07:00
|
|
|
import time
|
2016-11-11 10:30:48 -08:00
|
|
|
import gevent
|
2015-03-22 17:55:38 -07:00
|
|
|
|
2016-02-23 13:26:53 -08:00
|
|
|
from six import StringIO
|
2015-03-15 21:20:00 -07:00
|
|
|
|
2017-04-29 13:47:54 -07:00
|
|
|
import webtest
|
2017-04-26 12:12:34 -07:00
|
|
|
from pytest import raises
|
|
|
|
from mock import patch
|
|
|
|
|
|
|
|
from pywb import get_test_dir
|
2017-09-21 22:12:57 -07:00
|
|
|
from pywb.warcserver.test.testutils import BaseTestClass
|
2017-04-26 12:12:34 -07:00
|
|
|
|
2017-09-21 22:12:57 -07:00
|
|
|
from pywb.manager.autoindex import AutoIndexer
|
|
|
|
from pywb.manager.manager import main
|
2015-03-22 23:03:39 -07:00
|
|
|
|
2017-05-23 19:08:29 -07:00
|
|
|
from pywb.indexer.cdxindexer import main as cdxindexer_main
|
|
|
|
from pywb.warcserver.index.cdxobject import CDXObject
|
2015-03-19 20:52:00 -07:00
|
|
|
|
2017-05-23 19:08:29 -07:00
|
|
|
from pywb.apps.frontendapp import FrontEndApp
|
2015-03-13 19:53:50 -07:00
|
|
|
|
|
|
|
|
2015-03-16 18:48:09 -07:00
|
|
|
#=============================================================================
|
|
|
|
ARCHIVE_DIR = 'archive'
|
|
|
|
INDEX_DIR = 'indexes'
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
COLLECTIONS = '_test_colls'
|
|
|
|
|
2015-03-19 13:41:48 -07:00
|
|
|
INDEX_FILE = 'index.cdxj'
|
2015-03-22 17:55:38 -07:00
|
|
|
AUTOINDEX_FILE = 'autoindex.cdxj'
|
2015-03-19 13:41:48 -07:00
|
|
|
|
2015-03-16 18:48:09 -07:00
|
|
|
|
2015-03-13 19:53:50 -07:00
|
|
|
#=============================================================================
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
class TestManagedColls(CollsDirMixin, BaseConfigTest):
|
|
|
|
@classmethod
|
|
|
|
def setup_class(cls):
|
|
|
|
super(TestManagedColls, cls).setup_class('config_test.yaml')
|
|
|
|
|
2015-03-13 19:53:50 -07:00
|
|
|
def _check_dirs(self, base, dirlist):
|
|
|
|
for dir_ in dirlist:
|
|
|
|
assert os.path.isdir(os.path.join(base, dir_))
|
|
|
|
|
2015-03-16 18:48:09 -07:00
|
|
|
def _get_sample_warc(self, name):
|
|
|
|
return os.path.join(get_test_dir(), 'warcs', name)
|
|
|
|
|
2016-12-09 16:46:33 -08:00
|
|
|
@patch('pywb.apps.cli.BaseCli.run_gevent', lambda *args, **kwargs: None)
|
2015-03-22 21:50:56 -07:00
|
|
|
def test_run_cli(self):
|
|
|
|
""" test new wayback cli interface
|
2015-03-22 23:03:39 -07:00
|
|
|
test autoindex error before collections inited
|
2015-03-22 21:50:56 -07:00
|
|
|
"""
|
|
|
|
from pywb.apps.cli import wayback
|
2015-10-23 11:53:28 -07:00
|
|
|
|
2017-03-12 12:21:54 -07:00
|
|
|
wayback(['-p', '0'])
|
2015-03-22 21:50:56 -07:00
|
|
|
|
2015-03-22 23:03:39 -07:00
|
|
|
# Nothing to auto-index.. yet
|
|
|
|
with raises(SystemExit):
|
2017-03-12 12:21:54 -07:00
|
|
|
wayback(['-a', '-p', '0'])
|
2015-03-22 23:03:39 -07:00
|
|
|
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
colls = os.path.join(self.root_dir, COLLECTIONS)
|
2015-03-22 23:03:39 -07:00
|
|
|
os.mkdir(colls)
|
|
|
|
|
2017-09-21 22:12:57 -07:00
|
|
|
wayback(['-a', '-p', '0', '--auto-interval', '0'])
|
2015-03-22 23:03:39 -07:00
|
|
|
|
2015-03-13 19:53:50 -07:00
|
|
|
def test_create_first_coll(self):
|
2015-03-14 14:56:15 -07:00
|
|
|
""" Test first collection creation, with all required dirs
|
|
|
|
"""
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['init', 'test'])
|
2015-03-13 19:53:50 -07:00
|
|
|
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
colls = os.path.join(self.root_dir, COLLECTIONS)
|
2015-03-13 19:53:50 -07:00
|
|
|
assert os.path.isdir(colls)
|
|
|
|
|
|
|
|
test = os.path.join(colls, 'test')
|
|
|
|
assert os.path.isdir(test)
|
|
|
|
|
2015-03-16 18:48:09 -07:00
|
|
|
self._check_dirs(test, [INDEX_DIR, ARCHIVE_DIR, 'static', 'templates'])
|
2015-03-13 19:53:50 -07:00
|
|
|
|
|
|
|
def test_add_warcs(self):
|
2015-03-14 14:56:15 -07:00
|
|
|
""" Test adding warc to new coll, check replay
|
|
|
|
"""
|
2015-03-16 18:48:09 -07:00
|
|
|
warc1 = self._get_sample_warc('example.warc.gz')
|
2015-03-13 19:53:50 -07:00
|
|
|
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['add', 'test', warc1])
|
2015-03-13 19:53:50 -07:00
|
|
|
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
def test_add_warcs_replay(self, fmod):
|
|
|
|
resp = self.get('/test/20140103030321{0}/http://example.com/?example=1', fmod)
|
2015-03-13 19:53:50 -07:00
|
|
|
assert resp.status_int == 200
|
|
|
|
|
2015-03-14 14:56:15 -07:00
|
|
|
def test_another_coll(self):
|
|
|
|
""" Test adding warc to a new coll, check replay
|
|
|
|
"""
|
2015-03-16 18:48:09 -07:00
|
|
|
warc1 = self._get_sample_warc('example.warc.gz')
|
2015-03-14 14:56:15 -07:00
|
|
|
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['init', 'foo'])
|
2015-03-14 14:56:15 -07:00
|
|
|
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['add', 'foo', warc1])
|
2015-03-14 14:56:15 -07:00
|
|
|
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
def test_another_coll_replay(self, fmod):
|
|
|
|
resp = self.get('/foo/20140103030321{0}/http://example.com/?example=1', fmod)
|
2015-03-14 14:56:15 -07:00
|
|
|
assert resp.status_int == 200
|
|
|
|
|
2015-03-13 19:53:50 -07:00
|
|
|
def test_add_more_warcs(self):
|
2015-03-14 14:56:15 -07:00
|
|
|
""" Test adding additional warcs, check replay of added content
|
|
|
|
"""
|
2015-03-16 18:48:09 -07:00
|
|
|
warc1 = self._get_sample_warc('iana.warc.gz')
|
|
|
|
warc2 = self._get_sample_warc('example-extra.warc')
|
2015-03-13 19:53:50 -07:00
|
|
|
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['add', 'test', warc1, warc2])
|
2015-03-13 19:53:50 -07:00
|
|
|
|
|
|
|
# Spurrious file in collections
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
with open(os.path.join(self.root_dir, COLLECTIONS, 'blah'), 'w+b') as fh:
|
2016-02-23 13:26:53 -08:00
|
|
|
fh.write(b'foo\n')
|
2015-03-13 19:53:50 -07:00
|
|
|
|
|
|
|
with raises(IOError):
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['add', 'test', 'non-existent-file.warc.gz'])
|
2015-03-13 19:53:50 -07:00
|
|
|
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
def test_add_more_warcs_replay(self, fmod):
|
2015-03-14 14:56:15 -07:00
|
|
|
# check new cdx
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
resp = self.get('/test/20140126200624{0}/http://www.iana.org/', fmod)
|
2015-03-14 14:56:15 -07:00
|
|
|
assert resp.status_int == 200
|
|
|
|
|
|
|
|
def test_add_custom_nested_warcs(self):
|
|
|
|
""" Test recursive indexing of custom created WARC hierarchy,
|
|
|
|
warcs/A/..., warcs/B/sub/...
|
|
|
|
Ensure CDX is relative to root archive dir, test replay
|
|
|
|
"""
|
|
|
|
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['init', 'nested'])
|
2015-03-14 14:56:15 -07:00
|
|
|
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
nested_root = os.path.join(self.root_dir, COLLECTIONS, 'nested', ARCHIVE_DIR)
|
2015-03-14 14:56:15 -07:00
|
|
|
nested_a = os.path.join(nested_root, 'A')
|
|
|
|
nested_b = os.path.join(nested_root, 'B', 'sub')
|
|
|
|
|
|
|
|
os.makedirs(nested_a)
|
|
|
|
os.makedirs(nested_b)
|
|
|
|
|
2015-03-16 18:48:09 -07:00
|
|
|
warc1 = self._get_sample_warc('iana.warc.gz')
|
|
|
|
warc2 = self._get_sample_warc('example.warc.gz')
|
2015-03-14 14:56:15 -07:00
|
|
|
|
|
|
|
shutil.copy2(warc1, nested_a)
|
|
|
|
shutil.copy2(warc2, nested_b)
|
|
|
|
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['index',
|
2015-03-14 14:56:15 -07:00
|
|
|
'nested',
|
|
|
|
os.path.join(nested_a, 'iana.warc.gz'),
|
|
|
|
os.path.join(nested_b, 'example.warc.gz')
|
|
|
|
])
|
|
|
|
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
nested_cdx = os.path.join(self.root_dir, COLLECTIONS, 'nested', INDEX_DIR, INDEX_FILE)
|
2015-03-14 14:56:15 -07:00
|
|
|
with open(nested_cdx) as fh:
|
|
|
|
nested_cdx_index = fh.read()
|
|
|
|
|
2015-03-19 13:29:29 -07:00
|
|
|
assert '1043' in nested_cdx_index
|
|
|
|
assert '333' in nested_cdx_index
|
|
|
|
assert 'B/sub/example.warc.gz' in nested_cdx_index
|
|
|
|
|
|
|
|
assert '2258' in nested_cdx_index
|
|
|
|
assert '334' in nested_cdx_index
|
|
|
|
assert 'A/iana.warc.gz' in nested_cdx_index
|
2015-03-13 19:53:50 -07:00
|
|
|
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
def test_nested_replay(self, fmod):
|
|
|
|
resp = self.get('/nested/20140126200624{0}/http://www.iana.org/', fmod)
|
2015-03-14 14:56:15 -07:00
|
|
|
assert resp.status_int == 200
|
|
|
|
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
resp = self.get('/nested/20140103030321{0}/http://example.com/?example=1', fmod)
|
2015-03-13 19:53:50 -07:00
|
|
|
assert resp.status_int == 200
|
|
|
|
|
2015-03-14 14:56:15 -07:00
|
|
|
def test_merge_vs_reindex_equality(self):
|
|
|
|
""" Test full reindex vs merged update when adding warcs
|
|
|
|
to ensure equality of indexes
|
|
|
|
"""
|
|
|
|
# ensure merged index is same as full reindex
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
coll_dir = os.path.join(self.root_dir, COLLECTIONS, 'test', INDEX_DIR)
|
2015-03-19 13:41:48 -07:00
|
|
|
orig = os.path.join(coll_dir, INDEX_FILE)
|
2015-03-14 14:56:15 -07:00
|
|
|
bak = os.path.join(coll_dir, 'index.bak')
|
|
|
|
|
|
|
|
shutil.copy(orig, bak)
|
|
|
|
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['reindex', 'test'])
|
2015-03-14 14:56:15 -07:00
|
|
|
|
|
|
|
with open(orig) as orig_fh:
|
|
|
|
merged_cdx = orig_fh.read()
|
|
|
|
|
|
|
|
with open(bak) as bak_fh:
|
|
|
|
reindex_cdx = bak_fh.read()
|
|
|
|
|
|
|
|
assert len(reindex_cdx.splitlines()) == len(merged_cdx.splitlines())
|
|
|
|
assert merged_cdx == reindex_cdx
|
|
|
|
|
2015-03-13 19:53:50 -07:00
|
|
|
def test_add_static(self):
|
2015-03-14 14:56:15 -07:00
|
|
|
""" Test adding static file to collection, check access
|
|
|
|
"""
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
a_static = os.path.join(self.root_dir, COLLECTIONS, 'test', 'static', 'abc.js')
|
2015-03-13 19:53:50 -07:00
|
|
|
|
|
|
|
with open(a_static, 'w+b') as fh:
|
2016-02-23 13:26:53 -08:00
|
|
|
fh.write(b'/* Some JS File */')
|
2015-03-13 19:53:50 -07:00
|
|
|
|
2017-04-26 12:12:34 -07:00
|
|
|
resp = self.testapp.get('/static/_/test/abc.js')
|
2015-03-13 19:53:50 -07:00
|
|
|
assert resp.status_int == 200
|
|
|
|
assert resp.content_type == 'application/javascript'
|
2016-02-23 13:26:53 -08:00
|
|
|
resp.charset = 'utf-8'
|
|
|
|
assert '/* Some JS File */' in resp.text
|
2015-03-13 19:53:50 -07:00
|
|
|
|
2015-03-17 19:05:39 -07:00
|
|
|
def test_add_shared_static(self):
|
|
|
|
""" Test adding shared static file to root static/ dir, check access
|
|
|
|
"""
|
|
|
|
a_static = os.path.join(self.root_dir, 'static', 'foo.css')
|
|
|
|
|
|
|
|
with open(a_static, 'w+b') as fh:
|
2016-02-23 13:26:53 -08:00
|
|
|
fh.write(b'/* Some CSS File */')
|
2015-03-17 19:05:39 -07:00
|
|
|
|
2017-04-26 12:12:34 -07:00
|
|
|
resp = self.testapp.get('/static/foo.css')
|
2015-03-17 19:05:39 -07:00
|
|
|
assert resp.status_int == 200
|
|
|
|
assert resp.content_type == 'text/css'
|
2016-02-23 13:26:53 -08:00
|
|
|
resp.charset = 'utf-8'
|
|
|
|
assert '/* Some CSS File */' in resp.text
|
2015-03-17 19:05:39 -07:00
|
|
|
|
2015-03-15 21:20:00 -07:00
|
|
|
def test_add_title_metadata_index_page(self):
|
|
|
|
""" Test adding title metadata to a collection, test
|
|
|
|
retrieval on default index page
|
|
|
|
"""
|
|
|
|
main(['metadata', 'foo', '--set', 'title=Collection Title'])
|
|
|
|
|
|
|
|
resp = self.testapp.get('/')
|
|
|
|
assert resp.status_int == 200
|
|
|
|
assert resp.content_type == 'text/html'
|
2016-02-23 13:26:53 -08:00
|
|
|
resp.charset = 'utf-8'
|
|
|
|
assert '(Collection Title)' in resp.text
|
2015-03-15 21:20:00 -07:00
|
|
|
|
2017-04-26 12:12:34 -07:00
|
|
|
# test cache
|
|
|
|
resp = self.testapp.get('/')
|
|
|
|
resp.charset = 'utf-8'
|
|
|
|
assert '(Collection Title)' in resp.text
|
|
|
|
|
2015-03-15 21:20:00 -07:00
|
|
|
def test_other_metadata_search_page(self):
|
|
|
|
main(['metadata', 'foo', '--set',
|
|
|
|
'desc=Some Description Text',
|
|
|
|
'other=custom value'])
|
|
|
|
|
|
|
|
with raises(ValueError):
|
|
|
|
main(['metadata', 'foo', '--set', 'name_only'])
|
|
|
|
|
|
|
|
resp = self.testapp.get('/foo/')
|
2016-02-23 13:26:53 -08:00
|
|
|
resp.charset = 'utf-8'
|
2015-03-15 21:20:00 -07:00
|
|
|
assert resp.status_int == 200
|
|
|
|
assert resp.content_type == 'text/html'
|
|
|
|
|
2016-02-23 13:26:53 -08:00
|
|
|
assert 'Collection Title' in resp.text
|
2015-03-15 21:20:00 -07:00
|
|
|
|
2016-02-23 13:26:53 -08:00
|
|
|
assert 'desc' in resp.text
|
|
|
|
assert 'Some Description Text' in resp.text
|
2015-03-15 21:20:00 -07:00
|
|
|
|
2016-02-23 13:26:53 -08:00
|
|
|
assert 'other' in resp.text
|
|
|
|
assert 'custom value' in resp.text
|
2015-03-15 21:20:00 -07:00
|
|
|
|
2015-03-14 14:56:15 -07:00
|
|
|
def test_custom_template_search(self):
|
|
|
|
""" Test manually added custom search template search.html
|
|
|
|
"""
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
custom_search = os.path.join(self.root_dir, COLLECTIONS, 'test',
|
|
|
|
'templates', 'search.html')
|
2015-03-13 19:53:50 -07:00
|
|
|
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
with open(custom_search, 'w+b') as fh:
|
2016-02-23 13:26:53 -08:00
|
|
|
fh.write(b'pywb custom search page')
|
2015-03-13 19:53:50 -07:00
|
|
|
|
|
|
|
resp = self.testapp.get('/test/')
|
2016-02-23 13:26:53 -08:00
|
|
|
resp.charset = 'utf-8'
|
2015-03-13 19:53:50 -07:00
|
|
|
assert resp.status_int == 200
|
|
|
|
assert resp.content_type == 'text/html'
|
2016-02-23 13:26:53 -08:00
|
|
|
assert 'pywb custom search page' in resp.text
|
2015-03-13 19:53:50 -07:00
|
|
|
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
def test_add_custom_banner(self):
|
2022-09-26 19:49:38 -07:00
|
|
|
""" Test adding custom_banner.html per-collection template
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
"""
|
|
|
|
|
|
|
|
banner_file = os.path.join(self.root_dir, COLLECTIONS, 'test',
|
2022-09-26 19:49:38 -07:00
|
|
|
'templates', 'custom_banner.html')
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
|
|
|
|
with open(banner_file, 'w+b') as fh:
|
|
|
|
fh.write(b'<div>Custom Banner Here!</div>')
|
2019-10-27 01:39:52 +01:00
|
|
|
fh.write(b'\n{{ metadata | tojson }}')
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
|
2022-09-26 19:49:38 -07:00
|
|
|
def test_add_custom_banner_replay(self):
|
|
|
|
"""Test custom banner appears in unframed replay."""
|
|
|
|
resp = self.get('/test/20140103030321/http://example.com/?example=1', None)
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
assert '<div>Custom Banner Here!</div>' in resp.text
|
|
|
|
|
2017-04-26 12:12:34 -07:00
|
|
|
def test_more_custom_templates(self):
|
|
|
|
"""
|
|
|
|
Test custom templates and metadata
|
2015-03-15 22:23:08 -07:00
|
|
|
Template is relative to collection-specific dir
|
|
|
|
Add custom metadata and test its presence in custom search page
|
2015-03-14 14:56:15 -07:00
|
|
|
"""
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
custom_search = os.path.join(self.root_dir, COLLECTIONS, 'test',
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
'templates', 'search.html')
|
2015-03-15 22:23:08 -07:00
|
|
|
|
|
|
|
# add metadata
|
|
|
|
main(['metadata', 'test', '--set', 'some=value'])
|
2015-03-14 14:56:15 -07:00
|
|
|
|
|
|
|
with open(custom_search, 'w+b') as fh:
|
2017-04-26 12:12:34 -07:00
|
|
|
fh.write(b'overriden search page: ')
|
|
|
|
fh.write(b'{{ metadata | tojson }}\n')
|
2015-03-14 14:56:15 -07:00
|
|
|
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
# force clear of jinja env cache to reload
|
|
|
|
self.app.rewriterapp.jinja_env.jinja_env.cache = {}
|
|
|
|
|
2015-03-14 14:56:15 -07:00
|
|
|
resp = self.testapp.get('/test/')
|
2016-02-23 13:26:53 -08:00
|
|
|
resp.charset = 'utf-8'
|
2015-03-14 14:56:15 -07:00
|
|
|
assert resp.status_int == 200
|
|
|
|
assert resp.content_type == 'text/html'
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
assert 'overriden search page: ' in resp.text
|
2021-06-14 17:09:00 -07:00
|
|
|
#assert '"some":"value"' in resp.text, resp.text
|
|
|
|
assert '{"some":"value"}' in resp.text, resp.text
|
2015-03-15 22:23:08 -07:00
|
|
|
|
2022-09-26 19:49:38 -07:00
|
|
|
def test_replay_banner_metadata(self):
|
|
|
|
"""Test adding metadata in custom banner for unframed replay."""
|
|
|
|
resp = self.get('/test/20140103030321/http://example.com/?example=1', None)
|
2019-10-27 01:39:52 +01:00
|
|
|
assert '<div>Custom Banner Here!</div>' in resp.text
|
2021-06-14 17:09:00 -07:00
|
|
|
#assert '"some":"value"' in resp.text
|
|
|
|
assert '{"some":"value"}' in resp.text, resp.text
|
2019-10-27 01:39:52 +01:00
|
|
|
|
Frame insert refactor (#246)
refactor frame/head insert templates:
ContentFrame:
- content iframe inited with new ContentFrame() which creates iframe
- wb_frame.js: contains ContentFrame system for initing, updating, closing content frame for replayed content.
- wb_frame.js: supports 'app_prefix' and 'content_prefix' or default 'prefix' for replay content
- window.location.hash passed added to init url.
- frame insert and head insert: simplify, remove 'wbrequest'
- frame insert: global wbinfo object no longer needed in top frame, each ContentFrame self-contained.
- wombat.js: next_parent() check does not assume wbinfo is present in top frame
- vidrw.js: only init if wbinfo is present
Banner:
- wb.js no longer needed, frame check/redirect folded into wombat.js
- default banner self-contained in default_banner.js/default_banner.css, handles both frame and frameless case
- rename wb.css -> default_banner.css
- banner html passed in as 'banner_html' variable to be optionally included, supports per collection banner html.
- templateview: BaseInsertView can accept an option 'banner view', used by HeadInsertView and TopFrameView
Tests:
- tests: test_auto_colls uses shared app to test dynamic changes, testing both frame and non-frame access, added per-collection banner html check.
2017-09-30 21:09:38 -07:00
|
|
|
def test_more_custom_templates_replay(self, fmod):
|
|
|
|
resp = self.get('/test/20140103030321{0}/http://example.com/?example=1', fmod)
|
2015-03-15 22:23:08 -07:00
|
|
|
assert resp.status_int == 200
|
2015-03-14 14:56:15 -07:00
|
|
|
|
2015-03-16 19:57:28 -07:00
|
|
|
def test_add_default_coll_templates(self):
|
|
|
|
""" Test add default templates: collection,
|
2015-03-16 16:53:24 -07:00
|
|
|
and overwrite collection template
|
|
|
|
"""
|
|
|
|
# list
|
|
|
|
main(['template', 'foo', '--list'])
|
|
|
|
|
|
|
|
# Add collection template
|
|
|
|
main(['template', 'foo', '--add', 'query_html'])
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
assert os.path.isfile(os.path.join(self.root_dir, COLLECTIONS, 'foo', 'templates', 'query.html'))
|
2015-03-16 16:53:24 -07:00
|
|
|
|
|
|
|
# overwrite -- force
|
|
|
|
main(['template', 'foo', '--add', 'query_html', '-f'])
|
|
|
|
|
2015-03-16 19:57:28 -07:00
|
|
|
def test_add_modify_home_template(self):
|
|
|
|
# Add shared template
|
|
|
|
main(['template', '--add', 'home_html'])
|
|
|
|
|
|
|
|
filename = os.path.join(self.root_dir, 'templates', 'index.html')
|
|
|
|
assert os.path.isfile(filename)
|
|
|
|
|
|
|
|
with open(filename, 'r+b') as fh:
|
|
|
|
buf = fh.read()
|
2019-03-08 16:11:07 -08:00
|
|
|
buf = buf.replace(b'Pywb Wayback Machine', b'Custom Test Homepage')
|
2015-03-16 19:57:28 -07:00
|
|
|
fh.seek(0)
|
|
|
|
fh.write(buf)
|
|
|
|
|
|
|
|
resp = self.testapp.get('/')
|
2016-02-23 13:26:53 -08:00
|
|
|
resp.charset = 'utf-8'
|
2015-03-16 19:57:28 -07:00
|
|
|
assert resp.content_type == 'text/html'
|
2019-03-08 16:11:07 -08:00
|
|
|
assert 'Custom Test Homepage' in resp.text, resp.text
|
2015-03-16 19:57:28 -07:00
|
|
|
|
2015-03-16 16:53:24 -07:00
|
|
|
@patch('pywb.manager.manager.get_input', lambda x: 'y')
|
|
|
|
def test_add_template_input_yes(self):
|
|
|
|
""" Test answer 'yes' to overwrite
|
|
|
|
"""
|
|
|
|
main(['template', 'foo', '--add', 'query_html'])
|
|
|
|
|
|
|
|
|
|
|
|
@patch('pywb.manager.manager.get_input', lambda x: 'n')
|
|
|
|
def test_add_template_input_no(self):
|
|
|
|
""" Test answer 'no' to overwrite
|
|
|
|
"""
|
|
|
|
with raises(IOError):
|
|
|
|
main(['template', 'foo', '--add', 'query_html'])
|
|
|
|
|
|
|
|
@patch('pywb.manager.manager.get_input', lambda x: 'other')
|
|
|
|
def test_add_template_input_other(self):
|
|
|
|
""" Test answer 'other' to overwrite
|
|
|
|
"""
|
|
|
|
with raises(IOError):
|
|
|
|
main(['template', 'foo', '--add', 'query_html'])
|
|
|
|
|
|
|
|
@patch('pywb.manager.manager.get_input', lambda x: 'no')
|
|
|
|
def test_remove_not_confirm(self):
|
|
|
|
""" Test answer 'no' to remove
|
|
|
|
"""
|
|
|
|
# don't remove -- not confirmed
|
|
|
|
with raises(IOError):
|
|
|
|
main(['template', 'foo', '--remove', 'query_html'])
|
|
|
|
|
|
|
|
@patch('pywb.manager.manager.get_input', lambda x: 'yes')
|
|
|
|
def test_remove_confirm(self):
|
|
|
|
# remove -- confirm
|
|
|
|
main(['template', 'foo', '--remove', 'query_html'])
|
|
|
|
|
2015-03-13 19:53:50 -07:00
|
|
|
def test_no_templates(self):
|
2015-03-14 14:56:15 -07:00
|
|
|
""" Test removing templates dir, using default template again
|
|
|
|
"""
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
shutil.rmtree(os.path.join(self.root_dir, COLLECTIONS, 'foo', 'templates'))
|
2015-03-13 19:53:50 -07:00
|
|
|
|
2015-03-15 22:23:08 -07:00
|
|
|
resp = self.testapp.get('/foo/')
|
2016-02-23 13:26:53 -08:00
|
|
|
resp.charset = 'utf-8'
|
2015-03-13 19:53:50 -07:00
|
|
|
assert resp.status_int == 200
|
|
|
|
assert resp.content_type == 'text/html'
|
2016-02-23 13:26:53 -08:00
|
|
|
assert 'pywb custom search page' not in resp.text
|
2015-03-13 19:53:50 -07:00
|
|
|
|
2015-03-15 21:20:00 -07:00
|
|
|
def test_list_colls(self):
|
|
|
|
""" Test collection listing, printed to stdout
|
|
|
|
"""
|
|
|
|
orig_stdout = sys.stdout
|
2016-02-23 13:26:53 -08:00
|
|
|
buff = StringIO()
|
2015-03-15 21:20:00 -07:00
|
|
|
sys.stdout = buff
|
2015-03-16 16:53:24 -07:00
|
|
|
|
|
|
|
try:
|
|
|
|
main(['list'])
|
|
|
|
finally:
|
|
|
|
sys.stdout = orig_stdout
|
2015-03-15 21:20:00 -07:00
|
|
|
|
2015-03-15 22:23:08 -07:00
|
|
|
output = sorted(buff.getvalue().splitlines())
|
2015-03-15 21:20:00 -07:00
|
|
|
assert len(output) == 4
|
2015-03-15 22:23:08 -07:00
|
|
|
assert 'Collections:' in output
|
|
|
|
assert '- foo' in output
|
|
|
|
assert '- nested' in output
|
|
|
|
assert '- test' in output
|
2015-03-15 21:20:00 -07:00
|
|
|
|
2015-03-23 11:05:02 -07:00
|
|
|
def test_convert_cdx(self):
|
2015-03-19 20:52:00 -07:00
|
|
|
""" Create non-surt cdx, then convert to cdxj
|
|
|
|
"""
|
|
|
|
migrate_dir = os.path.join(self.root_dir, '_migrate')
|
|
|
|
|
|
|
|
os.mkdir(migrate_dir)
|
|
|
|
|
2020-07-10 20:22:58 -07:00
|
|
|
cdxindexer_main(['-u', '-o', migrate_dir, self._get_sample_warc('')])
|
2015-03-19 20:52:00 -07:00
|
|
|
|
|
|
|
# try one file with -9
|
2020-07-10 20:22:58 -07:00
|
|
|
cdxindexer_main(['-u', '-9', '-o', migrate_dir, self._get_sample_warc('example.warc.gz')])
|
2015-03-19 20:52:00 -07:00
|
|
|
|
|
|
|
cdxs = os.listdir(migrate_dir)
|
|
|
|
assert all(x.endswith('.cdx') for x in cdxs)
|
|
|
|
|
|
|
|
@patch('pywb.manager.manager.get_input', lambda x: 'blah')
|
|
|
|
def do_migrate_no():
|
2015-08-25 23:06:00 +03:00
|
|
|
main(['cdx-convert', migrate_dir])
|
2015-03-19 20:52:00 -07:00
|
|
|
|
|
|
|
do_migrate_no()
|
|
|
|
assert os.listdir(migrate_dir) == cdxs
|
|
|
|
|
|
|
|
@patch('pywb.manager.manager.get_input', lambda x: 'y')
|
|
|
|
def do_migrate_yes():
|
2015-08-25 23:06:00 +03:00
|
|
|
main(['cdx-convert', migrate_dir])
|
2015-03-19 20:52:00 -07:00
|
|
|
|
|
|
|
do_migrate_yes()
|
|
|
|
cdxjs = os.listdir(migrate_dir)
|
|
|
|
|
|
|
|
assert len(cdxs) == len(cdxjs)
|
|
|
|
assert all(x.endswith('.cdxj') for x in cdxjs)
|
|
|
|
|
2016-02-23 13:26:53 -08:00
|
|
|
with open(os.path.join(migrate_dir, 'iana.cdxj'), 'rb') as fh:
|
2015-10-22 17:41:42 -07:00
|
|
|
cdx = CDXObject(fh.readline())
|
|
|
|
assert cdx['urlkey'] == 'org,iana)/'
|
|
|
|
assert cdx['timestamp'] == '20140126200624'
|
|
|
|
assert cdx['url'] == 'http://www.iana.org/'
|
|
|
|
#assert fh.readline().startswith('org,iana)/ 20140126200624 {"url": "http://www.iana.org/",')
|
2015-03-19 20:52:00 -07:00
|
|
|
|
|
|
|
# Nothing else to migrate
|
2015-08-25 23:06:00 +03:00
|
|
|
main(['cdx-convert', migrate_dir])
|
2015-03-19 20:52:00 -07:00
|
|
|
|
2015-03-22 17:55:38 -07:00
|
|
|
def test_auto_index(self):
|
|
|
|
main(['init', 'auto'])
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
auto_dir = os.path.join(self.root_dir, COLLECTIONS, 'auto')
|
2015-03-22 17:55:38 -07:00
|
|
|
archive_dir = os.path.join(auto_dir, ARCHIVE_DIR)
|
|
|
|
|
|
|
|
archive_sub_dir = os.path.join(archive_dir, 'sub')
|
|
|
|
os.makedirs(archive_sub_dir)
|
|
|
|
|
|
|
|
def do_copy():
|
|
|
|
try:
|
2016-11-11 10:30:48 -08:00
|
|
|
time.sleep(1.0)
|
2015-03-22 17:55:38 -07:00
|
|
|
shutil.copy(self._get_sample_warc('example.warc.gz'), archive_dir)
|
|
|
|
shutil.copy(self._get_sample_warc('example-extra.warc'), archive_sub_dir)
|
2016-11-11 10:30:48 -08:00
|
|
|
time.sleep(1.0)
|
2015-03-22 17:55:38 -07:00
|
|
|
finally:
|
2017-09-21 22:12:57 -07:00
|
|
|
indexer.interval = 0
|
2015-03-22 17:55:38 -07:00
|
|
|
|
2017-09-21 22:12:57 -07:00
|
|
|
indexer = AutoIndexer(interval=0.25)
|
|
|
|
indexer.start()
|
2015-03-22 17:55:38 -07:00
|
|
|
|
2017-09-21 22:12:57 -07:00
|
|
|
ge = gevent.spawn(do_copy)
|
2016-11-11 10:30:48 -08:00
|
|
|
ge.join()
|
2015-03-25 10:56:53 -07:00
|
|
|
|
2015-03-22 17:55:38 -07:00
|
|
|
index_file = os.path.join(auto_dir, INDEX_DIR, AUTOINDEX_FILE)
|
|
|
|
assert os.path.isfile(index_file)
|
|
|
|
|
2016-03-10 13:07:57 -08:00
|
|
|
with open(index_file, 'r') as fh:
|
2015-03-22 17:55:38 -07:00
|
|
|
index = fh.read()
|
|
|
|
|
2016-03-10 13:07:57 -08:00
|
|
|
assert '"example.warc.gz' in index, index
|
|
|
|
assert '"sub/example-extra.warc' in index, index
|
2015-03-22 17:55:38 -07:00
|
|
|
|
|
|
|
mtime = os.path.getmtime(index_file)
|
|
|
|
|
|
|
|
# Update
|
2017-09-21 22:12:57 -07:00
|
|
|
indexer.interval = 0.25
|
|
|
|
indexer.start()
|
2015-03-22 17:55:38 -07:00
|
|
|
|
|
|
|
os.remove(index_file)
|
|
|
|
|
2016-11-11 10:30:48 -08:00
|
|
|
#thread = threading.Thread(target=do_copy)
|
|
|
|
#thread.daemon = True
|
|
|
|
#thread.start()
|
|
|
|
ge = gevent.spawn(do_copy)
|
2015-03-22 17:55:38 -07:00
|
|
|
|
2017-09-21 22:12:57 -07:00
|
|
|
#wayback(['-p', '0', '-a', '--auto-interval', '0.25'])
|
2015-03-22 17:55:38 -07:00
|
|
|
|
2016-11-11 10:30:48 -08:00
|
|
|
#thread.join()
|
|
|
|
ge.join()
|
2015-04-03 01:18:35 -07:00
|
|
|
|
2015-03-25 10:56:53 -07:00
|
|
|
# assert file was update
|
2015-03-22 17:55:38 -07:00
|
|
|
assert os.path.getmtime(index_file) > mtime
|
|
|
|
|
2015-03-16 16:53:24 -07:00
|
|
|
def test_err_template_remove(self):
|
|
|
|
""" Test various error conditions for templates:
|
|
|
|
invalid template name, no collection for collection template
|
|
|
|
no template file found
|
|
|
|
"""
|
|
|
|
# no such template
|
|
|
|
with raises(KeyError):
|
|
|
|
main(['template', 'foo', '--remove', 'blah_html'])
|
|
|
|
|
|
|
|
# collection needed
|
|
|
|
with raises(IOError):
|
|
|
|
main(['template', '--remove', 'query_html'])
|
|
|
|
|
|
|
|
# already removed
|
|
|
|
with raises(IOError):
|
|
|
|
main(['template', 'foo', '--remove', 'query_html'])
|
|
|
|
|
2015-03-14 14:56:15 -07:00
|
|
|
def test_err_no_such_coll(self):
|
|
|
|
""" Test error adding warc to non-existant collection
|
|
|
|
"""
|
2015-03-16 18:48:09 -07:00
|
|
|
warc1 = self._get_sample_warc('example.warc.gz')
|
2015-03-14 14:56:15 -07:00
|
|
|
|
|
|
|
with raises(IOError):
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['add', 'bar', warc1])
|
2015-03-14 14:56:15 -07:00
|
|
|
|
|
|
|
def test_err_wrong_warcs(self):
|
2015-03-16 18:48:09 -07:00
|
|
|
warc1 = self._get_sample_warc('example.warc.gz')
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
invalid_warc = os.path.join(self.root_dir, COLLECTIONS, 'test', ARCHIVE_DIR, 'invalid.warc.gz')
|
2015-03-14 14:56:15 -07:00
|
|
|
|
2015-03-15 21:20:00 -07:00
|
|
|
# Empty warc list, argparse calls exit
|
|
|
|
with raises(SystemExit):
|
|
|
|
main(['index', 'test'])
|
2015-03-14 14:56:15 -07:00
|
|
|
|
|
|
|
# Wrong paths not in collection
|
|
|
|
with raises(IOError):
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['index', 'test', warc1])
|
2015-03-14 14:56:15 -07:00
|
|
|
|
|
|
|
# Non-existent
|
|
|
|
with raises(IOError):
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['index', 'test', invalid_warc])
|
2015-03-14 14:56:15 -07:00
|
|
|
|
2015-04-03 01:18:35 -07:00
|
|
|
def test_err_invalid_name(self):
|
|
|
|
""" Invalid collection name
|
|
|
|
"""
|
|
|
|
with raises(ValueError):
|
|
|
|
main(['init', '../abc%'])
|
|
|
|
|
|
|
|
with raises(ValueError):
|
|
|
|
main(['init', '45^23'])
|
|
|
|
|
2015-03-13 19:53:50 -07:00
|
|
|
def test_err_missing_dirs(self):
|
2015-03-14 14:56:15 -07:00
|
|
|
""" Test various errors with missing warcs dir,
|
|
|
|
missing cdx dir, non dir cdx file, and missing collections root
|
|
|
|
"""
|
JS Object Proxy Override System (#224)
* Init commit for Wombat JS Proxies off of https://github.com/ikreymer/pywb/tree/develop
Changes
- cli.py: add import os for os.chdir(self.r.directory)
- frontendapp.py: added initial support for cors requests.
- static_handler.py: add import for NotFoundException
- wbrequestresponse.py: added the intital implementation for cors requests, webrecoder needs this for recording!
- default_rewriter.py: added JSWombatProxyRewriter to default js rewriter class for internal testing
- html_rewriter.py: made JSWombatProxyRewriter to be default js rewriter class for internal testing
- regex_rewriters.py: implemented JSWombatProxyRewriter and JSWombatProxyRewriter to support wombat JS Proxy
- wombat.js: added JS Proxy support
- remove print
* wombat proxy: simplify mixin using 'first_buff'
* js local scope rewrite/proxy work:
- add DefaultHandlerWithJSProxy to enable new proxy rewrite (disabled by default)
- new proxy toggleable with 'js_local_scope_rewrite: true'
- work on integrating john's proxy work
- getAllOwnProps() to generate list of functions that need to be rebound
- remove non-proxy related changes for now, remove angular special cases (for now)
* local scope proxy work:
- add back __WB_pmw() prefix for postMessage
- don't override postMessage() in proxy obj
- MessageEvent resolve proxy to original window obj
* js obj proxy: use local_init() to load local vars from proxy obj
* wombat: js object proxy improvements:
- use same object '_WB_wombat_obj_proxy' on window and document objects
- reuse default_proxy_get() for get operation from window or document
- resolve and Window/Document object to the proxy, eg. if '_WB_wombat_obj_proxy' exists, return that
- override MessageEvent.source to return window proxy object
* obj proxy work:
- window proxy: defineProperty() override calls Reflect.defineProperty on dummy object as well as window to avoid exception
- window proxy: set() also sets on dummy object, and returns false if Reflect.set returns false (eg. altered by Reflect.defineProperty disabled writing)
- add override_prop_to_proxy() to add override to return proxy obj for attribute
- add override for Node.ownerDocument and HTMLElement.parentNode to return document proxy
server side rewrite: generalize local proxy insert, add list for local let overrides
* js obj proxy work:
- add default '__WB_pmw' to self if undefined (for service workers)
- document.origin override
- proxy obj: improved defineProperty override to work with safari
- proxy obj: catch any exception in dummy obj setter
* client-side rewriting:
- proxy obj: catch exception (such as cross-domain access) in own props init
- proxy obj: check for self reference '_WB_wombat_obj_proxy' access to avoid infinite recurse
- rewrite style: add 'cursor' attr for css url rewriting
* content rewriter: if is_ajax(), skip JS proxy obj rewriting also (html rewrite also skipped)
* client-side rewrite: rewrite 'data:text/css' as inline stylesheet when set via setAttribute() on 'href' in link
* client-side document override improvements:
- fix document.domain, document.referrer, forms add document.origin overrides to use only the document object
- init_doc_overrides() called as part of proxy init
- move non-document overrides to main init
rewrite: add rewrite for "Function('return this')" pattern to use proxy obj
* js obj proxy: now a per-collection (and even a per-request) setting 'use_js_obj_prox' (defaults to False)
live-rewrite-server: defaults to enabled js obj proxy
metadata: get_metadata() loads metadata.yaml for config settings for dynamic collections),
or collection config for static collections
warcserver: get_coll_config() returns config for static collection
tests: use custom test dir instead of default 'collections' dir
tests: add basic test for js obj proxy
update to warcio>=1.4.0
* karma tests: update to safari >10
* client-side rewrite:
- ensure wombat.js is ES5 compatible (don't use let)
- check if Proxy obj exists before attempting to init
* js proxy obj: RewriteWithProxyObj uses user-agent to determine if Proxy obj can be supported
content_rewriter: add overridable get_rewriter()
content_rewriter: fix elif -> if in should_rw_content()
tests: update js proxy obj test with different user agents (supported and unsupported)
karma: reset test to safari 9
* compatibility: remove shorthand notation from wombat.js
* js obj proxy: override MutationObserver.observe() to retrieve original object from proxy
wombat.js: cleanup, remove commented out code, label new proxy system functions, bump version to 2.40
2017-08-05 10:37:32 -07:00
|
|
|
colls = os.path.join(self.root_dir, COLLECTIONS)
|
2015-03-13 19:53:50 -07:00
|
|
|
|
2015-03-15 22:23:08 -07:00
|
|
|
# No Statics -- ignorable
|
|
|
|
shutil.rmtree(os.path.join(colls, 'foo', 'static'))
|
|
|
|
|
2015-03-14 14:56:15 -07:00
|
|
|
# No WARCS
|
2015-03-16 18:48:09 -07:00
|
|
|
warcs_path = os.path.join(colls, 'foo', ARCHIVE_DIR)
|
2015-03-14 14:56:15 -07:00
|
|
|
shutil.rmtree(warcs_path)
|
|
|
|
|
|
|
|
with raises(IOError):
|
2015-03-15 21:20:00 -07:00
|
|
|
main(['add', 'foo', 'somewarc'])
|
2015-03-14 14:56:15 -07:00
|
|
|
|
2015-03-13 19:53:50 -07:00
|
|
|
# No CDX
|
2015-03-16 18:48:09 -07:00
|
|
|
cdx_path = os.path.join(colls, 'foo', INDEX_DIR)
|
2015-03-13 19:53:50 -07:00
|
|
|
shutil.rmtree(cdx_path)
|
|
|
|
|
|
|
|
# CDX a file not a dir
|
|
|
|
with open(cdx_path, 'w+b') as fh:
|
2016-02-23 13:26:53 -08:00
|
|
|
fh.write(b'foo\n')
|
2015-03-13 19:53:50 -07:00
|
|
|
|
|
|
|
shutil.rmtree(colls)
|
|
|
|
|
2015-03-22 21:50:56 -07:00
|
|
|
# No Collections to list
|
|
|
|
with raises(IOError):
|
|
|
|
main(['list'])
|
|
|
|
|
2015-03-13 19:53:50 -07:00
|
|
|
# No Collections
|
|
|
|
resp = self.testapp.get('/test/', status=404)
|
|
|
|
assert resp.status_int == 404
|
|
|
|
|