Commit Graph

10365 Commits (08aaf0e781782c6c7bd077e540ce7f85276135ae)

Author SHA1 Message Date
KPrasch 388286c18c Apply suggestions from code review
Co-authored-by: Derek Pierre <derek.pierre@gmail.com>
2022-10-18 20:09:25 +02:00
Kieran Prasch 48c357ef18 Inspiration credits to lit protocol. 2022-10-18 20:09:25 +02:00
derekpierre e3446303b7 Remove support for None in ReturnValueTest - solidity has no concept of None/null so not needed. We can revisit later.
Updated condition tests to use 'is True' or 'is False'
Added SubscriptionManager test to show condition test whose contract call returns a struct and that the struct can be tested for equality/inequality.
2022-10-18 20:09:25 +02:00
derekpierre d0d71944b9 Remove __eq__ from ReturnValueTest obj - only needed for tests. 2022-10-18 20:09:25 +02:00
derekpierre 658a4470a2 Apply RFCs from #2974.
Co-authored-by: KPrasch <kieran@nucypher.com>
2022-10-18 20:09:25 +02:00
derekpierre 96c829d5a6 ReturnValueTest can now take any valid value type (including None) for comparison - this provides flexibility based on the result of a contract call.
String value types need to be quoted, but context variables are a special case of strings that don't need to be.
Added tests.
2022-10-18 20:09:25 +02:00
derekpierre d158221794 Add '!=' comparator as a valid comparator for ReturnValueTest.
Updated tests.
2022-10-18 20:09:25 +02:00
David Núñez c238217b66 Use operator module instead of lambdas to implement comparators
Co-authored-by: Derek Pierre <derek.pierre@gmail.com>

