File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -29,12 +29,18 @@ def test_lessknown_host_will_return_a_set_of_v1_endpoints(self):
2929 self .assertNotIn ('v2.0' , a .token_endpoint )
3030
3131 def test_unknown_host_wont_pass_instance_discovery (self ):
32- with self .assertRaisesRegexp (ValueError , "invalid_instance" ):
33- Authority ('https://unknown.host/tenant_doesnt_matter_in_this_case' )
34-
35- def test_invalid_host_skipping_validation_meets_connection_error_down_the_road (self ):
36- with self .assertRaises (requests .exceptions .RequestException ):
37- Authority ('https://unknown.host/invalid' , validate_authority = False )
32+ _assert = getattr (self , "assertRaisesRegex" , self .assertRaisesRegexp ) # Hack
33+ with _assert (ValueError , "invalid_instance" ):
34+ Authority ('https://example.com/tenant_doesnt_matter_in_this_case' )
35+
36+ def test_invalid_host_skipping_validation_can_be_turned_off (self ):
37+ try :
38+ Authority ('https://example.com/invalid' , validate_authority = False )
39+ except ValueError as e :
40+ if "invalid_instance" in str (e ): # Imprecise but good enough
41+ self .fail ("validate_authority=False should turn off validation" )
42+ except : # Could be requests...RequestException, json...JSONDecodeError, etc.
43+ pass # Those are expected for this unittest case
3844
3945
4046class TestAuthorityInternalHelperCanonicalize (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments