Mercurial > p > roundup > code
annotate roundup/test/tx_Source_detector.py @ 8562:9c3ec0a5c7fc
chore: remove __future print_funcion from code.
Not needed as of Python 3.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 08 Apr 2026 21:39:40 -0400 |
| parents | 137aabd876ad |
| children |
| rev | line source |
|---|---|
| 4781 | 1 # |
| 2 # Example output when the web interface changes item 3 and the email | |
| 3 # (non pgp) interface changes item 4: | |
| 4 # | |
| 5 # tx_SourceCheckAudit(3) pre db.tx_Source: cgi | |
| 6 # tx_SourceCheckAudit(4) pre db.tx_Source: email | |
| 7 # tx_SourceCheckAudit(3) post db.tx_Source: cgi | |
| 8 # tx_SourceCheckAudit(4) post db.tx_Source: email | |
| 9 # tx_SourceCheckReact(4) pre db.tx_Source: email | |
| 10 # tx_SourceCheckReact(4) post db.tx_Source: email | |
| 11 # tx_SourceCheckReact(3) pre db.tx_Source: cgi | |
| 12 # tx_SourceCheckReact(3) post db.tx_Source: cgi | |
| 13 # | |
| 14 # Note that the calls are interleaved, but the proper | |
| 15 # tx_Source is associated with the same ticket. | |
| 16 | |
| 17 | |
| 18 def tx_SourceCheckAudit(db, cl, nodeid, newvalues): | |
| 19 ''' An auditor to print the value of the source of the | |
| 20 transaction that trigger this change. The sleep call | |
| 21 is used to delay the transaction so that multiple changes will | |
| 22 overlap. The expected output from this detector are 2 lines | |
| 23 with the same value for tx_Source. Tx source is: | |
| 24 None - Reported when using a script or it is an error if | |
| 25 the change arrives by another method. | |
| 26 "cli" - reported when using roundup-admin | |
|
5881
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
27 "web" - reported when using html based web pages |
|
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
28 "rest" - reported when using the /rest web API |
|
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
29 "xmlrpc" - reported when using the /xmlrpc web API |
| 4781 | 30 "email" - reported when using an unautheticated email based technique |
| 31 "email-sig-openpgp" - reported when email with a valid pgp | |
| 32 signature is used | |
| 33 ''' | |
| 34 if __debug__ and False: | |
| 7033 | 35 print("\n tx_SourceCheckAudit(%s) db.tx_Source: %s" % ( |
| 36 nodeid, db.tx_Source)) | |
| 4781 | 37 |
| 38 newvalues['tx_Source'] = db.tx_Source | |
| 39 | |
| 40 # example use for real to prevent a change from happening if it's | |
| 41 # submited via email | |
| 42 # | |
| 43 # if db.tx_Source == "email": | |
| 44 # raise Reject, 'Change not allowed via email' | |
| 45 | |
| 7033 | 46 |
| 4781 | 47 def tx_SourceCheckReact(db, cl, nodeid, oldvalues): |
| 48 ''' An reactor to print the value of the source of the | |
| 49 transaction that trigger this change. The sleep call | |
| 50 is used to delay the transaction so that multiple changes will | |
| 51 overlap. The expected output from this detector are 2 lines | |
| 52 with the same value for tx_Source. Tx source is: | |
| 53 None - Reported when using a script or it is an error if | |
| 54 the change arrives by another method. | |
| 55 "cli" - reported when using roundup-admin | |
|
5881
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
56 "web" - reported when using html based web pages |
|
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
57 "rest" - reported when using the /rest web API |
|
9938c40e03bc
Add "rest" and "xmlrpc" values for database tx_Source property
John Rouillard <rouilj@ieee.org>
parents:
5376
diff
changeset
|
58 "xmlrpc" - reported when using the /xmlrpc web API |
| 4781 | 59 "email" - reported when using an unautheticated email based technique |
| 60 "email-sig-openpgp" - reported when email with a valid pgp | |
| 61 signature is used | |
| 62 ''' | |
| 63 | |
| 64 if __debug__ and False: | |
| 7033 | 65 print(" tx_SourceCheckReact(%s) db.tx_Source: %s" % ( |
| 66 nodeid, db.tx_Source)) | |
| 4781 | 67 |
| 68 | |
| 69 def init(db): | |
| 70 db.issue.audit('create', tx_SourceCheckAudit) | |
| 71 db.issue.audit('set', tx_SourceCheckAudit) | |
| 72 | |
| 73 db.issue.react('set', tx_SourceCheckReact) | |
| 74 db.issue.react('create', tx_SourceCheckReact) | |
| 75 | |
| 76 db.msg.audit('create', tx_SourceCheckAudit) |
