-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pending job sync #8104
Open
elioschmutz
wants to merge
5
commits into
es/TI-1494-non-signers-sign-request
Choose a base branch
from
es/TI-1494-pending-job-sync
base: es/TI-1494-non-signers-sign-request
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Pending job sync #8104
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
00385b6
Use from_emails function to get signers and editors from a list of em…
elioschmutz f1cd067
Allow to update the signers and editors of a pending signing job
elioschmutz 3c64f65
Implement @update-pending-signing-job api endpoint.
elioschmutz 0a375f1
Provide update_url when signing a document
elioschmutz 90bf0cd
Add changelog
elioschmutz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Provides an endpoint to sync pending signing jobs with the external sign service. [elioschmutz] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,35 @@ Der Request löst den Signaturprozess für das Dokument aus. | |
|
||
Im Rahmen des Signaturprozesses wird ein Access-Token generiert, der dem externen Signaturservice übergeben wird. Dieses Token muss im späteren Request zur Rückführung der signierten PDF-Datei wiederverwendet werden. | ||
|
||
Aktualisieren eines ausstehenden Signierungsauftrags | ||
---------------------------------------------------- | ||
Der Endpoint ``@update-pending-signing-job`` dient dazu, die Listen der Signierenden ("signers") und Bearbeitenden ("editors") eines ausstehenden Signierungsauftrags zu aktualisieren. Dies ermöglicht es einem externen Signierungsdienst, Änderungen in GEVER vorzunehmen und die betroffenen Personen entsprechend anzupassen. | ||
|
||
**Beispiel-Request**: | ||
|
||
.. code-block:: http | ||
|
||
PATCH /@update-pending-signing-job HTTP/1.1 | ||
Content-Type: application/json | ||
Authorization: Bearer <access_token> | ||
|
||
{ | ||
"access_token": "12345", | ||
"signature_data": { | ||
"signers": ["[email protected]"], | ||
"editors": ["[email protected]"] | ||
} | ||
} | ||
|
||
- ``access_token``: Das beim Start des Signaturprozesses generierte Token. | ||
- ``signature_data`` (erforderlich): Ein Objekt, das die zu aktualisierenden Felder enthält. | ||
- ``signers`` (optional): Eine Liste von E-Mail-Adressen der neuen Signierenden. Wenn nicht angegeben, bleibt die Liste der Signierenden unverändert. | ||
- ``editors`` (optional): Eine Liste von E-Mail-Adressen der neuen Bearbeitenden. Wenn nicht angegeben, bleibt die Liste der Bearbeitenden unverändert. | ||
|
||
**Hinweise** | ||
|
||
- Die Aktualisierung gilt nur für ausstehende Signierungsaufträge und hat keine Auswirkungen auf bereits abgeschlossene Vorgänge. | ||
|
||
Hochladen der signierten PDF-Datei | ||
---------------------------------- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,3 +190,119 @@ def test_return_sign_redirect_url_when_signing_a_document_from_final_state(self, | |
|
||
self.assertEqual('http://external.example.org/signing-requests/123', | ||
browser.json.get('redirect_url')) | ||
|
||
|
||
class TestUpdatePendingSigningJobPost(SolrIntegrationTestCase): | ||
|
||
features = ['sign'] | ||
|
||
@browsing | ||
def test_raises_forbidden_if_context_is_not_in_signing_state(self, browser): | ||
with self.login(self.regular_user): | ||
url = self.document.absolute_url() + '/@update-pending-signing-job' | ||
|
||
browser.exception_bubbling = True | ||
with self.assertRaises(Forbidden): | ||
browser.open(url, method='PATCH', headers=self.api_headers) | ||
|
||
@browsing | ||
@requests_mock.Mocker() | ||
def test_access_token_is_required_in_payload(self, browser, mocker): | ||
mocker.post(re.compile('/signing-jobs'), json=DEFAULT_MOCK_RESPONSE) | ||
|
||
with self.login(self.regular_user, browser): | ||
browser.open(self.document.absolute_url() + '/@workflow/' + Document.draft_signing_transition, | ||
method='POST', | ||
headers=self.api_headers) | ||
|
||
url = self.document.absolute_url() + '/@update-pending-signing-job' | ||
|
||
with browser.expect_http_error(400): | ||
browser.open(url, | ||
method='PATCH', | ||
headers=self.api_headers, | ||
data=json.dumps({})) | ||
|
||
self.assertEqual( | ||
{'message': "Property 'access_token' is required", | ||
'type': 'BadRequest'}, | ||
browser.json) | ||
|
||
@browsing | ||
@requests_mock.Mocker() | ||
def test_requires_a_valid_access_token(self, browser, mocker): | ||
mocker.post(re.compile('/signing-jobs'), json=DEFAULT_MOCK_RESPONSE) | ||
|
||
with self.login(self.regular_user, browser): | ||
browser.open(self.document.absolute_url() + '/@workflow/' + Document.draft_signing_transition, | ||
method='POST', | ||
headers=self.api_headers) | ||
|
||
url = self.document.absolute_url() + '/@update-pending-signing-job' | ||
|
||
browser.exception_bubbling = True | ||
with self.assertRaises(Unauthorized): | ||
browser.open(url, | ||
method='PATCH', | ||
headers=self.api_headers, | ||
data=json.dumps({ | ||
'access_token': urlsafe_b64encode('<invalid-token>'), | ||
'signature_data': { | ||
'editors': ['[email protected]'], | ||
'signers': ['[email protected]'], | ||
} | ||
})) | ||
|
||
@browsing | ||
@requests_mock.Mocker() | ||
def test_data_attribute_is_required_in_payload(self, browser, mocker): | ||
mocker.post(re.compile('/signing-jobs'), json=DEFAULT_MOCK_RESPONSE) | ||
|
||
with self.login(self.regular_user, browser): | ||
browser.open(self.document.absolute_url() + '/@workflow/' + Document.draft_signing_transition, | ||
method='POST', | ||
headers=self.api_headers) | ||
|
||
url = self.document.absolute_url() + '/@update-pending-signing-job' | ||
|
||
with browser.expect_http_error(400): | ||
browser.open(url, | ||
method='PATCH', | ||
headers=self.api_headers, | ||
data=json.dumps({ | ||
'access_token': urlsafe_b64encode('<invalid-token>'), | ||
})) | ||
|
||
self.assertEqual( | ||
{'message': "Property 'signature_data' is required", | ||
'type': 'BadRequest'}, | ||
browser.json) | ||
|
||
@browsing | ||
@requests_mock.Mocker() | ||
def test_can_update_signers_and_editors_of_pending_job(self, browser, mocker): | ||
mocker.post(re.compile('/signing-jobs'), json=DEFAULT_MOCK_RESPONSE) | ||
|
||
with self.login(self.regular_user, browser=browser): | ||
browser.open(self.document.absolute_url() + '/@workflow/' + Document.draft_signing_transition, | ||
method='POST', | ||
headers=self.api_headers) | ||
|
||
token = urlsafe_b64encode(Signer(self.document).token_manager._get_token()) | ||
url = self.document.absolute_url() + '/@update-pending-signing-job' | ||
|
||
browser.open(url, | ||
method='PATCH', | ||
headers=self.api_headers, | ||
data=json.dumps({ | ||
'access_token': token, | ||
'signature_data': { | ||
'editors': ['[email protected]'], | ||
'signers': ['[email protected]'], | ||
} | ||
})) | ||
|
||
self.assertEqual([{'email': '[email protected]', 'userid': ''}], | ||
browser.json.get('editors')) | ||
self.assertEqual([{'email': '[email protected]', 'userid': ''}], | ||
browser.json.get('signers')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ def test_add_a_signing_job(self, mocker): | |
u'editors': ['[email protected]'], | ||
u'title': u'Vertr\xe4gsentwurf', | ||
u'upload_url': u'http://nohost/plone/ordnungssystem/fuhrung/vertrage-und-vereinbarungen/dossier-1/document-14/@upload-signed-pdf', # noqa | ||
u'update_url': u'http://nohost/plone/ordnungssystem/fuhrung/vertrage-und-vereinbarungen/dossier-1/document-14/@update-pending-signing-job', # noqa | ||
}, | ||
mocker.last_request.json()) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,11 @@ def test_can_be_serialized(self): | |
self.assertEqual(2, len(container.serialize())) | ||
self.assertItemsEqual([signer2.email, signer1.email], | ||
[item.get('email') for item in container.serialize()]) | ||
|
||
def test_can_be_created_from_a_list_of_emails(self): | ||
container = PendingEditors.from_emails(['[email protected]', '[email protected]']) | ||
|
||
self.assertEqual(2, len(container)) | ||
self.assertTrue(isinstance(container[0], PendingEditor)) | ||
self.assertItemsEqual(['[email protected]', '[email protected]'], | ||
[item.get('email') for item in container.serialize()]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,11 @@ def test_can_be_converted_to_signatories(self): | |
container.append(PendingSigner()) | ||
|
||
self.assertEqual(2, len(container.to_signatories())) | ||
|
||
def test_can_be_created_from_a_list_of_emails(self): | ||
container = PendingSigners.from_emails(['[email protected]', '[email protected]']) | ||
|
||
self.assertEqual(2, len(container)) | ||
self.assertTrue(isinstance(container[0], PendingSigner)) | ||
self.assertItemsEqual(['[email protected]', '[email protected]'], | ||
[item.get('email') for item in container.serialize()]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,3 +87,42 @@ def test_can_be_converted_to_a_signed_version(self): | |
], | ||
'version': 2 | ||
}, data) | ||
|
||
def test_can_update_signers_and_editors(self): | ||
self.login(self.regular_user) | ||
|
||
pending_signing_job = PendingSigningJob(signers=[], editors=[]) | ||
|
||
self.assertItemsEqual([], pending_signing_job.serialize().get('signers')) | ||
self.assertItemsEqual([], pending_signing_job.serialize().get('editors')) | ||
|
||
pending_signing_job.update(signers=['[email protected]']) | ||
|
||
self.assertItemsEqual( | ||
[{u'userid': u'', u'email': u'[email protected]'}], | ||
pending_signing_job.serialize().get('signers')) | ||
|
||
self.assertItemsEqual( | ||
[], | ||
pending_signing_job.serialize().get('editors')) | ||
|
||
pending_signing_job.update(editors=['[email protected]']) | ||
|
||
self.assertItemsEqual( | ||
[{u'userid': u'', u'email': u'[email protected]'}], | ||
pending_signing_job.serialize().get('signers')) | ||
|
||
self.assertItemsEqual( | ||
[{u'userid': u'', u'email': u'[email protected]'}], | ||
pending_signing_job.serialize().get('editors')) | ||
|
||
pending_signing_job.update(signers=['[email protected]'], | ||
editors=['[email protected]']) | ||
|
||
self.assertItemsEqual( | ||
[{u'userid': u'', u'email': u'[email protected]'}], | ||
pending_signing_job.serialize().get('signers')) | ||
|
||
self.assertItemsEqual( | ||
[{u'userid': u'', u'email': u'[email protected]'}], | ||
pending_signing_job.serialize().get('editors')) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.