Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions capmonstercloud_client/requests/ImpervaCustomTaskRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ class ImpervaCustomTaskRequest(CustomTaskRequestBase):

@validator('metadata')
def validate_metadata(cls, value):
if value.get('incapsulaScriptBase64') is None:
raise TypeError(f'Expect that incapsulaScriptBase64 will be defined.')
if value.get('incapsulaScriptUrl') is None:
raise TypeError(f'Expect that incapsulaScriptUrl will be defined.')
else:
if not isinstance(value.get('incapsulaScriptBase64'), str):
raise TypeError(f'Expect that incapsulaScriptBase64 will be str.')
if value.get('incapsulaSessionCookie') is None:
raise TypeError(f'Expect that incapsulaSessionCookie will be defined.')
if not isinstance(value.get('incapsulaScriptUrl'), str):
raise TypeError(f'Expect that incapsulaScriptUrl will be str.')
if value.get('incapsulaCookie') is None:
raise TypeError(f'Expect that incapsulaCookie will be defined.')
else:
if not isinstance(value.get('incapsulaSessionCookie'), str):
raise TypeError(f'Expect that incapsulaSessionCookie will be str.')
if value.get('reese84UrlEndpoint') is not None and not isinstance(value.get('incapsulaSessionCookie'), str):
if not isinstance(value.get('incapsulaCookie'), str):
raise TypeError(f'Expect that incapsulaCookie will be str.')
if value.get('reese84UrlEndpoint') is not None and not isinstance(value.get('reese84UrlEndpoint'), str):
raise TypeError(f'Expect that reese84UrlEndpoint will be str.')
return value

Expand Down
2 changes: 1 addition & 1 deletion capmonstercloud_client/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0
3.1.0
6 changes: 3 additions & 3 deletions examples/imperva.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ async def solve_captcha_async(num_requests):
key = os.getenv('API_KEY')
client_options = ClientOptions(api_key=key)
cap_monster_client = CapMonsterClient(options=client_options)
metadata = {"incapsulaScriptBase64": "",
"incapsulaSessionCookie": "SAyLRzdYgUntD6v0r7nFBmxTYGcAAAAArkznhRMmVs/cBynTg3r6YA==",
"reese84UrlEndpoint": "Alarums-Exeunter-Hath-Brese-Banq-Wheth-frangerd-"}
metadata = {"incapsulaScriptUrl": "_Incapsula_Resource?SWJIYLWA=719d34d31c8e3a6e6fffd425f7e032f3",
"incapsulaCookie": "incap_ses_1166_2930313=br7iX33ZNCtf3HlpEXcuEDzz72cAAAAA0suDnBGrq/iA0J4oERYzjQ==; visid_incap_2930313=P3hgPVm9S8Oond1L0sXhZqfK72cAAAAAQUIPAAAAAABoMSY9xZ34RvRseJRiY6s+;",
"reese84UrlEndpoint": "Built-with-the-For-hopence-Hurleysurfecting-the-"}
imperva_request = ImpervaCustomTaskRequest(
websiteUrl='https://example.com/login',
metadata=metadata
Expand Down
2 changes: 1 addition & 1 deletion test/amazonwaf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def testAllRequiredFieldsFilling(self):
self.assertTrue(i in list(request_dict.keys()),
msg=f'Required field {i} not in {request_dict}')

self.assertEqual(request_dict['type'], 'AmazonTaskProxyless')
self.assertEqual(request_dict['type'], 'AmazonTask')


if __name__ == '__main__':
Expand Down
14 changes: 7 additions & 7 deletions test/imperva_request_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ class ImpervaRequestTest(unittest.TestCase):

websiteUrlExample = 'site.com'
userAgentExample = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
incapsulaScriptBase64Example = 'dmFyIF8weGQ2ZmU9Wydce..eDUzXHg2YVx4NGYnKV09XzB4Mjk3MTIxO319KCkpOw=='
incapsulaSessionCookieExample = 'l/LsGnrvyB9lNhXI8borDKa2IGcAAAAAX0qAEHheCWuNDquzwb44cw='
incapsulaScriptUrlExample = 'dmFyIF8weGQ2ZmU9Wydce..eDUzXHg2YVx4NGYnKV09XzB4Mjk3MTIxO319KCkpOw=='
incapsulaCookieExample = 'l/LsGnrvyB9lNhXI8borDKa2IGcAAAAAX0qAEHheCWuNDquzwb44cw='
reese84UrlEndpointExample = "Built-with-the-For-hopence-Hurleysurfecting-the-"

def test_imperva(self,
):
required_fields = ['type',
'websiteURL',
'metadata']
metadata_required_fields = ['incapsulaScriptBase64', 'incapsulaSessionCookie']
metadata_example = {"incapsulaScriptBase64": self.incapsulaScriptBase64Example,"incapsulaSessionCookie": self.incapsulaSessionCookieExample}
metadata_required_fields = ['incapsulaScriptUrl', 'incapsulaCookie']
metadata_example = {"incapsulaScriptUrl": self.incapsulaScriptUrlExample,"incapsulaCookie": self.incapsulaCookieExample}
request = ImpervaCustomTaskRequest(websiteUrl=self.websiteUrlExample, metadata=metadata_example)
task_dictionary = request.getTaskDict()
for f in required_fields:
Expand All @@ -32,9 +32,9 @@ def test_imperva(self,
def test_imperva_metadata(self,):
base_kwargs = {"websiteUrl": self.websiteUrlExample, "metadata": {}}
self.assertRaises(TypeError, ImpervaCustomTaskRequest, **base_kwargs)
base_kwargs['metadata']['incapsulaScriptBase64'] = self.incapsulaScriptBase64Example
base_kwargs['metadata']['incapsulaScriptUrl'] = self.incapsulaScriptUrlExample
self.assertRaises(TypeError, ImpervaCustomTaskRequest, **base_kwargs)
base_kwargs['metadata']['incapsulaSessionCookie'] = self.incapsulaSessionCookieExample
base_kwargs['metadata']['incapsulaCookie'] = self.incapsulaCookieExample
ImpervaCustomTaskRequest(**base_kwargs)
base_kwargs['metadata']['reese84UrlEndpoint'] = self.reese84UrlEndpointExample
ImpervaCustomTaskRequest(**base_kwargs)
Expand All @@ -44,7 +44,7 @@ def test_imperva_missing(self,):
'websiteURL',
'metadata']
base_kwargs = {}
metadata_example = {"incapsulaScriptBase64": self.incapsulaScriptBase64Example,"incapsulaSessionCookie": self.incapsulaSessionCookieExample}
metadata_example = {"incapsulaScriptUrl": self.incapsulaScriptUrlExample,"incapsulaCookie": self.incapsulaCookieExample}
self.assertRaises(ValidationError, ImpervaCustomTaskRequest, **base_kwargs)
base_kwargs.update({'websiteUrl': self.websiteUrlExample})
self.assertRaises(ValidationError, ImpervaCustomTaskRequest, **base_kwargs)
Expand Down
Loading