@@ -104,6 +104,89 @@ def test_issue_stateless_channel_token_by_client_secret(self):
104104 self .assertNotIn ('client_assertion_type' , encoded_body )
105105 self .assertNotIn ('client_assertion' , encoded_body )
106106
107+ def test_issue_stateless_channel_token_with_http_info_by_jwt_assertion (self ):
108+ client_assertion = 'eyJhbGciOiJSUzI.q....'
109+ client_assertion_type = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'
110+
111+ with HTTPServer () as httpserver :
112+ httpserver .expect_request (
113+ uri = "/oauth2/v3/token" ,
114+ method = "POST" ,
115+ ).respond_with_json (
116+ {
117+ 'access_token' : 'test_access_token' ,
118+ 'expires_in' : 900 ,
119+ 'token_type' : 'Bearer' ,
120+ },
121+ status = 200 ,
122+ )
123+
124+ configuration = Configuration (host = httpserver .url_for ("/" ))
125+ with ApiClient (configuration ) as api_client :
126+ api = ChannelAccessToken (api_client )
127+ api .line_base_path = httpserver .url_for ("/" )
128+
129+ api_response = api .issue_stateless_channel_token_with_http_info_by_jwt_assertion (
130+ client_assertion ,
131+ )
132+
133+ self .assertEqual (api_response .status_code , 200 )
134+ response = api_response .data
135+ self .assertEqual (response .access_token , 'test_access_token' )
136+ self .assertEqual (response .expires_in , 900 )
137+ self .assertEqual (response .token_type , 'Bearer' )
138+ self .assertEqual (len (httpserver .log ), 1 )
139+
140+ request , _ = httpserver .log [0 ]
141+ encoded_body = parse_qs (request .data .decode ('utf-8' ))
142+ self .assertEqual (encoded_body ['grant_type' ], ['client_credentials' ])
143+ self .assertEqual (encoded_body ['client_assertion_type' ], [client_assertion_type ])
144+ self .assertEqual (encoded_body ['client_assertion' ], [client_assertion ])
145+ self .assertNotIn ('client_id' , encoded_body )
146+ self .assertNotIn ('client_secret' , encoded_body )
147+
148+ def test_issue_stateless_channel_token_with_http_info_by_client_secret (self ):
149+ client_id = 'test_client_id'
150+ client_secret = 'test_client_secret'
151+
152+ with HTTPServer () as httpserver :
153+ httpserver .expect_request (
154+ uri = "/oauth2/v3/token" ,
155+ method = "POST" ,
156+ ).respond_with_json (
157+ {
158+ 'access_token' : 'test_access_token' ,
159+ 'expires_in' : 900 ,
160+ 'token_type' : 'Bearer' ,
161+ },
162+ status = 200 ,
163+ )
164+
165+ configuration = Configuration (host = httpserver .url_for ("/" ))
166+ with ApiClient (configuration ) as api_client :
167+ api = ChannelAccessToken (api_client )
168+ api .line_base_path = httpserver .url_for ("/" )
169+
170+ api_response = api .issue_stateless_channel_token_with_http_info_by_client_secret (
171+ client_id ,
172+ client_secret ,
173+ )
174+
175+ self .assertEqual (api_response .status_code , 200 )
176+ response = api_response .data
177+ self .assertEqual (response .access_token , 'test_access_token' )
178+ self .assertEqual (response .expires_in , 900 )
179+ self .assertEqual (response .token_type , 'Bearer' )
180+ self .assertEqual (len (httpserver .log ), 1 )
181+
182+ request , _ = httpserver .log [0 ]
183+ encoded_body = parse_qs (request .data .decode ('utf-8' ))
184+ self .assertEqual (encoded_body ['grant_type' ], ['client_credentials' ])
185+ self .assertEqual (encoded_body ['client_id' ], [client_id ])
186+ self .assertEqual (encoded_body ['client_secret' ], [client_secret ])
187+ self .assertNotIn ('client_assertion_type' , encoded_body )
188+ self .assertNotIn ('client_assertion' , encoded_body )
189+
107190
108191if __name__ == '__main__' :
109192 unittest .main ()
0 commit comments