@@ -48,6 +48,20 @@ public class OpenApiOAuthFlowsTests
4848 }
4949 } ;
5050
51+ public static OpenApiOAuthFlows OAuthFlowsWithDeviceAuthorization = new ( )
52+ {
53+ DeviceAuthorization = new ( )
54+ {
55+ TokenUrl = new ( "http://example.com/token" ) ,
56+ RefreshUrl = new ( "http://example.com/refresh" ) ,
57+ Scopes = new Dictionary < string , string >
58+ {
59+ [ "scopeName1" ] = "description1" ,
60+ [ "scopeName2" ] = "description2"
61+ }
62+ }
63+ } ;
64+
5165 [ Fact ]
5266 public async Task SerializeBasicOAuthFlowsAsV3JsonWorks ( )
5367 {
@@ -139,5 +153,86 @@ public async Task SerializeOAuthFlowsWithMultipleFlowsAsV3JsonWorks()
139153 expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
140154 Assert . Equal ( expected , actual ) ;
141155 }
156+
157+ [ Fact ]
158+ public async Task SerializeOAuthFlowsWithDeviceAuthorizationAsV32JsonWorks ( )
159+ {
160+ // Arrange
161+ var expected =
162+ """
163+ {
164+ "deviceAuthorization": {
165+ "tokenUrl": "http://example.com/token",
166+ "refreshUrl": "http://example.com/refresh",
167+ "scopes": {
168+ "scopeName1": "description1",
169+ "scopeName2": "description2"
170+ }
171+ }
172+ }
173+ """ ;
174+
175+ // Act
176+ var actual = await OAuthFlowsWithDeviceAuthorization . SerializeAsJsonAsync ( OpenApiSpecVersion . OpenApi3_2 ) ;
177+
178+ // Assert
179+ actual = actual . MakeLineBreaksEnvironmentNeutral ( ) ;
180+ expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
181+ Assert . Equal ( expected , actual ) ;
182+ }
183+
184+ [ Fact ]
185+ public async Task SerializeOAuthFlowsWithDeviceAuthorizationAsV31JsonWorks ( )
186+ {
187+ // Arrange
188+ var expected =
189+ """
190+ {
191+ "x-oai-deviceAuthorization": {
192+ "tokenUrl": "http://example.com/token",
193+ "refreshUrl": "http://example.com/refresh",
194+ "scopes": {
195+ "scopeName1": "description1",
196+ "scopeName2": "description2"
197+ }
198+ }
199+ }
200+ """ ;
201+
202+ // Act
203+ var actual = await OAuthFlowsWithDeviceAuthorization . SerializeAsJsonAsync ( OpenApiSpecVersion . OpenApi3_1 ) ;
204+
205+ // Assert
206+ actual = actual . MakeLineBreaksEnvironmentNeutral ( ) ;
207+ expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
208+ Assert . Equal ( expected , actual ) ;
209+ }
210+
211+ [ Fact ]
212+ public async Task SerializeOAuthFlowsWithDeviceAuthorizationAsV3JsonWorks ( )
213+ {
214+ // Arrange
215+ var expected =
216+ """
217+ {
218+ "x-oai-deviceAuthorization": {
219+ "tokenUrl": "http://example.com/token",
220+ "refreshUrl": "http://example.com/refresh",
221+ "scopes": {
222+ "scopeName1": "description1",
223+ "scopeName2": "description2"
224+ }
225+ }
226+ }
227+ """ ;
228+
229+ // Act
230+ var actual = await OAuthFlowsWithDeviceAuthorization . SerializeAsJsonAsync ( OpenApiSpecVersion . OpenApi3_0 ) ;
231+
232+ // Assert
233+ actual = actual . MakeLineBreaksEnvironmentNeutral ( ) ;
234+ expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
235+ Assert . Equal ( expected , actual ) ;
236+ }
142237 }
143238}
0 commit comments