Skip to content

Commit 7ac2640

Browse files
committed
Rename parameter
1 parent f95abc5 commit 7ac2640

File tree

6 files changed

+40
-40
lines changed

6 files changed

+40
-40
lines changed

src/onelogin/saml2/logout_request.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,14 @@ def get_session_indexes(request):
212212
session_indexes.append(session_index_node.text)
213213
return session_indexes
214214

215-
def is_valid(self, request_data, raises=False):
215+
def is_valid(self, request_data, raise_exceptions=False):
216216
"""
217217
Checks if the Logout Request received is valid
218218
:param request_data: Request Data
219219
:type request_data: dict
220220
221-
:param raises: Optional argument. If true, the function will raise an exception as soon as first validation test fails
222-
:type raises: bool
221+
:param raise_exceptions: Whether to return false on failure or raise an exception
222+
:type raise_exceptions: Boolean
223223
224224
:return: If the Logout Request is or not valid
225225
:rtype: boolean
@@ -277,7 +277,7 @@ def is_valid(self, request_data, raises=False):
277277
debug = self.__settings.is_debug_active()
278278
if debug:
279279
print(err)
280-
if raises:
280+
if raise_exceptions:
281281
raise
282282
return False
283283

src/onelogin/saml2/logout_response.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ def get_status(self):
6363
status = entries[0].attrib['Value']
6464
return status
6565

66-
def is_valid(self, request_data, request_id=None, raises=False):
66+
def is_valid(self, request_data, request_id=None, raise_exceptions=False):
6767
"""
6868
Determines if the SAML LogoutResponse is valid
6969
:param request_id: The ID of the LogoutRequest sent by this SP to the IdP
7070
:type request_id: string
7171
72-
:param raises: Optional argument. If true, the function will raise an exception as soon as first validation test fails
73-
:type raises: bool
72+
:param raise_exceptions: Whether to return false on failure or raise an exception
73+
:type raise_exceptions: Boolean
7474
7575
:return: Returns if the SAML LogoutResponse is or not valid
7676
:rtype: boolean
@@ -115,7 +115,7 @@ def is_valid(self, request_data, request_id=None, raises=False):
115115
debug = self.__settings.is_debug_active()
116116
if debug:
117117
print(err)
118-
if raises:
118+
if raise_exceptions:
119119
raise
120120
return False
121121

src/onelogin/saml2/response.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, settings, response):
4747
self.encrypted = True
4848
self.decrypted_document = self.__decrypt_assertion(decrypted_document)
4949

50-
def is_valid(self, request_data, request_id=None, raises=False):
50+
def is_valid(self, request_data, request_id=None, raise_exceptions=False):
5151
"""
5252
Validates the response object.
5353
@@ -57,8 +57,8 @@ def is_valid(self, request_data, request_id=None, raises=False):
5757
:param request_id: Optional argument. The ID of the AuthNRequest sent by this SP to the IdP
5858
:type request_id: string
5959
60-
:param raises: Optional argument. If true, the function will raise an exception as soon as first validation test fails
61-
:type raises: bool
60+
:param raise_exceptions: Whether to return false on failure or raise an exception
61+
:type raise_exceptions: Boolean
6262
6363
:returns: True if the SAML Response is valid, False if not
6464
:rtype: bool
@@ -229,7 +229,7 @@ def is_valid(self, request_data, request_id=None, raises=False):
229229
debug = self.__settings.is_debug_active()
230230
if debug:
231231
print(err)
232-
if raises:
232+
if raise_exceptions:
233233
raise
234234
return False
235235

tests/src/OneLogin/saml2_tests/logout_request_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def testIsInvalidIssuer(self):
236236
settings.set_strict(True)
237237
logout_request2 = OneLogin_Saml2_Logout_Request(settings, OneLogin_Saml2_Utils.b64encode(request))
238238
with self.assertRaisesRegexp(Exception, 'Invalid issuer in the Logout Request'):
239-
logout_request2.is_valid(request_data, raises=True)
239+
logout_request2.is_valid(request_data, raise_exceptions=True)
240240

241241
def testIsInvalidDestination(self):
242242
"""
@@ -255,7 +255,7 @@ def testIsInvalidDestination(self):
255255
settings.set_strict(True)
256256
logout_request2 = OneLogin_Saml2_Logout_Request(settings, OneLogin_Saml2_Utils.b64encode(request))
257257
with self.assertRaisesRegexp(Exception, 'The LogoutRequest was received at'):
258-
logout_request2.is_valid(request_data, raises=True)
258+
logout_request2.is_valid(request_data, raise_exceptions=True)
259259

