Skip to content

Commit

Permalink
Merge pull request #76 from NYPL-Simplified/fix-confirmation-workflow
Browse files Browse the repository at this point in the history
Fix the confirmation workflow, which was broken in several places.
  • Loading branch information
leonardr committed Sep 5, 2018
2 parents 215f98f + 6f511d5 commit 921967c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def search_qa():

@app.route('/confirm/<int:resource_id>/<secret>')
@returns_problem_detail
def confirm_resource(secret):
return app.library_registry.validation_controller.validate(
def confirm_resource(resource_id, secret):
return app.library_registry.validation_controller.confirm(
resource_id, secret
)

Expand Down
2 changes: 2 additions & 0 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def setup_controllers(self, emailer_class=Emailer):
self.registry_controller = LibraryRegistryController(
self, emailer_class
)
self.validation_controller = ValidationController(self)

self.heartbeat = HeartbeatController()
vendor_id, node_value, delegates = Configuration.vendor_id(self._db)
if vendor_id:
Expand Down
50 changes: 41 additions & 9 deletions tests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from urllib import unquote

from controller import (
AdobeVendorIDController,
LibraryRegistry,
LibraryRegistryController,
ValidationController,
Expand Down Expand Up @@ -43,7 +44,7 @@
from config import Configuration
from testing import DummyHTTPResponse

class TestLibraryRegistry(LibraryRegistry):
class MockLibraryRegistry(LibraryRegistry):
pass

class MockEmailer(Emailer):
Expand All @@ -67,7 +68,7 @@ def setup(self):
del os.environ['AUTOINITIALIZE']
self.app = app
self.data_setup()
self.library_registry = TestLibraryRegistry(
self.library_registry = MockLibraryRegistry(
self._db, testing=True, emailer_class=MockEmailer,
)
self.app.library_registry = self.library_registry
Expand All @@ -79,6 +80,43 @@ def data_setup(self):
"""
pass

def vendor_id_setup(self):
"""Configure a basic vendor id service."""
integration, ignore = get_one_or_create(
self._db, ExternalIntegration,
protocol=ExternalIntegration.ADOBE_VENDOR_ID,
goal=ExternalIntegration.DRM_GOAL,
)
integration.setting(Configuration.ADOBE_VENDOR_ID).value = "VENDORID"


class TestLibraryRegistry(ControllerTest):

def test_instantiated_controllers(self):
# Verify that the controllers were instantiated and attached
# to the LibraryRegistry object.
assert isinstance(
self.library_registry.registry_controller,
LibraryRegistryController
)
assert isinstance(
self.library_registry.validation_controller,
ValidationController
)

# No Adobe Vendor ID was set up.
eq_(None, self.library_registry.adobe_vendor_id)

# Let's configure one.
self.vendor_id_setup()
registry_with_adobe = MockLibraryRegistry(
self._db, testing=True, emailer_class=MockEmailer
)
assert isinstance(
registry_with_adobe.adobe_vendor_id,
AdobeVendorIDController
)


class TestLibraryRegistryController(ControllerTest):

Expand All @@ -96,13 +134,7 @@ def data_setup(self):
manhattan_ks = self.manhattan_ks
us = self.crude_us

# Configure a basic vendor id service.
integration, ignore = get_one_or_create(
self._db, ExternalIntegration,
protocol=ExternalIntegration.ADOBE_VENDOR_ID,
goal=ExternalIntegration.DRM_GOAL,
)
integration.setting(Configuration.ADOBE_VENDOR_ID).value = "VENDORID"
self.vendor_id_setup()

def setup(self):
super(TestLibraryRegistryController, self).setup()
Expand Down

0 comments on commit 921967c

Please sign in to comment.