@@ -121,13 +121,29 @@ def _test_happy_path(self, app, mocked_http, expires_in, resource="R"):
121
121
122
122
class VmTestCase (ClientTestCase ):
123
123
124
- def test_happy_path (self ):
124
+ def _test_happy_path (self ) -> callable :
125
125
expires_in = 7890 # We test a bigger than 7200 value here
126
126
with patch .object (self .app ._http_client , "get" , return_value = MinimalResponse (
127
127
status_code = 200 ,
128
128
text = '{"access_token": "AT", "expires_in": "%s", "resource": "R"}' % expires_in ,
129
129
)) as mocked_method :
130
- self ._test_happy_path (self .app , mocked_method , expires_in )
130
+ super (VmTestCase , self )._test_happy_path (self .app , mocked_method , expires_in )
131
+ return mocked_method
132
+
133
+ def test_happy_path_of_vm (self ):
134
+ self ._test_happy_path ().assert_called_with (
135
+ 'http://169.254.169.254/metadata/identity/oauth2/token' ,
136
+ params = {'api-version' : '2018-02-01' , 'resource' : 'R' },
137
+ headers = {'Metadata' : 'true' },
138
+ )
139
+
140
+ @patch .dict (os .environ , {"AZURE_POD_IDENTITY_AUTHORITY_HOST" : "http://localhost:1234//" })
141
+ def test_happy_path_of_pod_identity (self ):
142
+ self ._test_happy_path ().assert_called_with (
143
+ 'http://localhost:1234/metadata/identity/oauth2/token' ,
144
+ params = {'api-version' : '2018-02-01' , 'resource' : 'R' },
145
+ headers = {'Metadata' : 'true' },
146
+ )
131
147
132
148
def test_vm_error_should_be_returned_as_is (self ):
133
149
raw_error = '{"raw": "error format is undefined"}'
0 commit comments