260260
dom = parseString(request)
261261
dom.documentElement.setAttribute('Destination', None)
@@ -286,7 +286,7 @@ def testIsInvalidNotOnOrAfter(self):
286286
settings.set_strict(True)
287287
logout_request2 = OneLogin_Saml2_Logout_Request(settings, OneLogin_Saml2_Utils.b64encode(request))
288288
with self.assertRaisesRegexp(Exception, 'Timing issues \(please check your clock settings\)'):
289-
logout_request2.is_valid(request_data, raises=True)
289+
logout_request2.is_valid(request_data, raise_exceptions=True)
290290

291291
def testIsValid(self):
292292
"""
@@ -334,4 +334,4 @@ def testIsValidRaisesExceptionWhenRaisesArgumentIsTrue(self):
334334
self.assertFalse(logout_request.is_valid(request_data))
335335

336336
with self.assertRaises(Exception):
337-
logout_request.is_valid(request_data, raises=True)
337+
logout_request.is_valid(request_data, raise_exceptions=True)

tests/src/OneLogin/saml2_tests/logout_response_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def testIsInValidIssuer(self):
202202
settings.set_strict(True)
203203
response_2 = OneLogin_Saml2_Logout_Response(settings, message)
204204
with self.assertRaisesRegexp(Exception, 'Invalid issuer in the Logout Request'):
205-
response_2.is_valid(request_data, raises=True)
205+
response_2.is_valid(request_data, raise_exceptions=True)
206206

207207
def testIsInValidDestination(self):
208208
"""
@@ -224,7 +224,7 @@ def testIsInValidDestination(self):
224224
settings.set_strict(True)
225225
response_2 = OneLogin_Saml2_Logout_Response(settings, message)
226226
with self.assertRaisesRegexp(Exception, 'The LogoutRequest was received at'):
227-
response_2.is_valid(request_data, raises=True)
227+
response_2.is_valid(request_data, raise_exceptions=True)
228228

229229
# Empty destination
230230
dom = parseString(OneLogin_Saml2_Utils.decode_base64_and_inflate(message))
@@ -259,7 +259,7 @@ def testIsValid(self):
259259
settings.set_strict(True)
260260
response_2 = OneLogin_Saml2_Logout_Response(settings, message)
261261
with self.assertRaisesRegexp(Exception, 'The LogoutRequest was received at'):
262-
response_2.is_valid(request_data, raises=True)
262+
response_2.is_valid(request_data, raise_exceptions=True)
263263

264264
plain_message = compat.to_string(OneLogin_Saml2_Utils.decode_base64_and_inflate(message))
265265
current_url = OneLogin_Saml2_Utils.get_self_url_no_query(request_data)
@@ -284,4 +284,4 @@ def testIsValidRaisesExceptionWhenRaisesArgumentIsTrue(self):
284284
self.assertFalse(response.is_valid(request_data))
285285

286286
with self.assertRaises(Exception):
287-
response.is_valid(request_data, raises=True)
287+
response.is_valid(request_data, raise_exceptions=True)

tests/src/OneLogin/saml2_tests/response_test.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ def testValidateVersion(self):
493493
xml = self.file_contents(join(self.data_path, 'responses', 'invalids', 'no_saml2.xml.base64'))
494494
response = OneLogin_Saml2_Response(settings, xml)
495495
with self.assertRaisesRegexp(Exception, 'Unsupported SAML version'):
496-
response.is_valid(self.get_request_data(), raises=True)
496+
response.is_valid(self.get_request_data(), raise_exceptions=True)
497497