"The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python"
2022-10-18 20:09:25 +02:00
derekpierre 43094f6a4b Move type check to is_context_variable() function - code smell RFC for #2974. 2022-10-18 20:09:25 +02:00
derekpierre 5baac258c4 Make SubscriptionManager condition tests pass now that the facilities to make it pass are now available. 2022-10-18 20:09:25 +02:00
derekpierre fb257cba7d Context variables used in ReturnValueTest were not being replaced - needed for the NFT use case. Modified the code to support it.
Updated ERC721 condition tests to use an actual ERC721 contract with a minted NFT.
Added ERC721 tests for balanceof.
2022-10-18 20:09:25 +02:00
derekpierre 0379ce7114 Parameter types for ContractConditions do not have to be strings - we need to be careful with types when checking whether a parameter is a context variable or not.
ERC721 ownerOf function takes an int and not a string which caused failures.
Added/updated tests.
2022-10-18 20:09:25 +02:00
David Núñez 1e8aeb0c7b Adjust name and typehints of ReturnValueTest sanitization method 2022-10-18 20:09:25 +02:00
David Núñez 9ce80c7877 Use pre-defined functions instead of eval for comparisons 2022-10-18 20:09:25 +02:00
David Núñez 36e5368f3c Add more basic unit tests for ReturnValueTest 2022-10-18 20:09:25 +02:00
David Núñez 7219c749ba Sanitize input to constructor of ReturnValueTest 2022-10-18 20:09:25 +02:00
David Núñez 56af2bf27f Basic unit test for ConditionLingo 2022-10-18 20:09:25 +02:00
David Núñez 49075e17cd Use ast.literal_eval() to make sure that subsequent uses of eval() only evaluate expressions with literals, with no side-effects 2022-10-18 20:09:25 +02:00
David Núñez 7c976751b0 Playing around with malicious input that exploits the use of eval()
This test creates an empty file in the filesystem when evaluating a condition. This shouldn't happen! We fix it later in this PR by using the ast module
2022-10-18 20:09:25 +02:00
derekpierre da018d034e Update response messages from Ursula - only log messages were updated, whoops!
Prevent ambigous empty error messages by also including exception class names in message when catching all-encompassing/non-specific exceptions.
Don't check response code since non-200 response code checking already done by middleware.
Code cleanup.
2022-10-18 20:09:25 +02:00
derekpierre ed6227ad09 Code cleanup and additional tests.. 2022-10-18 20:09:25 +02:00
Kieran Prasch b98af7e0ac Resolves authentication TODO on server.py 2022-10-18 20:09:25 +02:00
Kieran Prasch af3820bdb4 adjust missing condition context variable HTTP error 2022-10-18 20:09:25 +02:00
derekpierre e5fb972d2a Initial work for propagating errors that occur during Porter.retrieve_cfrags and communicating them back to the caller in Porter's response. 2022-10-18 20:09:25 +02:00
derekpierre f972c72470 Code cleanup to condition context variable - follow up RFCs from #2966. 2022-10-18 20:09:25 +02:00
derekpierre e42e50a3de Apply RFC from #2966. 2022-10-18 20:09:25 +02:00
derekpierre a4b9ef62d1 Improve error handling. 2022-10-18 20:09:25 +02:00
derekpierre f6721f7b81 Don't let context variable exceptions leak into ReencryptionCondition class. 2022-10-18 20:09:25 +02:00
derekpierre be175448f4 Perform actual validation of context provided for ":userAddress" context variable.
Added tests.
2022-10-18 20:09:25 +02:00
derekpierre a6cc6ce60f Updated deps for eip712-structs. 2022-10-18 20:09:25 +02:00
derekpierre 8c7f9f5a08 Tests updated since flask 2.2.2 has a different way of doing things. 2022-10-18 20:09:25 +02:00
derekpierre 7e8d9eb7f1 Modify tests to use context instead of python parameters. Add test for use of user customized context variable.
Cleanup some test code.
2022-10-18 20:09:25 +02:00
derekpierre 6d35b5754e Simple implementation for `:userAddress` context variable pre-processing.
Allow for user customized context variable - fallback to key-value pairing in context.
2022-10-18 20:09:25 +02:00
derekpierre f164cfb3a9 Clenup of tests regarding `context`. Minor fix for using lists for ConditionLingo conditions instead of tuple. 2022-10-18 20:09:25 +02:00
Kieran Prasch 0d55ed091b w3.eth.web3 -> w3.eth.w3 2022-10-18 20:09:25 +02:00
derekpierre 31e961d458 Fix randomly failing test (regression) - context is not a required parameter. 2022-10-18 20:09:25 +02:00
derekpierre 46b40dcc57 Update format of `context` for tests. 2022-10-18 20:09:25 +02:00
derekpierre 1851b605a7 Updated documentation of context parameter for retrieve endpoint. Also removed example showing the use of url parameters for the retrieve POST endpoint since not applicable. 2022-10-18 20:09:25 +02:00
derekpierre dc52a58590 Allow for optional enforcement of type safety for the JSON field. The Porter retrieval endpoint will enforce a dictionary type for the `context` parameter..
Updated tests.
2022-10-18 20:09:25 +02:00
derekpierre d77fac4d39 Allow context to be specified as JSON and not base64 JSON.
Remove retrieve tests that utilize url parameters since it is a POST endpoint.
2022-10-18 20:09:25 +02:00
derekpierre 67f4f50751 Add simple documentation for `context` parameter for Porter's retrieval endpoint. 2022-10-18 20:09:25 +02:00
derekpierre 15cb062940 Added some tests that provide a context for re-encryption. 2022-10-18 20:09:25 +02:00
derekpierre 40e2c5c0ea Initial work to have Porter provide 'context' for condition-based re-encryption when applicable. 2022-10-18 20:09:25 +02:00
KPrasch cd11a414bc Apply suggestions from code review
Co-authored-by: Derek Pierre <derek.pierre@gmail.com>
2022-10-18 20:09:25 +02:00
Kieran Prasch e450179e23 Use none as the 'free' gas post-london 2022-10-18 20:09:25 +02:00
Kieran Prasch 47a7780082 Skip JSON endpoint test 2022-10-18 20:09:25 +02:00
Kieran Prasch 3411fc36ab bump probationary period 2022-10-18 20:09:24 +02:00
Kieran Prasch 032088e0c9 Enrico.encrypt_message accepts conditions. 2022-10-18 20:08:52 +02:00
Kieran Prasch 0acfc7e381 Support for web3.py v6 2022-10-18 20:08:52 +02:00
Kieran Prasch 0608608460 Capsule filtration bugfixes 2022-10-18 20:08:52 +02:00