#NEWLINE# @ patch ( 'requests.Response' ) #NEWLINE# @ patch ( 'dcos.http._request' ) #NEWLINE# @ patch ( 'dcos.http._get_http_auth' ) #NEWLINE# def test_request_with_bad_auth_acl( mock , req_mock , auth_mock ) : #NEWLINE# #INDENT# mock . url = 'http://domain.com' #NEWLINE# mock . headers = { #NEWLINE# #INDENT# 'www-authenticate' : 'acsjwt' , #NEWLINE# #UNINDENT# } #NEWLINE# mock . status_code = 401 #NEWLINE# auth_mock . return_value = http . DCOSAcsAuth ( 'token' ) #NEWLINE# req_mock . return_value = e #NEWLINE# with pytest . raises ( DCOSException ) as e : #NEWLINE# #INDENT# http . _request_with_auth ( mock , 'method' , mock . url ) #NEWLINE# #UNINDENT# msg = 'Your core.dcos_acs_token is invalid. Please run: `dcos auth login`' #NEWLINE# assert ( e . exconly ( ) . split ( ':' , 1 ) [ 1 ] . strip ( ) == msg )