498498
def testValidateID(self):
499499
"""
@@ -504,7 +504,7 @@ def testValidateID(self):
504504
xml = self.file_contents(join(self.data_path, 'responses', 'invalids', 'no_id.xml.base64'))
505505
response = OneLogin_Saml2_Response(settings, xml)
506506
with self.assertRaisesRegexp(Exception, 'Missing ID attribute on SAML Response'):
507-
response.is_valid(self.get_request_data(), raises=True)
507+
response.is_valid(self.get_request_data(), raise_exceptions=True)
508508

509509
def testIsInValidReference(self):
510510
"""
@@ -534,7 +534,7 @@ def testIsInValidExpired(self):
534534
settings.set_strict(True)
535535
response_2 = OneLogin_Saml2_Response(settings, xml)
536536
with self.assertRaisesRegexp(Exception, 'Timing issues \(please check your clock settings\)'):
537-
response_2.is_valid(self.get_request_data(), raises=True)
537+
response_2.is_valid(self.get_request_data(), raise_exceptions=True)
538538

539539
def testIsInValidNoStatement(self):
540540
"""
@@ -592,7 +592,7 @@ def testIsInValidNoKey(self):
592592
xml = self.file_contents(join(self.data_path, 'responses', 'invalids', 'no_key.xml.base64'))
593593
response = OneLogin_Saml2_Response(settings, xml)
594594
with self.assertRaisesRegexp(Exception, 'Signature validation failed. SAML Response rejected'):
595-
response.is_valid(self.get_request_data(), raises=True)
595+
response.is_valid(self.get_request_data(), raise_exceptions=True)
596596

597597
def testIsInValidMultipleAssertions(self):
598598
"""
@@ -604,7 +604,7 @@ def testIsInValidMultipleAssertions(self):
604604
xml = self.file_contents(join(self.data_path, 'responses', 'invalids', 'multiple_assertions.xml.base64'))
605605
response = OneLogin_Saml2_Response(settings, xml)
606606
with self.assertRaisesRegexp(Exception, 'SAML Response must contain 1 assertion'):
607-
response.is_valid(self.get_request_data(), raises=True)
607+
response.is_valid(self.get_request_data(), raise_exceptions=True)
608608

609609
def testIsInValidEncAttrs(self):
610610
"""
@@ -620,7 +620,7 @@ def testIsInValidEncAttrs(self):
620620
settings.set_strict(True)
621621
response_2 = OneLogin_Saml2_Response(settings, xml)
622622
with self.assertRaisesRegexp(Exception, 'There is an EncryptedAttribute in the Response and this SP not support them'):
623-
response_2.is_valid(self.get_request_data(), raises=True)
623+
response_2.is_valid(self.get_request_data(), raise_exceptions=True)
624624

625625
def testIsInValidDuplicatedAttrs(self):
626626
"""
@@ -723,11 +723,11 @@ def testIsInValidIssuer(self):
723723
settings.set_strict(True)
724724
response_3 = OneLogin_Saml2_Response(settings, message)
725725
with self.assertRaisesRegexp(Exception, 'Invalid issuer in the Assertion/Response'):
726-
response_3.is_valid(request_data, raises=True)
726+
response_3.is_valid(request_data, raise_exceptions=True)
727727

728728
response_4 = OneLogin_Saml2_Response(settings, message_2)
729729
with self.assertRaisesRegexp(Exception, 'Invalid issuer in the Assertion/Response'):
730-
response_4.is_valid(request_data, raises=True)
730+
response_4.is_valid(request_data, raise_exceptions=True)
731731

732732
def testIsInValidSessionIndex(self):
733733
"""
@@ -752,7 +752,7 @@ def testIsInValidSessionIndex(self):
752752
settings.set_strict(True)
753753
response_2 = OneLogin_Saml2_Response(settings, message)
754754
with self.assertRaisesRegexp(Exception, 'The attributes have expired, based on the SessionNotOnOrAfter of the AttributeStatement of this Response'):
755-
response_2.is_valid(request_data, raises=True)
755+
response_2.is_valid(request_data, raise_exceptions=True)
756756

757757
def testDatetimeWithMiliseconds(self):
758758
"""
@@ -843,27 +843,27 @@ def testIsInValidSubjectConfirmation(self):
843843
settings.set_strict(True)
844844
response = OneLogin_Saml2_Response(settings, message)
845845
with self.assertRaisesRegexp(Exception, 'A valid SubjectConfirmation was not found on this Response'):
846-
response.is_valid(request_data, raises=True)
846+
response.is_valid(request_data, raise_exceptions=True)
847847

848848
response_2 = OneLogin_Saml2_Response(settings, message_2)
849849
with self.assertRaisesRegexp(Exception, 'A valid SubjectConfirmation was not found on this Response'):
850-
response_2.is_valid(request_data, raises=True)
850+
response_2.is_valid(request_data, raise_exceptions=True)
851851

852852
response_3 = OneLogin_Saml2_Response(settings, message_3)
853853
with self.assertRaisesRegexp(Exception, 'A valid SubjectConfirmation was not found on this Response'):
854-
response_3.is_valid(request_data, raises=True)
854+
response_3.is_valid(request_data, raise_exceptions=True)
855855

856856
response_4 = OneLogin_Saml2_Response(settings, message_4)
857857
with self.assertRaisesRegexp(Exception, 'A valid SubjectConfirmation was not found on this Response'):
858-
response_4.is_valid(request_data, raises=True)
858+
response_4.is_valid(request_data, raise_exceptions=True)
859859

860860
response_5 = OneLogin_Saml2_Response(settings, message_5)
861861
with self.assertRaisesRegexp(Exception, 'A valid SubjectConfirmation was not found on this Response'):
862-
response_5.is_valid(request_data, raises=True)
862+
response_5.is_valid(request_data, raise_exceptions=True)
863863

864864
response_6 = OneLogin_Saml2_Response(settings, message_6)
865865
with self.assertRaisesRegexp(Exception, 'A valid SubjectConfirmation was not found on this Response'):
866-
response_6.is_valid(request_data, raises=True)
866+
response_6.is_valid(request_data, raise_exceptions=True)
867867

868868
def testIsInValidRequestId(self):
869869
"""
@@ -889,7 +889,7 @@ def testIsInValidRequestId(self):
889889
settings.set_strict(True)
890890
response = OneLogin_Saml2_Response(settings, message)
891891
with self.assertRaisesRegexp(Exception, 'The InResponseTo of the Response'):
892-
response.is_valid(request_data, request_id, raises=True)
892+
response.is_valid(request_data, request_id, raise_exceptions=True)
893893

894894
valid_request_id = '_57bcbf70-7b1f-012e-c821-782bcb13bb38'
895895
response.is_valid(request_data, valid_request_id)
@@ -934,7 +934,7 @@ def testIsInValidSignIssues(self):
934934
settings_4 = OneLogin_Saml2_Settings(settings_info)
935935
response_4 = OneLogin_Saml2_Response(settings_4, message)
936936
with self.assertRaisesRegexp(Exception, 'The Assertion of the Response is not signed and the SP require it'):
937-
response_4.is_valid(request_data, raises=True)
937+
response_4.is_valid(request_data, raise_exceptions=True)
938938

939939
settings_info['security']['wantAssertionsSigned'] = False
940940
settings_info['strict'] = False
@@ -962,7 +962,7 @@ def testIsInValidSignIssues(self):
962962
settings_8 = OneLogin_Saml2_Settings(settings_info)
963963
response_8 = OneLogin_Saml2_Response(settings_8, message)
964964
with self.assertRaisesRegexp(Exception, 'The Message of the Response is not signed and the SP require it'):
965-
response_8.is_valid(request_data, raises=True)
965+
response_8.is_valid(request_data, raise_exceptions=True)
966966

967967
def testIsInValidEncIssues(self):
968968
"""
@@ -1044,7 +1044,7 @@ def testIsInValidCert(self):
10441044
response = OneLogin_Saml2_Response(settings, xml)
10451045

10461046
with self.assertRaisesRegexp(Exception, 'failed to load key'):
1047-
response.is_valid(self.get_request_data(), raises=True)
1047+
response.is_valid(self.get_request_data(), raise_exceptions=True)
10481048

10491049
def testIsInValidCert2(self):
10501050
"""
@@ -1270,4 +1270,4 @@ def testIsValidRaisesExceptionWhenRaisesArgumentIsTrue(self):
12701270
self.assertFalse(response.is_valid(self.get_request_data()))
12711271

12721272
with self.assertRaises(Exception):
1273-
response.is_valid(self.get_request_data(), raises=True)
1273+
response.is_valid(self.get_request_data(), raise_exceptions=True)

0 commit comments

Comments
 (0)